ESP8266Audio
ESP8266Audio copied to clipboard
Playing mp3 files in a function on ESP32
Hi,
I wanted to thank you for building this library. I am hoping to build a talking clock, with MP3 files for the sounds of "oh one"... "oh nine" and then "one" to "fifty nine". I have the files made already and they all fit under 2MB of SPIFFS memory on the ESP32.
What I am struggling with is trying to build a method for running a function that actually plays the sound. The example has only one sound file, and while I can play my own sound, adding more than one doesn't work.
So, what should the structure be in the loop that would allow for a sound to be played and then wait for the next?
Same problem-- how to manage various audio files and trigger them as part of other code. Seems so basic, but managing the memory and file loading is immediately confusing.
Also, I'm failing to understand how we need to manage mp3->isRunning()), mp3->loop() and mp3->stop() to create a some kind of play() function. It may need take handlers like this, but I'm not sure...
void play(uint8_t message, AudioGeneratorMP3 *mp3, AudioFileSourceID3 *id3, AudioOutputI2SNoDAC *out) {
The only thing like this is the example was the speech synthesis source. The audio quality is horrific, but it's looped. https://github.com/earlephilhower/ESP8266Audio/blob/master/examples/TalkingClockI2S/TalkingClockI2S.ino
This will play an mp3 file by name... https://github.com/doublejosh/AudioPlayground/blob/main/AudioPlayground.ino
There seem to be a lot of click/pop issues though...
- https://github.com/earlephilhower/ESP8266Audio/issues/406
- https://github.com/earlephilhower/ESP8266Audio/issues/476
- https://github.com/earlephilhower/ESP8266Audio/issues/349
- https://github.com/earlephilhower/ESP8266Audio/issues/329
- https://github.com/earlephilhower/ESP8266Audio/issues/246
Thanks for tis :)= sorry for the delay. I have built a case structure that allows me at least to loop through the list o files I have on the ESP32, and I am hoping to get that included in the main structure, but I will surely take a look at your solution.