In this waveplayer, the wave file will be keep looping after the waiting time. For the wave file, my format is 11khz 8bit mono. You might need to have a op-amp across the mbed and speaker as the signal will be very small

Dependencies:   mbed wave_player

Committer:
daryl2110
Date:
Tue Nov 22 08:12:12 2011 +0000
Revision:
0:e0d156143789

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
daryl2110 0:e0d156143789 1 #include "mbed.h"
daryl2110 0:e0d156143789 2 #include "wave_player.h"
daryl2110 0:e0d156143789 3
daryl2110 0:e0d156143789 4 LocalFileSystem local("loc");
daryl2110 0:e0d156143789 5 AnalogOut DACout(p18);
daryl2110 0:e0d156143789 6 wave_player waver(&DACout);
daryl2110 0:e0d156143789 7
daryl2110 0:e0d156143789 8 int main() {
daryl2110 0:e0d156143789 9 FILE *fp = fopen("/loc/Hello.wav", "r");
daryl2110 0:e0d156143789 10 while (1)
daryl2110 0:e0d156143789 11 {
daryl2110 0:e0d156143789 12 waver.play(fp);
daryl2110 0:e0d156143789 13 fseek(fp, 0, SEEK_SET); // set file poiter to beginning
daryl2110 0:e0d156143789 14 wait(3.0);
daryl2110 0:e0d156143789 15 printf("File Playing\n");
daryl2110 0:e0d156143789 16 }
daryl2110 0:e0d156143789 17 fclose(fp);
daryl2110 0:e0d156143789 18 }