Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 6 months ago.
FRDM-K64F wav player
Anyone have a working wav player example for the FRDM-K64F? I can separately read/write files from the SD card, and generate a tone from the DAC, but haven't yet found a working example that plays .wav files.
1 Answer
8 years, 6 months ago.
While not having done this myself, I would have a look at: https://developer.mbed.org/users/sravet/code/wave_player/
I have tried that one. It doesn't work. It compiles, but when run, it hangs on opening a file - can be a file that exists or does not exist - it doesn't matter.
Here's my example code:
#include "mbed.h" #include "SDFileSystem.h" #include <wave_player.h> #define PC_BAUD 9600 SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); Serial pc(USBTX,USBRX); AnalogOut DACout(DAC0_OUT); wave_player waver(&DACout); int main() { waver.set_verbosity(1); FILE *wave_file; pc.baud(PC_BAUD); printf("\n\r\n\rGoing to open a file...\n\r"); wave_file=fopen("/sd/missing.wav","r"); printf("Opened a file. Will now play.\n\r"); waver.play(wave_file); fclose(wave_file); }
Still you should be able to use it as guideline on how to play a wave file. Bit weird it hangs on opening the file though.
posted by 20 May 2016
Thanks for the update. Reverting to 119 did get me past the fopen, but unfortunately waver.play doesn't play anything and never returns.
posted by Uh Clem 20 May 2016http://developer.mbed.org/users/neilt6/code/SDFileSystem/ and http://developer.mbed.org/users/sravet/code/wave_player/ work, so long as MBED is 119.
posted by Uh Clem 02 Jun 2016