When I was looking for an alternative open source MP3 decoder, I found the minimp3 project from lieff.

Arduino Support

Yesterday I took another effort to make it work on an Arduino ESP32. To make the project Arduino compatible was easy: I just had to add library.properties and change the Readme.md to add the instructions.

Running the code on the ESP32 however turned out to be not so easy: the sketches were crashing w/o any proper error messages or stack traces. Reviewing the code, I found 2 data structures that were allocated on the stack, that were quite big:

  • mp3dec_scratch_t
  • L12_scale_info

Most of the other data was allocated on the heap as part of the mp3dec_t, so the solution was simple. I just moved these variables from the stack and made it part of mp3dec_t as well and to my surprise all the issues were resolved with this.

The Result

Unfortunately however, the result is disappointing: The decoder is too slow (e.g. on an ESP32) to decode any audio with a rate >= 32000 samples per second and the audio quality is quite poor.

On other platforms this library can use SIMD to improve the performance. Unfortunately neither the ESP32 or the RP2040 can support this. W/o SIMD the library relies heavily on floating point operations – which is a known weak spot of all the Espressif microcontrollers – so any alternative with a decent floating point performance will perform much better .

The Source Code

The adapted Arduino library can be found on github.


Leave a Reply

Avatar placeholder

Your email address will not be published.