Skip to content

audiobiquad: buffer_size, so a host's small blocks are filtered once - #324

Merged
bdbarnett merged 1 commit into
mainfrom
fix/biquad-buffer-size
Oct 28, 2026
Merged

bdbarnett merged 1 commit into
mainfrom
fix/biquad-buffer-size

Conversation

@bdbarnett

Copy link
Copy Markdown
Contributor

Biquad and AllPass now take buffer_size in bytes, the same as audioladder.Ladder: whole frames, from one frame up to the default 256.

Before this, a host feeding 128-frame blocks got 256 frames from each pull. The node filled them by taking the same looped block twice, so it filtered every block twice and the filter state ran ahead. At the host's own size, each pull takes exactly one source block.

Renders at the default size are byte-identical to before. The filter is per sample, so a smaller block size gives the same render, just cut smaller.

Tested:

  • BlockSizeTest in tests/test_cpython_audiobiquad.py, 5 tests. With the old fixed-size loop planted back in, 3 of them fail.
  • tests/parity/filter_f32_frames_probe.py gives byte-identical output on CPython and the unix MicroPython build, at 256, 64, 1 and 200 frames.
  • The CircuitPython spike bindings were edited to match but not compiled.

Biquad and AllPass take buffer_size in bytes, as the CircuitPython effects
do, from one frame up to the default 256. Each pull then hands out that many
frames and takes exactly one block from a source of the same size, so a host
running small blocks gets the filter with no latency and coefficients that
can move once a block. The filter is per sample, so the audio is the default
render cut smaller; renders at the default size are byte-identical to before.
@bdbarnett
bdbarnett merged commit 39b9dc3 into main Oct 28, 2026
31 checks passed
@bdbarnett
bdbarnett deleted the fix/biquad-buffer-size branch October 28, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant