Fix sign of b2 in synthio PEAKING_EQ biquad - #11275
Merged
Merged
Conversation
The RBJ cookbook peaking section is b2 = 1 - alpha*A; the + turned a +6 dB bell at 1 kHz into a bass shelf reading +21.4 dB at DC. With the minus the response is unity at DC and Nyquist and hits its gain at the centre frequency, as measured on the unix build. Adds a regression test that checks DC, centre, and 12 kHz gains. Fixes adafruit#11265
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.
Fixes #11265.
common_hal_synthio_biquad_tick()computes the PEAKING_EQ numeratorwith
b2 = 1 + alpha * A; the RBJ cookbook peaking section isThe minus is what makes numerator and denominator sum to the same value
at DC and again at Nyquist — unity everywhere except the band around
f0. With the plus, the numerator picks up2*alpha*Aat DC that thedenominator does not, so the "bell" is actually a bass shelf with a
bell buried in it.
Measured on a unix coverage build of
main, a +6 dB bell at 1 kHz,Q 1, 48 kHz (
audiofilters.Filterfed DC and sineRawSamples):The other six filter modes already match the cookbook and are
untouched. The wrong coefficient reaches both
audiofilters.Filterand
synthio.Note.filter, since they share these coefficients.Includes a regression test (
tests/circuitpython/synthio_biquad_peaking.py)that checks the DC, centre, and 12 kHz gains; it fails on current
mainand passes with the fix. The neighboring biquad/filter teststhat pass on unmodified
mainin the same environment still pass.