// 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) } }