ESP32-audioI2S icon indicating copy to clipboard operation
ESP32-audioI2S copied to clipboard

sending samples 1 by 1 consumes lots of cpu and smaller bugs - improvement included

Open shbgr opened this issue 1 year ago • 12 comments

Hi. I did some experiments with the lib. Works great, but i was wondering about only sending chunks of 4 bytes only to the i2s-driver. My C-experiences are cumbersome and the same with GIT. But managed to get CPU-load down by a factor of 2 by sending 16 i2s-frames instead of the the current single frame in the lib. This is likely due to several checks and creating a semaphore in IDF-lib for each call to i2s_write.

My results on Core 1 for a 320kbit MP3, stereo, 48k sample rate, SD connected with SPI:

  • single frame send: 65% load (lib 3.0.8)
  • 16 frame send: 32% load

I have attached my modified lib (based on 3.0.8). Seems to run fine, but memory leaks and other codecs than mp3 were off my scope. So better double check. See also some notes incorporated on filters that might get wrong and playSample for 8-bit files. And i added an additional attenuation. Not relevant for the lib.

Maybe this helps for further improvement. Audiosh.zip

shbgr avatar May 29 '24 11:05 shbgr