Skip to content

Pin DspTap 0.7.0; replace the five private Butterworth copies with DspTap's stage - #40

Merged
tap merged 2 commits into
mainfrom
ccr-daa69fda-lj5z0o
Nov 24, 2026
Merged

tap merged 2 commits into
mainfrom
ccr-daa69fda-lj5z0o

Conversation

@tap

@tap tap commented Nov 24, 2026

Copy link
Copy Markdown
Owner

What this changes

Two commits.

1. The DspTap pin moves from 2137d86 to a20b1ef. That is the commit carrying DspTap 0.7.0; v0.7.0 is not tagged yet.

  • A new include/taptools/dsptap_version.h asserts 0.7.0 as the floor. Every header that reaches into tap::dsp includes it.
  • Nothing TapTools already called changes between the two pins. Outputs of nr, spectra, conv_engine, tune and harmonizer are bit-identical across them.
  • Stale "Ooura static lib" comments are corrected in CMakeLists.txt, README.md and bench/fft_bench.cpp.

2. The five private Butterworth copies are replaced with DspTap's stage, tap::dsp::basic_butterworth_lowpass<double, N>.

  • The copies were:
    • butterworth4 in ladder.h, diode_ladder.h, overdrive.h and svf.h;
    • butterworth8 in fuzz.h, which ondes.h reuses.
  • They now go through one adapter, include/taptools/butterworth.h (butterworth_lowpass<N>, with butterworth4 / butterworth8 as aliases). It keeps the copies' design / tick / reset shape, so no call site changes.
    • design() is set_cutoff(): noexcept and allocation-free. It returns at once when the cutoff is unchanged.
    • The default constructor designs at 0.225 cycles per sample, because the stage has no default constructor.
  • New tests/butterworth_test.cpp: the stage against a copy of the old cookbook cascades at every corner a kernel designs.
  • Flush-to-zero. The stage asserts in Debug builds that the calling thread flushes subnormals; DspTap leaves setting it to the host. tools/support/flush_to_zero.h is a scope that sets the bits and restores the caller's register. This tree's own hosts use it:
    • a Catch2 listener around every test case;
    • the C ABI's process entry points for the oversampled kernels;
    • the benchmarks and the render tools.
  • New bench/oversampling_bench.cpp times every oversampled kernel at every factor.
  • Docs: the kernel banners, README.md, bench/README.md and the book's machine chapters (ladder, diode, overdrive, svf, fuzz) describe the shared stage and cite it.

Why

Each of these kernels carried its own copy of the same filter. DspTap now has the stage, written for exactly this use: its set_cutoff() is the allocation-free redesign that set_oversample() needs while audio runs. 0.7.0 made that call cheaper: 1.1–2.8 µs at order 4 and 5.5–14 µs at order 8 on x86-64, down from 45–188 µs in 0.6.0.

Verification

All on x86-64, Linux.

  • Builds. Each runs ctest 1/1: 328 test cases and 1,763,565 assertions (325 test cases before this PR).

    • GCC 13 Release, Clang 18 Release and GCC 13 Debug, at the 0.7.0 pin.
    • The Debug build runs the flush-to-zero assertion.
    • GCC's warnings are the 44 that main has.
  • Format and lint. clang-format 18 is clean on the tree. clang-tidy 18 reports nothing on new or changed lines.

  • Output difference, old copies against the stage. Max |difference|, with the difference over the output's peak in brackets. Inputs: sawtooths at 110 and 1003 Hz plus white noise, at every oversampling factor.

    Kernel Max abs diff Relative to peak
    ladder 3.5e-10 1.1e-9
    diode 2.1e-10 9.9e-10
    svf 3.7e-10 4.4e-10
    overdrive 7.1e-9 1.3e-8
    fuzz 2.5e-8 2.4e-8
    ondes 2.0e-10 1.2e-9
    • The filter alone differs by at most 2.9e-9 at order 4 and 3.7e-9 at order 8; butterworth_test.cpp pins it under 1e-8.
    • No existing test tolerance changed.
  • Performance (bench/oversampling_bench.cpp, 20 s of audio, GCC 13 -O3, flush-to-zero set, a shared 2.1 GHz Xeon VM).

    • Instructions per input sample (callgrind), copies → stage:

      Kernel 2× 4× 8×
      ladder −4 % 0 % –
      diode −3 % −1 % –
      svf (driven) −2 % +4 % –
      overdrive −8 % +2 % +9 %
      fuzz +4 % +7 % +10 %
      ondes +11 % +13 % +15 %
    • Wall clock: fuzz at 8× is 2.23 % of a core against 2.20 % with the copies. Every case is inside this host's run-to-run spread.

    • Passing the stage each input sample's oversampled frames as one block was measured too, and was no better.

  • Notebooks. The eight that drive these kernels were run against the old and the new C ABI. Every printed figure and every plot is identical (PNG bytes), so they are not re-executed.

  • Not run here: macOS arm64, where the compiler may fuse multiply-adds, and Windows. CI is the first gate for both; the 1e-8 test bound leaves room for contraction.

