Add mono→stereo routing to PedalBoard
Introduce chain width propagation (mono=1 / stereo=2, capped at 2), represented as a pair of mono buses to reuse existing infrastructure. - Pedal: width-parameterized build() with channelKind (mono / widener / stereoNative); effect() runs per channel for auto-stereoize, shared knobs. - PedalBoard: width tracking, add() dispatch, mergeToMono(), splitStereo()/ collectStereo() with four route modes (stereo / leftOnly / rightOnly / bypass), centered solo, click-free lagged gains. - BoardOutputMaster: width-aware (Pan2 mono, direct L/R stereo). - New routing nodes: StereoSplitter, StereoRouteCollector, StereoSplitSection. - Reference pedals: OctaveUpSplitterPedal (widener), PingPongDelayPedal (stereo-native). - 12 stereo-routing tests; full suite 108/108. Design: docs/stereo-routing-design.md Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -40,29 +40,52 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
|
||||
// MARK: - Routing
|
||||
|
||||
/// Left / mono board output bus index.
|
||||
private let boardOutputBusIndex: Int
|
||||
|
||||
/// Right board output bus index when the board tail is stereo (width 2), else `nil`.
|
||||
/// When set, the left bus drives hardware 0 and the right bus drives hardware 1 directly,
|
||||
/// bypassing the mono `Pan2` spread.
|
||||
private let boardOutputBusRightIndex: Int?
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Pan position for the board in the stereo field. Centre = 0.0.
|
||||
/// Pan position for the board in the stereo field. Centre = 0.0. Used only for a mono board.
|
||||
private let stereoPan: Double = 0.0
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
init(boardOutputBusIndex: Int) {
|
||||
/// Creates a board output master.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - boardOutputBusIndex: Left / mono board output bus index.
|
||||
/// - 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).
|
||||
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil) {
|
||||
self.boardOutputBusIndex = boardOutputBusIndex
|
||||
self.boardOutputBusRightIndex = boardOutputBusRightIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
// MARK: - Build
|
||||
|
||||
override func build() {
|
||||
let boardOut: In.Audio = input(bus: boardOutputBusIndex)
|
||||
// Lag the board-select gain so switching boards crossfades over `crossfadeTime`
|
||||
// seconds rather than clicking. The user master-gain knob is applied directly.
|
||||
let smoothedSelect: Lag.Control = Lag.Control(input: $selectGain, time: $crossfadeTime)
|
||||
let gained: any ValidGeneratorInput = (boardOut * smoothedSelect) * $masterGain
|
||||
// Pan2 spreads the mono pedalboard output to stereo hardware buses 0 + 1.
|
||||
output(bus: 0, source: Pan2(input: gained, pan: stereoPan))
|
||||
|
||||
let boardOutLeft: In.Audio = input(bus: boardOutputBusIndex)
|
||||
let gainedLeft: any ValidGeneratorInput = (boardOutLeft * smoothedSelect) * $masterGain
|
||||
|
||||
if let rightIndex: Int = boardOutputBusRightIndex {
|
||||
// Stereo board: left tail → hardware 0, right tail → hardware 1, no pan spread.
|
||||
let boardOutRight: In.Audio = input(bus: rightIndex)
|
||||
let gainedRight: any ValidGeneratorInput = (boardOutRight * smoothedSelect) * $masterGain
|
||||
output(bus: 0, source: gainedLeft)
|
||||
output(bus: 1, source: gainedRight)
|
||||
} else {
|
||||
// Mono board: Pan2 spreads the mono output to stereo hardware buses 0 + 1.
|
||||
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user