Fix tuner leaking its pitch signal into the audio output

TunerTap wrote its pitch-capture generator to the scratch bus via output(bus:),
which always builds an Out.Audio — so the write went to *audio*-bus memory at the
control bus's index. Control-bus indices are low, so they collide with the
hardware output buses (e.g. index 1 = right channel), and because the tap runs
.after(mainGroup) the write lands after the master's rig-mute gate. Result: the
tracked frequency (e.g. 82 Hz) was summed onto an output channel, bypassing the
mute — audible as crackle while the pitch was unstable, stopping once a note
locked. Confirmed by render: the leaked value appears verbatim on the output bus.

Route through controlOutput (Out.Control → control-bus memory) instead. The
scratch bus is a control bus; it was only ever meant to give the engine a reason
to evaluate the side-effecting capture generator, and nothing reads it.

Test engagedTunerDoesNotLeakIntoOutput renders a muted rig with the tuner engaged
and asserts the settled output tail is silent (fails without the fix — the tail
carries the leaked pitch value; passes with it). 465 tests pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-13 19:58:41 -07:00
parent 7720fbec7b
commit 551b650d45
2 changed files with 48 additions and 1 deletions
@@ -55,6 +55,12 @@ final class TunerTap: SynthesizerBase {
)
let capture: TunerPitchCapture = TunerPitchCapture(input: filtered)
pitchCapture = capture
output(bus: scratchControlBus, source: capture)
// Route through `controlOutput` (Out.Control → control-bus memory), NOT `output`
// (Out.Audio → *audio*-bus memory at the same index). The scratch bus exists only to give
// the engine a reason to evaluate the capture generator; writing the capture's pitch signal
// to an audio bus at the control-bus index would land it on a hardware output channel (a low
// control index collides with the output buses) — audible as crackle while the pitch is
// unstable — and, because this tap runs after `mainGroup`, would bypass the rig mute.
controlOutput(bus: scratchControlBus, source: capture)
}
}