32blit-sdk icon indicating copy to clipboard operation
32blit-sdk copied to clipboard

Buffer audio instead of firing an interrupt at 22,050Hz

Open Gadgetoid opened this issue 4 years ago • 4 comments

As brought up by @zenodante in #562 - firing an audio callback at 22kHz will ransack the instruction cache among other things. We should be feeding a ~441 sample buffer at ~50Hz instead.

Gadgetoid avatar Jan 25 '21 11:01 Gadgetoid

Checking if the DAC should be enabled every sample probably isn't great either... https://github.com/pimoroni/32blit-beta/blob/master/32blit-stm32/Src/sound.cpp#L22

Daft-Freak avatar Jan 25 '21 11:01 Daft-Freak

I did some sleuthing for the old audio code that used DMA and a buffer, and recalled that I never did manage to get it working. The system would just lock up solid and I had to abandon all hope in favour of... this travesty. So... yep. Long overdue a fix.

Gadgetoid avatar Jan 26 '21 21:01 Gadgetoid

I will work on it, after I receive the hardware. Current my h750-dk boards don't have a DAC audio setup. (Q_Q)/

zenodante avatar Jan 27 '21 00:01 zenodante

I ended up figuring this out (eventually): https://github.com/Daft-Freak/32blit-beta/commit/9b8d4a268d107b3d35ba43957482833acba02414 (Very lightly tested)

Mostly because I suspected that this was why audio was weird in my new DOOM port...

Daft-Freak avatar Jan 17 '25 16:01 Daft-Freak