Playing 2 wave file continuously

24 Nov 2011

Hey guys, I have a question. I had done a program where it could play a wav. file from SD card. However I was thinking is there any way that i could play 2 file continuously? Hope you guys can help me.

This is my programming.

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

SDFileSystem sd(p5, p6, p7, p8, "sd");

AnalogOut DACout(p18);

wave_player waver(&DACout);

int main() {

mkdir("/sd/wf/", 0777); make the directory to the SD card

0777 is the default mode so to have the widest access

FILE *fp = fopen("/sd/wf/1.wav", "r");

if(fp == NULL){

printf("File couldn't open\n");

}

while (1)

{

waver.play(fp);

fseek(fp, 0, SEEK_SET); set file poiter to beginning

wait(3.0);

printf("File Playing\n");

}

fclose(fp);

}

25 Nov 2011

Open the two wave files into file pointers fp1, fp2 respectively. Call play() sequentially: waver.play(fp1); waver.play(fp2);