Files
ShoeGaze/Sources/LyrebirdShoeGaze/Routing/StereoSplitter.swift
T
josh f89229282f 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>
2026-06-21 16:48:25 -07:00

80 lines
2.8 KiB
Swift

// StereoSplitter.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import LyrebirdSynth
import LyrebirdUI
/// Fans one mono input bus out to two branch buses plus a dry-tap bus.
///
/// Unlike ``Splitter`` (which gates each branch and is consumed by a summing ``Merger``),
/// `StereoSplitter` is the head of a stereo split region: the two branches are processed
/// independently and become the left and right output channels, while the dry tap carries
/// the clean pre-split signal forward so the region's ``StereoRouteCollector`` can offer a
/// `bypass` route. All three outputs carry the full input signal — gating and routing are
/// performed downstream by the collector, not here.
///
/// ## Signal graph
///
/// ```
/// inputBus → In.Audio ──┬── → outputBusLeft (left branch input)
/// ├── → outputBusRight (right branch input)
/// └── → dryTapBus (clean pre-split signal)
/// ```
///
/// - Parameters:
/// - inputBus: Audio bus index to read the mono input from.
/// - outputBusLeft: Audio bus index for the left branch input.
/// - outputBusRight: Audio bus index for the right branch input.
/// - dryTapBus: Audio bus index for the clean pre-split tap.
public final class StereoSplitter: SynthesizerBase {
// MARK: - Routing
/// Audio bus index from which the mono input is read.
public internal(set) var inputBus: Int
/// Audio bus index for the left branch input.
public internal(set) var outputBusLeft: Int
/// Audio bus index for the right branch input.
public internal(set) var outputBusRight: Int
/// Audio bus index for the clean pre-split tap.
public internal(set) var dryTapBus: Int
// MARK: - Init
/// Creates a stereo splitter that fans one input to two branches plus a dry tap.
///
/// - Parameters:
/// - inputBus: Audio bus index to read the mono input from.
/// - outputBusLeft: Audio bus index for the left branch input.
/// - outputBusRight: Audio bus index for the right branch input.
/// - dryTapBus: Audio bus index for the clean pre-split tap.
public init(
inputBus: Int,
outputBusLeft: Int,
outputBusRight: Int,
dryTapBus: Int
) {
self.inputBus = inputBus
self.outputBusLeft = outputBusLeft
self.outputBusRight = outputBusRight
self.dryTapBus = dryTapBus
super.init()
}
// MARK: - Build
/// Builds the signal graph: input copied to both branch buses and the dry-tap bus.
public override func build() {
let inSig: In.Audio = input(bus: inputBus)
output(bus: outputBusLeft, source: inSig)
output(bus: outputBusRight, source: inSig)
output(bus: dryTapBus, source: inSig)
}
}