Notes for the reviewer

  • Submodule pin moved. a20b1ef carries 0.7.0's version bump; v0.6.0 is on 3143a02.
    • DspTap main has one more commit, b26a7db, which re-records bench baselines only.
    • If v0.7.0 is tagged anywhere other than a20b1ef, the pin follows it.
    • After this merges, TapTools-Max bumps its pin.
  • TapTools-Max must set flush-to-zero on its audio threads (or confirm Max already does) before it takes this pin. Otherwise a Debug build of the externals stops at the stage's assertion. Release behaviour without it is what the copies did: subnormal decay after the input stops, a CPU matter, not a sound one.
  • tb303's notebook timing line. The notebooks build the C ABI unoptimized (-O0). There the stage's one-frame process() costs more than the inline copies did: about 480 → 890 ns/sample for the fast solver, and the printed exact/fast ratio drops from about 1.7× to 1.3–1.4×. Nothing in the book cites that line, and the committed notebook keeps its earlier run.
  • fuzz.h's "3.16 % / 3.02 %" is kept and marked as the measurement made with the old biquads, with the new figures beside it.
  • Left alone:
    • the install rule that still ships Ooura's readme as OOURA_LICENSE.txt;
    • book/src/fuzz.md's uncited "extra 1.4 % of a core";
    • the README's "All 29 headers" count.

Generated by Claude Code

submodules/dsptap moves from 2137d86 to a20b1ef, the commit that carries
DspTap 0.7.0 (to be tagged v0.7.0): the Butterworth low-pass stage
(tap/dsp/butterworth.h, 0.6.0) that the next commit adopts, its block
kernel, and 0.7.0's cheaper set_cutoff(), which drops the group-delay scan
from the redesign that TapTools' set_oversample() setters call. Nothing
TapTools calls changes between the two pins: the FFT already ran the
srdif engine at 2137d86 (fft.h, srdif.h and the vDSP backend gain move
semantics and documentation only; yin, psola and pvoc are untouched), and
the outputs of nr, spectra, conv_engine, tune (all three backends) and
harmonizer are bit-identical across the two pins (FNV-1a over one second
of a sawtooth plus noise, GCC 13, x86-64), so the executed notebooks stay
as they are.

- include/taptools/dsptap_version.h: static_assert(TAP_DSP_VERSION >=
  TAP_DSP_VERSION_ENCODE(0, 7, 0)), the floor DspTap's README asks a
  consumer to state. Included by every header that includes a tap/dsp
  header (stft.h, conv_engine.h, tune.h, harmonizer.h) rather than put in
  the umbrella, which no translation unit includes.
- CMakeLists.txt: tap::dsp is a pure INTERFACE target (as it already was
  at the old pin); the comments describing an Ooura wrapper and a static
  library it links are corrected.
- README.md, bench/fft_bench.cpp: DspTap vendors CMSIS-DSP and keeps only
  the Ooura package's license record; the FFT is the srdif engine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
