Playing MP3 from SD card and displaying effect on neopixels

Hello,

How would you go about playing MP3 from SD card, and displaying synchronized colour effects on neopixels? I'm thinking either volume or frequency (FFT) related.

I found this library - schreibfaul1/ESP32-audioI2S - very easy to achieve the first part (play MP3 from SD card), but I'm struggling with the second part; I don't think it allows to tap in to process the samples

I don't think I can write all the code from scratch myself (read from SD, decode MP3 etc), but if you could recommend libraries I could use, I think I would manage to scramble something together.

Best regards

https://www.google.com/search?q=neopixel+audio+visualizer

https://www.google.com/search?q=dfplayer+mini+mp3+library

if possible, I would prefer to skip ADC, since I'm decoding MP3 on the ESP anyway (at least when using schreibfaul1/ESP32-audioI2S library). I did take a look at dfplayer, but I though it might be possible to do all on the ESP

I don't know anything about those libraries but once you've decoded the MP3 you have the audio samples and you should be able to pass them to FFT.

Of course FFT needs to know the sample rate and bit-depth. And if it's stereo the left & right samples will alternate so you'll have to deal with that.

Note that MP3 decoding is processor intensive and so are FFT and NeoPixels and I don't know if the ESP can do it all. The most important thing is that the audio samples come-out "smoothly" without interruption. (On a computer that's done with a buffer and as long as the the buffer doesn't run out of data the audio can flow-out constantly and evenly.)

With a DFplayer (or similar) the processor doesn't have access to the SD card or the digital audio data so you have to feed the analog back-into the ADC.

I'm still tweaking code and I have some weird issues (i.e. file takes a long time to start playing) and still struggling to find perfect parameters for visualization, but I've got promising results with GitHub - earlephilhower/ESP8266Audio: Arduino library to play MOD, WAV, FLAC, MIDI, RTTTL, MP3, and AAC files on I2S DACs or with a software emulated delta-sigma DAC on the ESP8266 and ESP32 and
GitHub - kosme/arduinoFFT: Fast Fourier Transform for Arduino
I need to admit that it's using a very small MP3 file, not sure what is going to be realistic to achieve but for the thing I want it for it might be enough

Look into how music colour units work.

https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://schematicsforfree.com/files/Lights%2520%2526%2520Lighting/Disco%2520and%2520Night%2520Club%2520Lighting/Musicolour%2520Colour%2520Organ-Light%2520Chaser%2520for%2520240V.pdf&ved=2ahUKEwipi4Xx-PqIAxWIXWwGHb2tBL4QFnoECBYQAQ&usg=AOvVaw0CHfFxWYm-LDq8LZDXTYRl

in a similar setup with an ESP32 I use a DFPlayer module as recommended by @kolaha in post 2 and the Adafruit_NeoPixel library (note that if you have more than 85 LEDs this library does not work with ESP32 Arduino Core 3.x and I have to use 2.0.17)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.