← Back to context

Comment by Joeboy

1 day ago

I don't really understand your issue sorry, but my thing basically just writes the audio output to a buffer, and the DMA and PIO "automatically" send that to the I2S output. There's also some messing about with ping ponging between two DMA buffers to avoid gaps between each buffer write audio. I guess things might be quite different on the ESP32.

Edit: Ok I glanced at your code, if I read it right it seems like you're writing sin waves into buffers at "init" time then copying the appropriate buffer at "run" time. Which is not what I'd do, but then I'm used to more luxurious devices. Maybe try using a fast sin approximation rather than the precomputed buffer table?

https://bmtechjournal.wordpress.com/2020/05/27/super-fast-qu... might be helpful there.

Thanks! This was just some playing round years ago, so I don't remember much about it. I don't remember if calculating sin() at runtime was too slow, or I wanted to avoid polyphonic O(n) inside the buffer loop, or what. I bet it uses a LUT anyway.

I much prefer your method of just rotating the phase!