1a09cf9cf8
A stereo-output pedal (Ping-Pong, Octave Splitter) now shows a "Stereo flow / Split L/R" toggle on its card: - Stereo flow (default): unchanged broadcast behavior — following pedals process both channels as one stereo flow. - Split L/R: inserts a Stereo Unzip region right after the pedal, routing the L channel into one lane and R into the other for independent processing, then recombining to stereo with the same route/solo/bypass control as the stereo split. Engine/core: - StereoUnzipSplitter: 2-in -> 3-out node (L->lane L, R->lane R, and a centered 0.5*L+0.5*R dry tap for the bypass route). - PedalBoard.unzipStereo() mirrors splitStereo() but reads both tails and requires width 2; reuses collectStereo / StereoSplitSection / StereoRouteCollector. New stereoUnzipSections (cleared on teardown). - BoardSegment/.stereoUnzip + StereoUnzipState round-trip via preset capture/rebuild/applyState. - ShoeGaze.insertStereoUnzip(afterSegment:)/isStereoUnzip(afterSegment:) drive the toggle; invalid insert (mono tail) throws cannotUnzipMonoChain and the atomic rebuild keeps the board intact. - StereoSplitSection.splitter relaxed to `any Synthesizer` (stored only) so it can hold either splitter type. UI: per-pedal toggle + STEREO UNZIP region rendering in BoardFlowView. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
95 lines
3.5 KiB
Swift
95 lines
3.5 KiB
Swift
// StereoUnzipSplitter.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import LyrebirdSynth
|
|
|
|
/// Splits an existing stereo signal's two channels into two independent branch inputs, plus a
|
|
/// centered mono dry tap.
|
|
///
|
|
/// This is the head of a *stereo unzip* region (the stereo counterpart of ``StereoSplitter``).
|
|
/// Where `StereoSplitter` duplicates one mono input into both branches, `StereoUnzipSplitter`
|
|
/// reads the current left and right tails and routes each into its own branch so the channels can
|
|
/// be processed independently, then recombined by a ``StereoRouteCollector`` (reused from the
|
|
/// stereo split). The dry tap carries `0.5·L + 0.5·R` — a centered mono monitor of the pre-unzip
|
|
/// signal for the collector's `bypass` route.
|
|
///
|
|
/// ## Signal graph
|
|
///
|
|
/// ```
|
|
/// inputLeft → In.Audio → outputBusLeft (left branch input)
|
|
/// inputRight → In.Audio → outputBusRight (right branch input)
|
|
/// (0.5·L + 0.5·R) → dryTapBus (centered mono monitor)
|
|
/// ```
|
|
///
|
|
/// - Parameters:
|
|
/// - inputLeft: Audio bus index of the incoming left channel.
|
|
/// - inputRight: Audio bus index of the incoming right channel.
|
|
/// - outputBusLeft: Audio bus index for the left branch input.
|
|
/// - outputBusRight: Audio bus index for the right branch input.
|
|
/// - dryTapBus: Audio bus index for the centered mono dry tap.
|
|
public final class StereoUnzipSplitter: SynthesizerBase {
|
|
|
|
// MARK: - Routing
|
|
|
|
/// Audio bus index of the incoming left channel.
|
|
public internal(set) var inputLeft: Int
|
|
|
|
/// Audio bus index of the incoming right channel.
|
|
public internal(set) var inputRight: 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 centered mono dry tap.
|
|
public internal(set) var dryTapBus: Int
|
|
|
|
// MARK: - Constants
|
|
|
|
/// Per-channel gain for the centered mono dry sum, so two correlated channels do not double.
|
|
private static let dryChannelGain: Double = 0.5
|
|
|
|
// MARK: - Init
|
|
|
|
/// Creates a stereo unzip splitter.
|
|
///
|
|
/// - Parameters:
|
|
/// - inputLeft: Audio bus index of the incoming left channel.
|
|
/// - inputRight: Audio bus index of the incoming right channel.
|
|
/// - outputBusLeft: Audio bus index for the left branch input.
|
|
/// - outputBusRight: Audio bus index for the right branch input.
|
|
/// - dryTapBus: Audio bus index for the centered mono dry tap.
|
|
public init(
|
|
inputLeft: Int,
|
|
inputRight: Int,
|
|
outputBusLeft: Int,
|
|
outputBusRight: Int,
|
|
dryTapBus: Int
|
|
) {
|
|
self.inputLeft = inputLeft
|
|
self.inputRight = inputRight
|
|
self.outputBusLeft = outputBusLeft
|
|
self.outputBusRight = outputBusRight
|
|
self.dryTapBus = dryTapBus
|
|
super.init()
|
|
}
|
|
|
|
// MARK: - Build
|
|
|
|
/// Builds the signal graph: each input channel copied to its branch bus, and a centered mono
|
|
/// sum written to the dry tap.
|
|
public override func build() {
|
|
let leftSig: In.Audio = input(bus: inputLeft)
|
|
let rightSig: In.Audio = input(bus: inputRight)
|
|
output(bus: outputBusLeft, source: leftSig)
|
|
output(bus: outputBusRight, source: rightSig)
|
|
let gain: Double = StereoUnzipSplitter.dryChannelGain
|
|
output(bus: dryTapBus, source: (leftSig * gain) + (rightSig * gain))
|
|
}
|
|
}
|