Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precalculate common PWMAudio dividers, avoid noise #2714

Merged
merged 1 commit into from
Dec 22, 2024
Merged

Conversation

earlephilhower
Copy link
Owner

Calculating the DMA clock divider for PWMAudio can take a very long time because there are 65K floating point divisions required. But most audio will be one of a dozen sample rates, so it is possible to precalculate the rates on the host and use a small lookup table to avoid any math at all. Removes occasional scratching in PWMAudio when the BackgroundAudio library changes sample rates.

Related to earlephilhower/BackgroundAudio#3

Calculating the DMA clock divider for PWMAudio can take a very long time
because there are 65K floating point divisions required.  But most audio
will be one of a dozen sample rates, so it is possible to precalculate
the rates on the host and use a small lookup table to avoid any math at
all.  Removes occasional scratching in PWMAudio when the BackgroundAudio
library changes sample rates.
@earlephilhower earlephilhower merged commit d732ac8 into master Dec 22, 2024
26 checks passed
@earlephilhower earlephilhower deleted the silencio branch December 22, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant