Files
ShoeGaze/Sources/LyrebirdShoeGaze/Presets/BoardSegmentState.swift
T
josh 1a09cf9cf8 Add Stereo Unzip: process a stereo signal's L/R independently
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>
2026-06-22 10:21:18 -07:00

36 lines
1.5 KiB
Swift

// BoardSegmentState.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
/// Serialisable snapshot of one ordered element of a board's signal chain.
///
/// A board's full topology is a `[BoardSegmentState]` in signal-flow order: a sequence of
/// linear pedals interleaved with parallel and stereo split regions. This is the unit that
/// makes split-region topology round-trip through presets, where the older flat
/// `[PedalState]` list could not.
///
/// `Codable` conformance is auto-synthesized for this associated-value enum.
///
/// > Important: The synthesized encoding uses the case names — `"pedal"`, `"parallel"`,
/// > `"stereoSplit"` — as the on-disk discriminators. Renaming a case is a wire-format break
/// > that would prevent older presets from decoding; rename only with a migration.
public enum BoardSegmentState: Codable, Equatable {
/// A single linear pedal. Wire discriminator: `"pedal"`.
case pedal(PedalState)
/// A parallel section (`split()`/`merge()`). Wire discriminator: `"parallel"`.
case parallel(ParallelSectionState)
/// A stereo split region (`splitStereo()`/`collectStereo()`). Wire discriminator: `"stereoSplit"`.
case stereoSplit(StereoSplitState)
/// A stereo unzip region (`unzipStereo()`/`collectStereo()`). Wire discriminator: `"stereoUnzip"`.
case stereoUnzip(StereoUnzipState)
/// A `mergeToMono()` collapse (no payload). Wire discriminator: `"mergeToMono"`.
case mergeToMono
}