ESP8266Audio icon indicating copy to clipboard operation
ESP8266Audio copied to clipboard

Playing mp3 files in a function on ESP32

Open HeikkiHietala opened this issue 3 years ago • 3 comments

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?

HeikkiHietala avatar Dec 10 '21 12:12 HeikkiHietala

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

doublejosh avatar Jan 03 '22 00:01 doublejosh

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

doublejosh avatar Jan 03 '22 00:01 doublejosh

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.

HeikkiHietala avatar Jan 12 '22 09:01 HeikkiHietala