feat(postboard): shared post-board chain after the board mix
Add a dedicated linear stereo post-board chain that processes the summed board mix once, after the board split, before the hardware output — for global reverb, a bus limiter, a final EQ, and the like. Routing: when a post-chain exists, every BoardOutputMaster writes a shared stereo mix bus (parameterized output bus indices) instead of hardware; the post-chain (PostChain + PostChainOutput) reads that mix, runs its pedals in order, and copies the tail to the hardware outputs. Always stereo-headed (dual-mono for a mono rig) so mono pedals auto-stereoize per channel. The chain's head node is inserted at .tail(of: mainGroup), so it evaluates after every board master regardless of board add order — no re-order on board add, and no board dropped from the mix. buildPostChain tracks the chain before wiring it so a mid-build throw stays reclaimable by teardown. State: additive ShoeGazeState.postChain (nil-when-empty, decodeIfPresent, byte-identical old-rig round-trip). Edit API (append/insert/remove/move) mirrors the pre-board chain: capture-from-live, stop/teardown/rebuild. Undo treats a post-topology change as a full rebuild via id-sequence compare. UI: a hide-when-empty post-board strip below the boards, symmetric to the pre-board strip, with palette routing and per-pedal remove through undo. Bumps the iOS demo's Lyrebird pin to 2.3.0 (onEditingEnded). Tests: PostBoardChainTests (render, closed-volume silences output, post-chain-after-every-master ordering, board-add ordering, insert/move/ remove, save/load round-trip with knob, old-rig decode) + post-pedal undo. 855 tests pass. Reviewed (RT-safety + line sweep); the ordering bug both reviewers caught is fixed at the root and covered by a deterministic test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -80,6 +80,12 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// bypass source so a bypassed board passes its untouched input straight through.
|
||||
private let dryInputBusIndex: Int
|
||||
|
||||
/// Destination buses for the master's stereo output — hardware 0 / 1 by default. When a
|
||||
/// post-board chain exists, the masters are pointed at a shared **mix bus** instead, and the
|
||||
/// post-chain reads that mix and writes hardware. All boards share the same destination.
|
||||
private let outputLeftBusIndex: Int
|
||||
private let outputRightBusIndex: Int
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Lag time constant in seconds for the bypass crossfades — smooths engaged ↔ bypassed
|
||||
@@ -99,10 +105,18 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// - boardOutputBusRightIndex: Right board output bus index for a stereo (width-2) board,
|
||||
/// or `nil` for a mono board (the signal is panned to centre instead).
|
||||
/// - dryInputBusIndex: The board's head-bus index, read as the dry bypass source.
|
||||
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil, dryInputBusIndex: Int) {
|
||||
init(
|
||||
boardOutputBusIndex: Int,
|
||||
boardOutputBusRightIndex: Int? = nil,
|
||||
dryInputBusIndex: Int,
|
||||
outputLeftBusIndex: Int = 0,
|
||||
outputRightBusIndex: Int = 1
|
||||
) {
|
||||
self.boardOutputBusIndex = boardOutputBusIndex
|
||||
self.boardOutputBusRightIndex = boardOutputBusRightIndex
|
||||
self.dryInputBusIndex = dryInputBusIndex
|
||||
self.outputLeftBusIndex = outputLeftBusIndex
|
||||
self.outputRightBusIndex = outputRightBusIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
@@ -131,15 +145,15 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
let switchedRight: any ValidGeneratorInput = applyBypass(wet: boardOutRight, dry: dry)
|
||||
let gainedRight: any ValidGeneratorInput =
|
||||
((switchedRight * smoothedSelect) * $masterGain) * rigOutputGain
|
||||
output(bus: 0, source: gainedLeft)
|
||||
output(bus: 1, source: gainedRight)
|
||||
output(bus: outputLeftBusIndex, source: gainedLeft)
|
||||
output(bus: outputRightBusIndex, source: gainedRight)
|
||||
} else {
|
||||
// Mono board: write the mono signal to both hardware buses at unity (0 dB). Using an
|
||||
// equal-power `Pan2` to centre would drop each channel by 3 dB (×0.707) — power-correct
|
||||
// for a true pan, but a mono guitar rig should come out at the same level it went in, so
|
||||
// the signal is copied to left and right directly instead.
|
||||
output(bus: 0, source: gainedLeft)
|
||||
output(bus: 1, source: gainedLeft)
|
||||
output(bus: outputLeftBusIndex, source: gainedLeft)
|
||||
output(bus: outputRightBusIndex, source: gainedLeft)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user