wav_play Issues - Limited Play Times
BTL24
Posts: 54
I am attempting to have a wav file play over and over again... indefinitely (until I stop program), but am having issues as it only plays 5 times then stops.
When I utilize the wav_play function as shown in the code below, the wav file "yay" only plays 5 times... then goes silent. The code continues to run as evidenced in the serial terminal. If I reload the program, it will play 5 times again.. then stop again.
FYI...I am running code on the Prop Activity board through the simple IDE. The Yay.wav file is from the Parallax tutorials.
Is there an issue that the wav_play function keeps opening new cogs... then eventually runs out? Am I exceeding a stack somewhere? Any help would be appreciated.
Regards,
Brian
When I utilize the wav_play function as shown in the code below, the wav file "yay" only plays 5 times... then goes silent. The code continues to run as evidenced in the serial terminal. If I reload the program, it will play 5 times again.. then stop again.
FYI...I am running code on the Prop Activity board through the simple IDE. The Yay.wav file is from the Parallax tutorials.
Is there an issue that the wav_play function keeps opening new cogs... then eventually runs out? Am I exceeding a stack somewhere? Any help would be appreciated.
Regards,
Brian
/* Test WAV Volume (10).c */ #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 yay[] = {"yay.wav"}; while(1) { print("Play Wave File\n"); wav_play(yay); // Pass to wav player wav_volume(6); // Adjust volume print("Play medium\n"); pause(3000); // Play for 5 sec wav_stop(); // Stop playing } }
Comments
However, tests proved futile, as the player again only played the "yay.wav" file 5 times before ceasing to play it anymore in my rendition of the code (See attached). Other code continues to run per the serial terminal output.
Observation: Upon examining the documentation for wav_play, it really doesn't explain how the routine executes and how many cogs it uses (presumed 2 cogs). It would be nice to have a little more explanation on how this function operates so as to provide insight into it use in various applications. For example, upon execution how the cogs are assigned, does the function release the cogs or sustain their usage.
Please understand, I am not complaining here. There is a lot of great work coming up with these cool functions to help us all out in getting the prop to jump through hoops.... Kudos! It is just a suggestion to better understand the function.
Any other suggestions/recommendations?
Regards,
Brian (BTL24)
The library has a global FILE *fp and a local FILE *fp which means the wav_stop function is not closing the file.
For the moment, change line 115 of this file: Documents\SimpleIDE\Learn\Simple Libraries\Audio\libwavplayer\wavplayer.c
//FILE* fp = fopen(trackp, "r");
fp = fopen(trackp, "r");
Rebuild libwavplayer for CMM, LMM, XMMC.
It's quite easy to fix though. Just change this section of code to:
Edit: This code is in wavplayer.c.
Thanks for the quick feedback and solution. I cant wait to give it a try.!
Now that I know where to check out the function code, I will better understand its operation.
I am new to Prop C....but learning fast...thanks to guys like you.
Regards,
Brian (BTL24)
No worries... and no inconvenience. It is all a learning process for me as I adopt the propeller as my new processor of choice. The Prop C approach is fantastic and I appreciate the leg work that has gone into this new C language platform. This is why its called Beta... LOL.
I have been a huge fan of Stamps and SX processors and incorporated them into many embedded systems. I have been slow to come off the SX as it is so versatile. I see great things with the 8 cog propeller chip though... great things...especially in my work with stage lighting and DMX busses.
Regards,
Brian (BTL24)
My code is playing the "Yay" wav file over and over again... indefinitely. It is now up to over 200 plays and still going!
Thanks to jazzed and David for all their help. Fantastic!!!
To rebuild libraries, see jazzed post (http://forums.parallax.com/showthread.php/150727-How-Are-Libraries-Compiled-Built-and-or-Updated). He gives a very precise list of instructions how to do it.
(P.S. I have been on travel this last week and just got back to my laptop to run these tests... thus the delay in responding)
Regards,
Brian (BTL24)
Edit: It works for two different methods of calling way_play....1) the one in first post and 2) the one posted here that I am now testing...