Unable to play wav file through Wave_player

17 Nov 2011

Hello guys,

I am encountering a problem here,I had imported the program wave_player to my compiler but when I send to mbed trying to play the wav file,I couldn't play the audio, can anyone help me?

This is my programming

  1. include "mbed.h"
  1. include "wave_player.h"

AnalogOut DACout(p18);

wave_player waver(&DACout);

int main() { FILE *wave_file;

printf("\n\n\nHello, wave world!\n");

wave_file=fopen("/local/Hello.wav","r");

waver.play(wave_file);

fclose(wave_file);

}

And this is my connection, just for your info, i connect to p18

/media/uploads/daryl2110/13114840.gif

Hope you guys can help me

17 Nov 2011

This might help:

LocalFileSystem local("local"); Create the local filesystem under the name "local"

I'm not sure, try it out.

Btw: Maybe a capacitor between the speaker and the 470 ohm resistor, to fitler out DC is good.

18 Nov 2011

I tried include LocalFileSystem local("local"); to my program, it still doesn't work.

I tried to debug the program and i notice that the program stop at waver.play(wave_file); and it doesn't continue. I not too sure isit something wrong with it?

18 Nov 2011

When I get home from work, I will try it out, haven't got mbed right here. I'll report success or failure.

18 Nov 2011

Just tried it, didn't work with mine either. Tried different setups, only speaker, speaker with capacitor, speaker with resistor and capacitor.

Will investigate.

18 Nov 2011

Perhaps the wave_player doesn't work with local memory? Maybe a SD-card is really needed. Will try to setup SD-card on embedded artists base board.

18 Nov 2011

It works, try using a amplifier stage of some sort. Volume is very low, but I moved the speaker to my ear, and heard CHARGE :-)

18 Nov 2011

Oh I see, can i see ur connection for the mbed to speaker? anyway what is the format for wave file? my format is 22khz 16bit mono, just wondering could it be that my format of the file is wrong?

18 Nov 2011

It's just like yours, except the 100nF capacitor for GND, and mine also has a DC blocking cap between the speaker and resistor.

My file: 11 kHz, 8bit mono. Had to try one, googled "small wave files" the first link pointed to some files. The sound isn't perfect, but maybe higher sampling freq will be better.

I'll add a op-amp to the circuit, to amplify the signal.

22 Nov 2011

hey thanks a lot! i had solve it! ya i need an amplifier to amplify the signal, if not it will be too soft

22 Nov 2011

Btw, the LocalFileSystem, can't handle wave-files very good. Transfer of bytes takes too long, I tried with a SD card, and it worked perfect, until 44.1kHz, so 22.05 kHz works great!

22 Nov 2011

oh I see, Yah I had rewrote my program and it work perfectly well, although the quality of the audio is not that good, but it can be heard. Tomorrow I will try using an SD card, hope that it will work well! anyway really thank you for ur help! appreciate a lot (:

22 Nov 2011

oh I see, Yah I had rewrote my program and it work perfectly well, although the quality of the audio is not that good, but it can be heard. Tomorrow I will try using an SD card, hope that it will work well! anyway really thank you for ur help! appreciate a lot (: