Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 14:18 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : PLAY WAV - PROGRAMM STOPS

Author Message
rentner111
Newbie

Joined: 18/03/2014
Location: Austria
Posts: 19
Posted: 12:10am 20 Jul 2017
Copy link to clipboard 
Print this post

Hi Geoff!
The implementation of "PLAY WAV" in the Basic of the PIC470 is a great thing.

Unfortunately the running program remains about one second before WAV end to the

WAV end hang. It does not matter if the announcement is long or short.


Here is a small demonstration program:

The announcement is started.
The LED flashes in the DO - LOOP.
About one second before WAV end, the LED stops flashing.
After WAV end, the LED flashes again.

Best greetings from Tyrol / Austria


Option autorun
LED = 1
Setpin LED, dout
PLAY WAV "TEST.WAV", WAVEND ()
do
Pin (LED) = 0 'LED flashing
Pause 50

pin (LED) = 1
Pause 50
loop

Sub WAVEN ()
Print "PLAY END"
End sub
end
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9749
Posted: 03:09am 20 Jul 2017
Copy link to clipboard 
Print this post

Well, I'm not Geoff, but.....

MMBASIC probably does not like the double-parenthesis.
I would drop that so your code just looks like:


Option autorun
LED = 1
Setpin LED, dout
PLAY WAV "TEST.WAV", WAVEND
do
Pin (LED) = 0 'LED flashing
Pause 50

pin (LED) = 1
Pause 50
loop

Sub WAVEND
Print "PLAY END"
End sub
end
[/Code]

Not tested, but I did do plenty of testing on the PLAY WAV command, and never had that hanging problem - I THINK it is coming from the fact that you are calling your sub from the PLAY WAV command, and MMBASIC is interpreting that as passing an array via the () syntax, so it tries to call WAVEND as a sub, but also tries to treat that as passing an array at the same time, and crashes.

I might have that wrong, but that is how I interpret it anyway. I would be very interested to know how you go if you remove the ().....
Smoke makes things work. When the smoke gets out, it stops!
 
rentner111
Newbie

Joined: 18/03/2014
Location: Austria
Posts: 19
Posted: 05:51am 20 Jul 2017
Copy link to clipboard 
Print this post

Hi Grogster!

Thanks for the answer.
I have tested the following program without ().

Option autorun on
LED = 1
Setpin LED, dout

PLAY WAV "alisauhr.WAV"

do
Pin (LED) = 0 'LED flashing
Pause 50
Pin (LED) = 1
Pause 50
loop

end


It is the same result. The length of the WAV file is 10 seconds.
The LED flashes until the 9th second.
From 9th to 10th no flashing of the LED.
Then the LED flashes again.
LED flashing means that the DO-LOOP is going through.

Thank you very much
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 06:01am 20 Jul 2017
Copy link to clipboard 
Print this post

Try a different SD card and/or other wave file.
Microblocks. Build with logic.
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9749
Posted: 05:16pm 20 Jul 2017
Copy link to clipboard 
Print this post

If you are saying that what you get is(in pseudo-code):


START {OK}
PLAY FILE {OK}
START BLINKING LED {OK}
FILE PLAYBACK ENDS {OK}
LED STOPS FLASHING FOR ONE SECOND OR SO THEN STARTS AGAIN {OK}
[/Code]

This may be normal - I never tested the time it takes for MMBASIC to return from playing a file in the background. matherp or Geoff would indeed be able to tell you if that is normal, but this short delay at the end of playback could, in fact, be normal.

Your code seems to halt at the end of playback(not your doing), but then resumes a second or so later, which may be unwanted, but normal. We'll wait and see what the guru's say.
Smoke makes things work. When the smoke gets out, it stops!
 
rentner111
Newbie

Joined: 18/03/2014
Location: Austria
Posts: 19
Posted: 09:50pm 20 Jul 2017
Copy link to clipboard 
Print this post

The program will actually stay for about 1100 msec.
If the WATCHDOG 1000 command is activated, a restart is carried out by the watchdog at the end of the PLAY WAV command.
Only at WATCHDOG> 1100 is no restart.

Best regards from Tyrol / Austria
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9749
Posted: 10:08pm 20 Jul 2017
Copy link to clipboard 
Print this post

Interesting......

I will bow out now, and watch to see if one of the guru's chime in with any ideas.
Smoke makes things work. When the smoke gets out, it stops!
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1116
Posted: 06:23pm 23 Jul 2017
Copy link to clipboard 
Print this post

Erwin,

Interesting and clever use of the WATCHDOG command for faultfinding.

Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
PicFan
Senior Member

Joined: 18/03/2014
Location: Austria
Posts: 133
Posted: 10:10pm 02 Aug 2017
Copy link to clipboard 
Print this post

Yes, the pause is unfortunately very disturbing if one wants to form sentences from individual words. The interrupt is also about 1 sec. delayed. For example, for a time announcement.

Wolfgang
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10565
Posted: 06:28am 07 Nov 2017
Copy link to clipboard 
Print this post

I've just fixed this for the Micromite eXtreme. I'll notify Geoff of the fix to include in a future release for the MM+ - it is the same code.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025