Closed copych closed 1 year ago
@copych Awesome, thanks for sharing! I haven't done too much audio DSP on ESP32 since I wrote that blog post (mostly CV stuff). Is this something you're using in an application?
I'm curious if the dual core synchronization adds additional task switching overhead. Are you using 1000Hz for the freeRTOS tick rate? Specifically I'm wondering if one of the cores is taking a lot longer than the other, or otherwise being consumed by other tasks, will this more easily lead to dropouts?
@ndonald2 , I use this methodology in this app: https://github.com/copych/AcidBox this is a combo of two mono synths and one drums sampler, plus a realtime pattern generation/playback, all midi based. I must say that I am not a programmer, so probably I don't know the subject deeply. I haven't measured the overhead, but there must be some loss, and shrinking output buffer size at some stage leads to glitches. Now it's 32 samples at 44100Hz . Yes, I use RTOS defaults, including 1000Hz tickrate AFAIK, and had no issues with it. In ArduinoIDE by default Core1 is running all the user code, but it's configurable. I tried different combinations of arranging activities between cores, and there were cases when tasks execution time differed more than 2x. There were no problem with pausing/resuming/syncing, as task notification works quite as expected, which I can't tell about some unpredictable compiler optimizations, leading to strange results which can't be preseen staring for hours at the simpliest piece of code).
Thanks for your example, here's a slightly advanced version, using multithreading on both of ESP32 cores, giving significantly more power from one CPU. It's for ArduinoIDE, but surely can be easily converted to ESP-IDF code. https://github.com/copych/ESP32-dualcore-i2s/blob/main/ESP32-dualcore-i2s.ino