7 years, 11 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.

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 2016

1 Answer

7 years, 11 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); 
}
posted by Uh Clem 19 May 2016

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 Erik - 20 May 2016

Erik,

mbed library v120 breaks a few things on the K64F, SPI being one of them. There are a few threads on this topic already, as well as a github request to look into this. Try using mbed v119.

...kevin

posted by Kevin Braun 20 May 2016

Uh Clem you mean ;).

posted by Erik - 20 May 2016