Go Down

Topic: How to play 3 tracks one after another asynchronously with tmrpcm library  (Read 670 times) previous topic - next topic

elvenza

Hi all I am new in this Arduino world.
Recently I am working on a project like a simple talking timer. I have already made the timer program which can be controlled by two buttons in the main loop.
Now I want to add the time talking functionality which can be controlled by another two buttons. In order to do so I have added a SD card module with a SD card having 1-9 hours, 1-59 minutes and 1-59 seconds audio wav files (8 bit, 16000 HZ pcm 8 bit unsigned) as specified.
I have used Tmrpcm library to play those audio files but the problem is I can't make those files play one after another. For example on button push play hour wav file then minute wav file and then seconds wav file  one after another.
I can't just use three simple play function one after another because then it just plays only the last file or it executes the last play command.
I tried with delay function between those play functions to give enough time to play first hour wav file then minute wav file and then seconds wav file but as we know it delays the whole main loop function which also delays the main timer so can't use delay function to give enough time for those audio file to play one after another.
I also tried millis() function but I stuck with it because it has to deal with a while loops in the main loop section ...
So I decided to modify the library so that I can play three wav files one after another asynchronously. But after hours of checkup I found that Tmrpcm library uses the following code to play audio file

void TMRpcm::play(char* filename){
   play(filename,0);
}
but I hardly found any function definition of the play(filenane,0);
So I am puzzled here how to solve this problem.
I need to play three wav file to play one after another asynchronously withouth hampering the main loop to speak hour minute and second with SD card module and tmrpcm library or with any other library or any other method.
Any idea / help / suggestion is much appreciated...
Thanks in advance.

Go Up