Written by an AI agent working in this repository.
chant-forge renders a Gregorian chant over a backing track and can push it to -14 LUFS with a lookahead limiter. Each limiter pass measures the true peak: the highest value the waveform reaches between samples, found by 4x oversampling with a 32-tap windowed-sinc filter. On a 3-minute track that is 8.4 million samples a channel, three 32-tap sums per sample, eight passes.
The meter already skipped work. Any interpolated value is at most the sum of the absolute tap values times the loudest sample in its window, so a window that can't beat the peak found so far is skipped. That bound works on quiet music. On a limited master it does little: every sample sits near the limiter's 0.766 ceiling, the absolute taps add up to 2.1 to 2.5, and the peak to beat is 0.886. The bound says "maybe" almost everywhere the music is loud.
Most of a sinc filter's weight is in the middle
The fix is a tighter bound that still costs little. Of the 32 taps, the 4 nearest the interpolated point carry most of the weight. Sum those 4 exactly, then bound the other 28 by their absolute sum (0.57 to 0.81) times the window's loudest sample. If even that total can't reach the current peak, the full 32-tap sum can't either, and the meter moves on.
Counted on the real render: the old block bound rules out 85% of points, and of the 7.5 million phase sums left per pass the new bound rules out 96%. truePeak went from 4.6 s to 2.1 s of CPU across the render.
Same answer, checked three ways
A skip only counts if it can never change the result:
- The bound carries a slack for floating-point rounding, about a hundred thousand times larger than the rounding the sums can actually have, and a NaN sample fails the comparison so it still reaches the full sum.
- The meter's existing test compares it bit for bit against the original version on random, bursty, clipped and NaN signals. We added four "limited" signals, clamped below a higher inter-sample peak, which is the case the new bound is for. With the bound deliberately broken (outer taps set to zero), two tests fail.
- The full render's channels and stems hash to the same sha256 before and after.
Two smaller changes came with it: the limiter now reuses its five working arrays across its eight passes instead of allocating about 300 MB of them on each pass, and the slowest test got its own file so it runs in parallel with the rest. The venture's test suite went from 24.9 s to 14.2 s.
The notes, profile and what to try next are in docs/history/ci-perf-2026-11-14-chant-forge-central-taps-bound.md.