Repository navigation
rational: the guard band filter in both forms and the composition tests (IIR-c) - #114
Merged
Merged
Conversation
The guard band filter of docs/IIR_PLAN.md I7, with the maintainer's order rule (question 14) and the floating limit cycle kept as an honest limit (question 19): - guard_band.h: guard_band_filter<S, Ch, P> over guard_band_filter_base<S, P> (K12), a 1:1 stage beside the ratios (ratio<L, M>'s charter unchanged). P is a guard_phase: nonlinear, the odd-order Chebyshev II over DspTap's biquad_cascade, its latency nominal (I5); linear, the even-length symmetric (type II) FIR over dot_row, its latency exact, (N - 1) / 2 frames. guard_band_settings::super_economy() ... transparent() are the profiles' numbers at the orders 5 / 7 / 7 / 7: the named Chebyshev II designs compile-time (k_guard_band_cheby2), the linear form DspTap's committed rows (k_guard_band_fir, copied at compile time so an image holds only those four); a custom setting designs at construction (design_cheby2_lowpass and cheby2_linf_gains; design_guard_band_linear at the length search_guard_band_linear_length finds, validate() refusing a setting no length up to 512 taps meets). Every format, the FIR's taps quantized by halves and mirrored so they stay symmetric bit for bit. The family's call shapes, process / pull / flush out of line against a cursor (A12), window_frames() as I6 states it. - The golden leg: tools/reference/make_guard_band_reference_vectors.py writes tests/reference/guard_band_reference_vectors.h, the Chebyshev II as scipy's own cheby2 design through sosfilt (checked against DspTap's transfer function within 1e-14) and the FIR's taps through lfilter. - tests/test_guard_band.cpp (typed over float / double / Q15 / Q31): the golden leg and the bit pins, the spec per form, the order rule recomputed behind each half-band kind, the machine, validate(), latency, flush and the limit cycle's bound, fixed point, the aliases a decimating chain leaves; tests/support/iir_signals.h, the signals it shares with the composition tests; test_iir_subnormals.cpp's no-flush residue for the Chebyshev II and the FIR's exact silence. - tap_sr_rational_guard_band_tests, an executable of its own: with these tests in the main battery its Hexagon image passes the +-8 MiB reach of a direct call (lld's R_HEX_B22_PCREL out of range) and its M55 image the 2 MiB CODE region. bare_metal_main.cpp's third mode runs it on the Arm legs, leaving out the four host measurements. - The rational header count is 9. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…uard band stages (IIR-c, I10) docs/IIR_PLAN.md I10 as the maintainer decided it (question 16's part): the recursive stages and both guard band forms satisfy tap::dsp::sync_stage, and a mixed chain is the caller's tap::dsp::chain, never a named chain or a coverage-matrix row. tests/test_iir_composition.cpp, in tap_sr_rational_guard_band_tests: the concepts (the linear form an exact stage, the Chebyshev II a nominal one, a near-linear stage with the linear form an exact_delay_stage for the round-trip scaffold); mixed chains (an IIR up2 and an FIR up3 behind the filter, FIR down3 and IIR down2 before it, the filter before the FIR and near-linear interpolators and after the FIR decimator, after iir_down_by<..., 8> and down_by8) bit-identical for any chunking in every format, and flushing as zero padding, bit for bit but for the honest limit where a floating stage that holds the zero-input limit cycle is followed by others; the linear form keeping an all-FIR chain's exact latency and the nominal composing over a chain with the Chebyshev II, both against the impulse response; and the offering table pinned cell by cell. compile_fail/guard_band_exact_latency.cpp: a chain holding the Chebyshev II has no exact latency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…urements (IIR-c) guard_band.EachFormMeetsItsSpec (eight impulse responses through 2049-point DTFTs in double), guard_band.AnUnmeetableLinearSettingIsRefused and guard_band.CustomSettingsMeetTheirSpec (DspTap's Kaiser length search, 15 s and 0.5 s on x86-64) and guard_band.EveryValidDesignFitsTheFixedPointFormats (294 run-time Chebyshev II designs) run in soft double on Hexagon; the Arm legs' one-shot filter names the same four (bare_metal_main.cpp). Every other guard band and composition test runs there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…he roadmap and the book (IIR-c) - docs/IIR_PLAN.md v11: the maintainer's decisions for IIR-c (question 14, the orders 5 / 7 / 7 / 7; question 16's part, I10 as recommended; question 19, the floating limit cycle an honest limit), IIR-c in review with its measured numbers (section 5 item 4), and its two findings put to the maintainer as questions 20 (the order rule is the nonlinear half-band's) and 21 (the linear form in Q15 misses the 70 dB tier). - rational/PLAN.md: the charter's note that a 1:1 guard band stage is admitted beside the ratios (section 1), R26-R28, R24's question 19 decided, the layout, the v0.22 row and the IIR-c record in section 6. - rational/CLAUDE.md and the root CLAUDE.md: the charter constraints and the engine's description; PLAN.md section 2's "not engines" line. - README.md: rational's row and the profile section; rational/README.md: the guard band filter, its numbers, the offering table (I10) and its honest limits, and question 19 decided in the recursive stages' limits. - docs/ROADMAP.md: IIR-b landed, IIR-c in review. - book: Part VII's chapter on guard_band.h, and the recursive stages' chapter with question 19 decided. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
Hosted GCC 13 and Clang 18 with -Werror, both builds, Debug; clang-tidy, clang-format, the vocabulary gate and the book; the M33, M55 and Hexagon batteries in both builds; every rational workload, probe and stack binary byte-identical to the parent commit's on the M33, M55, Hexagon and host in both builds, every baseline gate and ceiling passing, none re-recorded. MSVC and AppleClang not run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
…bound scoped to what was measured (IIR-c) The settings table in guard_band.h's header had been reflowed past the column limit into broken rows; it is narrowed to fit. The test names that the comments cite are kept whole on one line, so a grep finds them. The limit cycle's bound of 16 times the smallest normal is stated for order 7, the order it was measured at; a custom order of 9 or more is not measured here, and DspTap's survey (iir_kernels.h) is cited for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
CI's Linux GCC job (GCC 15) failed on test_guard_band.cpp: the run() helper's out.resize(), inlined into alias_level(), put resize()'s growing branch in view, and -Warray-bounds reported a write past the 4096-sample buffer, a branch that never runs since process() returns outputs_for(). The helper now trims with erase(), which never grows. GCC 15.3 also failed internally (mark_use) on the order rule's lambda, which captured references to the half-band designs; the lambda names them instead. CI's GCC 15 does not reach that failure; 15.3 does, so the change keeps the next runner image building. Reproduced in the gcc:15 image (15.3.0): nine array-bounds errors with the old helper, none with the new one; the tree builds there with -Werror on all three engines and the C ABIs, 507 of 507 tests passing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
tap
pushed a commit
that referenced
this pull request
Nov 22, 2026
… follow-up) Question 20 of docs/IIR_PLAN.md, which IIR-c (#114) put to the maintainer, decided after it landed: "The settings can be different for the fir and near linear chains than the nonlinear chains." guard_band.h gains half_band_kind (fir, nonlinear, near_linear) beside guard_phase, and every named setting takes it with no default. I7's rule (question 14) is applied behind the half-band the filter serves: 5 / 7 / 7 / 7 behind the nonlinear half-band, 7 / 7 / 7 / 11 behind the FIR and near-linear ones. economy and balanced are one design behind every kind and take the kind all the same; guard_band_settings{} stays economy's and the constructor's and validate()'s default. Six designs per form, the two new ones (70 dB 1/3 at order 7, 120 dB 5/12 at order 11) already DspTap's committed Chebyshev II and type II FIR rows, so DspTap does not change; any other setting designs at run time as before. Every test over the named settings runs the six designs: the golden vectors regenerated (12 cases; the generator's sosfilt against direct-form check loosened to 1e-8, the order-11 polynomials agreeing within 1.7e-9), the four bit pins re-recorded as the cases they hash grew, the spec, fixed point, limit cycle and quantized linear stopbands; the order rule pins every kind's pick against its named setting; the aliases, composition and offering tests build each chain's filter at its own kind, and the offering table's near-linear rows with a filter move (down 2 at super_economy 25 and 43 multiplies, at transparent 49 and 121). The floating limit cycle at the new orders, over 20 starts per design: 4.4 (float) and 3.0 (double) times the smallest normal at super_economy's order 7, 8.4 and 7.7 at transparent's order 11, inside the bound of 16, which stays. Without flush-to-zero the residue reaches 11 times the smallest subnormal (bound 32). The Q15 linear limit is unchanged in kind and stays pinned (question 21: DspTap's Q15 rows, a later pin bump): -68.9 and -69.2 dB for the new rows. The header's settings table gains a half-band column, and README.md, rational/README.md, rational/CLAUDE.md and the book's guard band chapter state the settings per kind with the new windows, latencies and multiplies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
tap
pushed a commit
that referenced
this pull request
Nov 22, 2026
docs/IIR_PLAN.md v12 records the maintainer's answers to the two questions IIR-c (#114) put to him, given after it landed, and the follow-up that implements them: - question 20, the guard band settings behind the near-linear and the FIR half-band, decided per kind: "The settings can be different for the fir and near linear chains than the nonlinear chains." 5 / 7 / 7 / 7 behind the nonlinear half-band, 7 / 7 / 7 / 11 behind the FIR and near-linear ones, through half_band_kind (I6, I7, section 5 item 4, section 8); - question 21, the linear form in Q15, decided as "DspTap Q15 rows": DspTap commits Q15 linear rows designed with margin in a PR of its own; rational keeps the Q15 limit pinned as it is until the pin bump that brings them. v11's record of IIR-c stays as it was; IIR-c is marked landed. rational/PLAN.md: R26 and R28 state the settings per kind and the limit cycle at the new orders; v0.23 and section 6's record of IIR-c's follow-up carry its measurements and verification (488 of 488 hosted with GCC 13, Clang 18 and without exceptions, 507 of 507 with GCC 15; the M33, M55 and Hexagon legs in both builds; every rational ratchet binary byte-identical to IIR-c's, no baseline or ceiling re-recorded). docs/ROADMAP.md marks IIR-c landed and adds its follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
tap
pushed a commit
that referenced
this pull request
Nov 22, 2026
… follow-up) Question 20 of docs/IIR_PLAN.md, which IIR-c (#114) put to the maintainer, decided after it landed: "The settings can be different for the fir and near linear chains than the nonlinear chains." guard_band.h gains half_band_kind (fir, nonlinear, near_linear) beside guard_phase, and every named setting takes it with no default. I7's rule (question 14) is applied behind the half-band the filter serves: 5 / 7 / 7 / 7 behind the nonlinear half-band, 7 / 7 / 7 / 11 behind the FIR and near-linear ones. economy and balanced are one design behind every kind and take the kind all the same; guard_band_settings{} stays economy's and the constructor's and validate()'s default. Six designs per form, the two new ones (70 dB 1/3 at order 7, 120 dB 5/12 at order 11) already DspTap's committed Chebyshev II and type II FIR rows, so DspTap does not change; any other setting designs at run time as before. Every test over the named settings runs the six designs: the golden vectors regenerated (12 cases; the generator's sosfilt against direct-form check loosened to 1e-8, the order-11 polynomials agreeing within 1.7e-9), the four bit pins re-recorded as the cases they hash grew, the spec, fixed point, limit cycle and quantized linear stopbands; the order rule pins every kind's pick against its named setting; the aliases, composition and offering tests build each chain's filter at its own kind, and the offering table's near-linear rows with a filter move (down 2 at super_economy 25 and 43 multiplies, at transparent 49 and 121). The floating limit cycle at the new orders, over 20 starts per design: 4.4 (float) and 3.0 (double) times the smallest normal at super_economy's order 7, 8.4 and 7.7 at transparent's order 11, inside the bound of 16, which stays. Without flush-to-zero the residue reaches 11 times the smallest subnormal (bound 32). The Q15 linear limit is unchanged in kind and stays pinned (question 21: DspTap's Q15 rows, a later pin bump): -68.9 and -69.2 dB for the new rows. The header's settings table gains a half-band column, and README.md, rational/README.md, rational/CLAUDE.md and the book's guard band chapter state the settings per kind with the new windows, latencies and multiplies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
tap
pushed a commit
that referenced
this pull request
Nov 22, 2026
docs/IIR_PLAN.md v12 records the maintainer's answers to the two questions IIR-c (#114) put to him, given after it landed, and the follow-up that implements them: - question 20, the guard band settings behind the near-linear and the FIR half-band, decided per kind: "The settings can be different for the fir and near linear chains than the nonlinear chains." 5 / 7 / 7 / 7 behind the nonlinear half-band, 7 / 7 / 7 / 11 behind the FIR and near-linear ones, through half_band_kind (I6, I7, section 5 item 4, section 8); - question 21, the linear form in Q15, decided as "DspTap Q15 rows": DspTap commits Q15 linear rows designed with margin in a PR of its own; rational keeps the Q15 limit pinned as it is until the pin bump that brings them. v11's record of IIR-c stays as it was; IIR-c is marked landed. rational/PLAN.md: R26 and R28 state the settings per kind and the limit cycle at the new orders; v0.23 and section 6's record of IIR-c's follow-up carry its measurements and verification (488 of 488 hosted with GCC 13, Clang 18 and without exceptions, 507 of 507 with GCC 15; the M33, M55 and Hexagon legs in both builds; every rational ratchet binary byte-identical to IIR-c's, no baseline or ceiling re-recorded). docs/ROADMAP.md marks IIR-c landed and adds its follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
tap
pushed a commit
that referenced
this pull request
Nov 23, 2026
… pair TAP_SR_VERSION_* 0.9.0 in the three umbrella headers (async.h, ratio.h, rational.h) and the root project(), token-identical (family.VersionMacrosAgree, re-pinned in tests/family/version_macros.cpp), and each engine's C ABI version probe pinned at 0x000900 (CApi.VersionIsBitPacked, with Ratio.VersionIsTheFamilys). The release of rational's recursive stages and guard band filter (the IIR plan: IIR-b, IIR-c #114, its follow-up #115, the DspTap 0.4.0 pin #116 and IIR-d), as the maintainer decided for IIR-d's PR (docs/IIR_PLAN.md v14). CHANGELOG.md gains the 0.9.0 entry: what breaks (DspTap 0.4.0 is the floor) and what is new. The root README's tested-pairs row for 0.9.0 (DspTap floor 0.4.0, pinned v0.4.0) is a release's now, and its rational row names the C ABI's new entry points; the root CLAUDE.md's version lines say 0.9.0, with the release in its history sentence. No ratchet binary changes with the version. The maintainer tags v0.9.0 after the merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
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.
What this changes
IIR-c of
docs/IIR_PLAN.md:rationalgains the guard band filter, a 1:1 stage that a caller places in atap::dsp::chainafter a decimator or before an interpolator, FIR or recursive (I7, R26). This PR also adds the composition tests for mixed chains (I10, R27). The FIR stages, chains, matrix and C ABI are unchanged, and so are IIR-b's recursive stages.guard_band.h:guard_band_filter<S, Ch, P>overguard_band_filter_base<S, P>(K12). P is aguard_phase:nonlinear: the odd-order Chebyshev II, run by DspTap'sbiquad_cascade. Its latency is nominal (nominal_latency_output_frames,latency_deviation_output_frames,group_delay_output_frames(f)), and a chain holding it has no exact latency (a new compile-fail case).linear: the even-length symmetric (type II) FIR, run bydot_row. Its latency is exact,latency_output_frames()= (N − 1)/2, so an all-FIR chain holding it keeps R7's exact latency.guard_band_settings{passband_frac, stopband_atten_db, order}. The named settingssuper_economy()…transparent()use the profiles' numbers at orders 5 / 7 / 7 / 7 (question 14). Both forms reach A from the Chebyshev II's stop edge (stop_edge()). The named settings are compile-time or committed DspTap designs (k_guard_band_cheby2,k_guard_band_fir); any other setting is designed at construction.process,pull,flush,reset,validate,outputs_for,frames_needed,window_frames,flush_output_frames,channels()).process,pullandflushare out of line, each against a cursor (A12).ratio<L, M>'sstatic_assertis unchanged. Recorded inPLAN.mdsection 2,rational/PLAN.mdsection 1,rational/CLAUDE.mdand the root README.tools/reference/make_guard_band_reference_vectors.py, scipy's owncheby2design throughsosfilt(checked against DspTap's transfer function to 1e-14) and the committed FIR taps throughlfilter;tests/test_guard_band.cppand the composition teststests/test_iir_composition.cpp, built as an executable of their own,tap_sr_rational_guard_band_tests(see the notes);tests/test_iir_subnormals.cpp;book/src/part7/guard-band.md; the offering table inrational/README.mdand the book;rational/PLAN.mdR26–R28 and its verification record; the roadmap; anddocs/IIR_PLAN.mdv11, which records your decisions on questions 14, 16 (I10) and 19 and opens questions 20 and 21.TAP_SR_VERSIONstays 0.8.0 and the DspTap pin stays atv0.3.0. I11 (the C ABI, notebooks, ratchet workloads) and 0.9.0 are IIR-d's.Why
This is the IIR plan's third step (section 5, item 4). Every half-band crosses over at the low rate's Nyquist: −3 dB there for the recursive half-band, −6 dB for the FIR one. Its transition band therefore folds onto the guard band (f_pass, r/2) going down, and images into it going up. The passband is alias-free with or without this filter; the filter removes the guard band as a whole. Its zero at Nyquist is exact in both forms and every format.
Verification
Each number is measured by the named test (asserted there against its bound or stated tolerance):
guard_band_test.MatchesTheGoldenLegguard_band_fixed_test.OutputsAreBitPinnedguard_band.EachFormMeetsItsSpecTheZeroAtNyquistIsExactInEveryFormat,TheLinearFormIsSymmetricBitForBitguard_band.OrderIsTheLowestOddOrderWhoseGuardBandAliasIsAtHalfAeconomy, 68 before the FIR ↑2)NominalLatencyAndGroupDelayMatchTheImpulseResponse,GroupDelayMatchesTheGoldenLeg,TheLinearLatencyIsExact,iir_composition.TheLinearFormKeepsAnAllFirChainsExactLatencyFullScaleDriveNeverWrapsInside,Q15FloorsAgainstDouble,FixedPointSilenceIsExactlyZeroAfterTheWindow,EveryValidDesignFitsTheFixedPointFormatsguard_band_float_test.TheChebyshevLimitCycleIsBoundediir_subnormals.WithoutFlushToZeroTheGuardBandResidueIsBoundedtransparent); past the stop edge ≤ −75.1 dB (−126.9) with either form, against −3.4 to −6.6 dB with no filterguard_band.AliasesLandOnlyAboveThePassbandEdgeiir_down_by<…, 8>anddown_by8: bit-identical for any chunking in all four formats. Flush equals zero padding bit for bit, except downstream of a cycling floating stage (within 64× the smallest normal)iir_composition_test.MixedChainsAreBitIdenticalForAnyChunking,FlushEqualsZeroPaddingBitForBitInMixedChainsiir_composition.TheOfferingTableIsMeasuredWhere it ran:
-Werroron all three engines, 488 of 488 (my rebuild of the pushed head, 289 of themrational). GCC 15.3 (thegcc:15image) with-Werroron all three engines and the C ABIs, 507 of 507, after 4a1ee13's fix for the first push's Linux GCC failure (-Warray-boundson the test helper'sresize()). The agent that built it also ran Clang 18 with-Werror, GCC without exceptions or RTTI, and a Debug build of rational's battery (291 of 291, both precondition death tests), all passing.ci.yml's exclusions.k_guard_band_fir<…>.taps.size().Notes for the reviewer
docs/IIR_PLAN.mdv11. Both are pinned as stated limits here.super_economy(target −35) and −48.8 / −45.6 dB attransparent(target −60).economyandbalancedmeet −A/2 behind every half-band. The passband and the band past the stop edge keep their contracts everywhere. The choices:transparentat 30 multiplies and 102 taps);guard_band_fixed_test.QuantizedLinearTablesAttainTheirStatedStopbands). The choices:R_HEX_B22_PCRELout of range, past a direct call's ±8 MiB). The M55 image would also pass its 2 MiB CODE region: the main battery's is already 2,042,664 bytes. Sotest_guard_band.cppandtest_iir_composition.cppbuild astap_sr_rational_guard_band_tests, andbare_metal_main.cppgains a mode that runs it on the Arm legs.validate()refuses one no length up to 512 taps meets, withstd::runtime_error.tap::dsp::chainreports nowindow_frames(), so a chain holding a chain (down_by8, say) processes but cannot flush. The flush tests write such chains out flat, and the README says so. Making nested chains flush would be a DspTap change.iir_kernels.h's comment that allpass sections "reach an exactly zero state" under flush-to-zero is wrong for IIR-b's near-lineartransparentstage at divisor 1. Its "IIR-c's to decide" on the Chebyshev cycle is now decided. Both are DspTap's to correct.🤖 Generated with Claude Code
https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf