9 years, 8 months ago.

AudioCODEC board on the AnimatronicLAB board multi file

Hej All,

I recently started doing some test using the RS Audio Codec libray. The AudioCODEC_HelloWorld program works nicely , https://mbed.org/users/p07gbar/code/AudioCODEC_HelloWorld/ Now I am trying to write my own little code where multiple files are played one after another. But it seem to have a timing issue. here is my little code.

include the mbed library with this snippet

#include "mbed.h"
#include "WavPlayer.h"
#include "MSCFileSystem.h"



MSCFileSystem msc("msc"); // Mount flash drive under the name "msc"
WavPlayer player;
void spela(const char* filename);


int main()
{
    const char* filename= "/msc/test.wav";
    spela(filename);

    filename= "/msc/test2.wav";
    spela(filename);

    filename= "/msc/welcome.wav";
    spela(filename);
    
    filename= "/msc/abc.wav";
    spela(filename);
}


 void spela(const char* filename)
{

    FILE *fp = fopen(filename, "r");  // Open "out.txt" on the local file system for writingfp2 = fopen("/msc/abc.wav", "r");  // Open "out.txt" on the local file system for writing

    player.open(&fp);
    player. play();
    fclose(fp);
}

the first sound is playing well. the second is cut at the beginning and end. the third did not playing at all. Forth also cut. And there is this long delay between each sound.

I am grateful for any guidance i can receive.

best regards Basit Nuri

1 Answer

9 years, 8 months ago.

can you try with these lines of code ?

   spela("/msc/test.wav");
 
    spela("/msc/test2.wav");
 
    spela("/msc/welcome.wav");
    
    spela("/msc/abc.wav");

I don'like lines of code like :

filename = "/msc/test2.wav";

if would prefer :

char *filename[255];

strcpy(filename, "/msc/test2.wav");

Thanx Raph, you are right. it's more correctly written that way. But still no luck with playing the sounds in turn,

posted by Baz Nuri 01 Aug 2014