Repository navigation
synthio.Biquad: take CircuitPython main's widened biquad - #353
Merged
Merged
Conversation
A low shelf or low-frequency filter no longer settles at a DC offset in silence. synthio.Biquad, audiofilters.Filter, Note.filter and the LPG node now run upstream's arithmetic at ae47a3f15d (adafruit/circuitpython#11679): the reflected fast_sincos (24546b7d1d), per-filter coefficient shifts and 12-bit-fraction state (0a7df85004). The Python filter chain also gets PEAKING_EQ's b2 sign right. No CircuitPython release carries this yet, so the oracle is skipped for three verify_dsp probes and biquad_component and synthtools_acceptance are re-captured from this port; upstream-sync.md says what to undo when the pin moves.
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 #310. A biquad on a low shelf or a low-frequency filter no longer settles at a DC offset in silence.
synthio.Biquad, and soaudiofilters.Filter,Note.filter,Echo.filter, freeverb's filter and the graph's LPG node, now run CircuitPython main's arithmetic at ae47a3f15d (adafruit/circuitpython#11679, which also carried #11678):fast_sincosreflects the angle into the first quadrant first.Both are taken in upstream's words. The Python filter chain behind
Echo.filterand freeverb on CPython also had PEAKING_EQ'sb2sign the wrong way round, and that's fixed too.What it does
#310's repro is a 200 Hz
LOW_SHELFat A=1.0, quiet noise then silence, throughaudiofilters.Filterat 36 kHz. Here is the offset over the last 2000 silent samples:Upstream's four biquad tests (
synthio_biquad_dc_offset,_low_frequency,_high_frequency,_peaking) now print upstream's expected output on both builds. They failed before.A harness built from upstream's own
Biquad.cat ae47a3f15d agrees with this port on 20,000 random filters across all seven modes and rates from 8 to 48 kHz. That is 40,960,000 samples with no difference. The previous kernel fails the harness.Gates
verify_dspwith MicroPython and CPython: 62 comparisons, 0 failures.verify_graphwith MicroPython and CPython: all four probes agree to 0 counts. A plantedlpgfault fails it.verify_effects,verify_streamingandverify_mixdown_kneepass unchanged.What moved, and why
No CircuitPython release has #11679 yet, so the 11.0.0-alpha.2 oracle now disagrees wherever a
synthio.Biquadis heard.verify_dsporacle skips.echo_filter_probeandfreeverb_filter_probematched the oracle byte for byte before this change, and they now skip the CircuitPython comparison. The note onbiquad_component_probeis updated to match. MicroPython and CPython are still compared.biquad_componentgolden. It was re-captured because the filter output changed: d9950b16… became ba714db8….synthtools_acceptancegolden. Itsstdoutwas re-captured.lead,bendandbassrun a resonant low-pass and moved, and the other five lines are unchanged.circuitpython_stdoutstill holds alpha.2's answer, and its note now says why the two differ.test_cpython_audiograph_nodesOverdrive comparison. The reference now getstoneas float32, the way the node holds it. With 30-bit coefficients, a tone that isn't float32 moves the output by one count.test_cpython_audiobiquadfixed-point test. It now pins the new numbers. A DC burst into a low-pass settles at exactly 0 at 400 Hz and 1000 Hz. At 100 Hz and 40 Hz it settles 1 and 4 counts away, where Q15 used to hold 2631 and 16143.Float-precision CI bounds. The single-precision MicroPython cell already allowed
biquad_component_probeandecho_filter_probeto differ from CPython on 4 lines each, becausesynthio.Biquadderives W0 inmp_float_t(synthio.Biquad derives W0 in mp_float_t while the CPython extension uses the shared double helper, so a single-precision target runs a different filter #101). The 30-bit coefficients now carry more of that float rounding than Q15 did, and CI measured 35 and 6 lines. The bounds are set to those numbers, so the gate still fails if either one grows.When the oracle pin moves to a release that has #11679, drop the three skips and re-capture both goldens from the oracle. upstream-sync.md has the details.
Held for the next resync
These upstream changes landed between alpha.2 and ae47a3f15d and are not taken here:
synthio.MidiTrackcommits 679e9700ab, ff05e5b620, aad79fe5eb, 6dfa7e5f20 and a54b951de6audiotapmodule (e9b2fd49f5, f889146e81)Downstream digests that run a
synthio.Biquad, or the graph's OVERDRIVE with a knob that isn't float32, will move when they pick this up.