entire song isn't played
laurent974
Posts: 77
How long a wav song can be played ?
i tried this code, but the song is stopped after around 10sec. i tried also with only one pause and the length of the song 2 min = pause(120 000 )
but the result is the same.
Edit : Forget my question. it works
i tried this code, but the song is stopped after around 10sec. i tried also with only one pause and the length of the song 2 min = pause(120 000 )
but the result is the same.
#include "simpletools.h" #include "wavplayer.h" int main() // main function { int DO = 22, CLK = 23, DI = 24, CS = 25; // SD I/O pins sd_mount(DO, CLK, DI, CS); // Mount SD card const char techloop[] = {"luftbal.wav"}; // Set up techloop string wav_play(techloop); // Pass to wav player wav_volume(10); pause(5000); pause(5000); pause(5000); pause(5000); pause(5000); wav_stop(); // Stop playing }
Edit : Forget my question. it works
Comments
But I don't understand why, because pause is defined with an int (see code below), and int is as large as 0xFFFF FFFF (and not 0xFFFF)
from pause.c in simpletool
https://github.com/parallaxinc/Simple-Libraries/blob/master/Learn/Simple%20Libraries/Utility/libsimpletools/source/pause.c
Because the parameter is multiplied by st_pauseTicks. Assuming the clock is 80MHz then 1ms = 80000000/1000 = 80000 ticks, if you pass a time value of 80000ms the result is 80000*80.000=6400000000 or $17D784000 well above the limit. The maximum allowed time should be 4294967295 / 80000 = 53687 milliseconds.
Here's another approach:
A variation on that would be if(!wav_playing()) { //code that runs once, followed by break; to exit the playing loop and move on to other things }.
A third approach is to just loop without paying attention to if the song is playing. Here is an example of how that can be used:
App
http://learn.parallax.com/tutorials/robot/activitybot/remote-control-rock-talk-and-roll-activitybot
Code
http://learn.parallax.com/tutorials/robot/activitybot/remote-control-rock-talk-and-roll-activitybot/how-does-it-all-work
P.S.
I got a bug report about pause saying that it only plays for half that time, so I'd recommend using pause(26000) as a max for the time being.
i understand where my mistake came from: i was following the tutorial on how to play wav
http://learn.parallax.com/tutorials/language/propeller-c/propeller-c-simple-devices/play-wav-files
and it's written : i was thinking i had to dedicate a 3rd cog just to play and insert some pause. indeed the pause is there just to prevent the main loop stopping.
I did not reach the last tutorial you mentioned. i 'll change the code of my roaming jukeBOT.
the wav_playing() isn't working. here is my code
it never enters in the first clause of if
maybe because it runs out of cog due to bouge() function