Clock Radio
Sine Wave Glitches
So I've been struggling with this I2S thing for a bit. It just isn't working properly. It seems like it's almost working but not quite. I can see something that looks like a sine wave but it's all glitchy.
And if you squint at it long enough you realize those glitches aren't overlaying the wave, they're interrupting the wave.
It's old buffer data.
So I finally bench the signal generation. I'm just doing a fully naive sin(t) with full double precision. And for a 256 sample buffer, it takes about 9ms to generate 256 samples.
256 samples at 44.1KHz is 5.8ms.
Then it hits me. The ESP32-C3 is a RV32IMC. This has no floating point anything. You can't do double precision floats on a 160MHz system without floating point hardware! That's insane!
It wasn't working because an ESP32-C3 literally can't generate double precision sine waves at 44.1KHz in real time.
I can't even reliably do it in single precision. :)
This does not bode well for decoding MP3s. I might have to use the full ESP32 just for the horsepower.
But at least what you can do for the sine wave is cheat by precomputing it. :)