Repository navigation
Conversation
The old fit covered [0, pi/2] only. A filter above sample_rate / 4 used it outside that range, where the error grows to 0.17 by Nyquist, so a low-pass at 22 kHz / 48 kHz was 7 dB down at its own cutoff and a 22 kHz high-pass rejected a 12 kHz tone by only 28 dB. Reflect the angle into [0, pi/2] and then into [0, pi/4] by swapping sine and cosine, and evaluate a four-term minimax polynomial for each. The error is at the last bits of a float over the whole 0..Nyquist range, and a frequency above Nyquist is merely wrong rather than absurd.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First of the three changes from #11269. The old sine/cosine fit only covers 0 to pi/2, so filters above sample_rate/4 ran off its end: at 48 kHz a 22 kHz low-pass was 7 dB down at its cutoff.
This reflects the angle into 0 to pi/4 and uses a four-term minimax polynomial for each of sine and cosine. Worst error up to Nyquist drops from 0.17 to 1.2e-7. A coefficient update takes 9 multiplies and 9 adds (was 10 and 7), and raspberry_pi_pico grows by 32 bytes.
Tested with a new
synthio_biquad_high_frequencytest on the unix coverage build, and on a Pico Plus 2 W and a Feather RP2040, where a 50 Hz low-pass gives sample-identical output to main. I didn't regeneratesynthio_biquad.py.exp: it already differs from main's output on my machine, and this changes it, since it sweeps past Nyquist.Written by an agent, reviewed by a human