ladder.h, diode_ladder.h, overdrive.h and svf.h each carried a 4th-order
Butterworth for the oversampling chain (two RBJ cookbook biquads at the Q
pair 0.54119610 / 1.30656296), and fuzz.h an 8th-order one that ondes.h
borrowed (four biquads). All five now run DspTap 0.7.0's
tap::dsp::basic_butterworth_lowpass<double, N> (tap/dsp/butterworth.h: the
bilinear design with pre-warping, Oppenheim & Schafer sec. 7.2, sections in
increasing pole radius, the same transposed direct form II arithmetic and
section order the copies ran) through one adapter:

- include/taptools/butterworth.h: tap::tools::butterworth_lowpass<N>, with
  butterworth4 and butterworth8 as its instantiations, keeps the copies'
  call shape (design / tick / reset) so every call site stays as it was.
  The default constructor designs the stage at 0.225 cycles per sample
  (0.45 / 2, the 2x chains' corner and fuzz's per-stage corner) because
  the stage has none; design() is set_cutoff() (noexcept, allocation-free,
  1.1 to 2.8 us at order 4 and 5.5 to 14 us at order 8 on x86-64 by
  DspTap 0.7.0's measurement) and returns at once at the cutoff the filter
  already has, so fuzz's configure() costs no redesign. fuzz::butterworth8 is an alias of it, so
  ondes.h's `using fuzz::butterworth8` is unchanged. The private biquad
  structs go where nothing else used them (ladder, diode, svf); overdrive
  and fuzz keep theirs for the voicing EQ, minus design_lowpass.
- tests/butterworth_test.cpp: the stage against a reference copy of the
  old cookbook cascades at every corner a kernel designs (0.225, 0.1125,
  0.05625), on noise at 0.9: measured at most 2.9e-9 (order 4) and 3.7e-9
  (order 8), GCC 13 and Clang 18 alike, pinned under 1e-8; plus the
  nominal default design and reset().

Flush-to-zero. The stage's process() asserts in a Debug build that the
calling thread flushes subnormals (tap/dsp/subnormals.h); DspTap leaves
setting it to the host. tools/support/flush_to_zero.h is a scope that
sets the bits (MXCSR FTZ | DAZ, FPCR.FZ, FPSCR.FZ) and restores the
caller's register, its register write mirroring DspTap's test support
(tests/support/iir_support.h) rather than copying it. This tree's hosts use
it: a Catch2 listener around every test case
(tests/support/flush_to_zero_listener.cpp; without it the Debug battery
aborts in autowah_test, through svf's driven circuit), the C ABI's process
entry points for svf, ladder, diode, tb303, autowah, overdrive, ondes and
fuzz (the notebooks build tools/capi with no build type, so with
assertions on), the three benchmarks that run these kernels and the five
render tools that do. For the shipping objects, setting it on the audio
threads is TapTools-Max's job; butterworth.h, the README and the ladder
chapter say so, and that a Release host without it gets what the copies
did: subnormal decay after the input stops, a CPU matter, not a sound
one.

Output difference, old copies against the stage (2 s each of a 110 Hz
saw at 0.5, a 1003 Hz saw at 0.8 and white noise at 0.5, every
oversampling factor, svf driven at orders 2 and 8, ondes as a source at
220 and 880 Hz; x86-64, GCC 13 -O3), max |difference| and that over the
output's peak: ladder 3.5e-10 (1.1e-9), diode 2.1e-10 (9.9e-10), svf
3.7e-10 (4.4e-10), overdrive 7.1e-9 (1.3e-8), fuzz 2.5e-8 (2.4e-8, its
drive amplifying the filter's difference), ondes 2.0e-10 (1.2e-9). The
existing battery passes unchanged: 328 test cases, 1,763,565 assertions on
GCC 13 and Clang 18 Release and on GCC 13 Debug, which runs the
flush-to-zero precondition; GCC's warnings are the 44 the tree had.

Notebooks. The eight that drive these kernels (autowah_validation, fuzz,
ladder, ondes, overdrive, step_seq, svf, tb303) were executed against the
old and the new C ABI on this machine: every printed figure and every
plot (PNG bytes) is identical, so the committed notebooks stay as they
are. The one line that would read differently is tb303's wall-clock
ns/sample print, which times the notebooks' unoptimized (-O0) build of the
C ABI: there the stage's one-frame process() call costs more than the
inline copies did (about 480 -> 890 ns/sample for the fast solver on this
machine, the exact/fast ratio 1.7 -> 1.3-1.4x). Nothing in the book cites
it; the optimized cost is the benchmark below.

Performance (bench/oversampling_bench.cpp, new: each oversampled kernel
at each factor over 20 s of a sawtooth plus noise, flush-to-zero set,
GCC 13 -O3, a shared 2.1 GHz Xeon VM). Instructions per input sample
(callgrind), copies -> stage: ladder 2x/4x -4/0 %, diode -3/-1 %, svf
driven -2/+4 %, overdrive 2x/4x/8x -8/+2/+9 %, fuzz +4/+7/+10 %, ondes
+11/+13/+15 % (the stage's per-sample kernel runs its sections in a loop
over a coefficient table, where the copies were inline calls). Wall clock (best of 30 runs
interleaved over two sessions, pinned to one CPU): fuzz 8x 2.23 % of a
core against 2.20 %, 4x 1.24 % against 1.26 %; every case within the
host's run-to-run spread, which the 1x rows (no filter run) show at up to
24 %. svf_bench and diode_bench agree: diode within 2 %, svf driven
-10 to +9 %. Handing the stage each input sample's 2 to 8 oversampled
frames as one block (its block kernel) was measured too and was no
better (instructions -4 to +18 % against the per-sample route), so the
call sites stayed per sample. fuzz.h's cost paragraph and the fuzz
chapter state the re-measurement beside the historical 3.16 / 3.02 %.

Docs: the six kernel banners, README, bench/README.md and the book's
machine chapters (ladder, diode, overdrive, svf, fuzz) describe the
shared stage and cite it; the ladder chapter carries the flush-to-zero
note for all of them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
@tap
tap merged commit 0b60a5e into main Nov 24, 2026
12 checks passed
tap pushed a commit to tap/SampleRateTap that referenced this pull request Nov 25, 2026
The ×4 / ×8 / ×16 plan still listed DspTap's scaffold as open. It merged
as tap/DspTap#67 on 2026-11-21 (tap/dsp/subband.h: subband_delta over the
exact_delay_stage and subband_op concepts) and shipped in DspTap v0.3.0
beside IIR-a; this tree has pinned it since IIR-b, and rational's IIR
battery runs its stages through it.

- docs/X4_X8_PLAN.md: status v9 (X-c landed; what remains is the rest of
  TapTools), section 8 item 7 marked landed, and item 8's first step
  (TapTools' DspTap pin) marked done, past it at 0.7.0 (tap/TapTools#40).
- docs/ROADMAP.md: the block's X-c entry landed, the TapTools entry's pin
  landed and the rest open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
tap pushed a commit to tap/SampleRateTap that referenced this pull request Nov 25, 2026
The ×4 / ×8 / ×16 plan still listed DspTap's scaffold as open. It merged
as tap/DspTap#67 on 2026-11-21 (tap/dsp/subband.h: subband_delta over the
exact_delay_stage and subband_op concepts) and shipped in DspTap v0.3.0
beside IIR-a; this tree has pinned it since IIR-b, and rational's IIR
battery runs its stages through it.

- docs/X4_X8_PLAN.md: status v9 (X-c landed; what remains is the rest of
  TapTools), section 8 item 7 marked landed, and item 8's first step
  (TapTools' DspTap pin) marked done, past it at 0.7.0 (tap/TapTools#40).
- docs/ROADMAP.md: the block's X-c entry landed, the TapTools entry's pin
  landed and the rest open.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016GKzq1VSdcMYCRMhddiMaf
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.

2 participants