circuitpython/ports/raspberrypi/common-hal/audiopwmio
Jeff Epler bef07961ab raspberrypi: audiopwmout: subtle for #5092
I noticed that the loop over 65535 possible denominators took a long time,
causing up to 100ms wait for a sound sample to start playing!

This algorithm, adapted from an algorithm shown in Python's fractions.py,
is guaranteed to find the best denominator in a small number of steps
(I think log2-many steps but I'm not sure). In practice, it means the time
between samples playing is just 10ms, and some of that is recreating the
sine wave sample in Python each time.

It often finds the same solution as the old code, but sometimes it finds
one a bit better since it compares the ratios using float point instead
of integer arithmetic.
2021-08-24 16:33:20 -05:00
..
PWMAudioOut.c raspberrypi: audiopwmout: subtle for #5092 2021-08-24 16:33:20 -05:00
PWMAudioOut.h Fix various RP2040 audio dma things: (see detailed commit message) 2021-07-08 08:14:49 -04:00
__init__.c Add PWM based audio playback 2021-02-09 15:38:33 -08:00