I have built a Bluetooth speaker using an ESP32. It can stream BLE audio and play MP3/WAV from an embedded SD card. I want to record 44.1Khz res audio from it but unfortunately the ESP32 is not powerful enough to convert WAV to MP3 in real time. I am looking for an additional component (MCu/DSP IC) which can convert wav from ESP32 to MP3 in real time.It should be able to record 5 mins max and store them as MP3 on an embedded SD card. I am not very experienced with DSP so kindly help me out.
1 Answer
yeah, any 32 bit microcontroller that you can buy these days should be able to do that, given enough RAM.
The more capable ESP32 should be more than capable enough: They're dual-core machines that benchmark in the millions of integer operations per second, and that's way more than you need.
So, this mainly boils down to the question on what you did to determine that your MCU wasn't powerful enough – maybe you just need to use a better encoder. But maybe the problem is really that the processing gets interrupted to handle bluetooth every couple of microseconds. I don't know which is the case – but unless you have actually profiled that, I wouldn't believe your chip is too slow, especially since there are actually (at least) two cores, one being a specific Bluetooth protocol handler, inside that family of chips.
Anyways, if it is too slow, then you'd want to connect an external second microcontroller and send the uncompressed data to, using a wide-as-possible data bus and DMA. Sadly, I think the only external communication interface with DMA that comes into question and that any ESP32 supports ("ESP32" is a whole group of pretty different processors!) is SPI, so this might be very hard.
Also, a friendly reminder: MP3 is technologically 33 years old. There's better codecs, and they aren't necessarily much harder to compute. And whatever you read that card with will support other things than MP3 (like AAC-LC in mp4, whose patents also already lapsed), as well. For example, if you choose to use an STM32 with a cortex-M4F (or bigger) as secondary processor for encoding purposes, st has a proven OPUS encoder, and OPUS is an IETF (i.e., the internet engineers) standard. The reference OPUS encoder can be compiled on basically anything, including the Xtensa or RISC-V architecture that your ESP32 is using; I don't think it relies on any libc functionality, and it has an "integer math only" mode, if you choose a microcontroller without a capable FPU (why would you?).
-
$\begingroup$ Thank you for the answer. I looked at the Lyra T mini audio development board by espressif. They use a ESP32 wrover which comes with 8 MB PSRAM. Also I would be using a 24 bit codec for microphone and wav to mp3 conversion. $\endgroup$ Commented Feb 19 at 4:06