712f049f96
Replace the flat per-board pedal list with an ordered [BoardSegmentState] (pedal | parallel | stereoSplit | mergeToMono) so parallel and stereo split regions — branch pedal chains plus SplitMode/StereoRoute — round-trip through saveRig/loadRig and rebuildBoard. - PedalBoard.orderedSegments tracks chain structure (add/split/splitStereo/ mergeToMono); captureState() walks it; rebuildSegments() replays it. - BoardState backward-compatible: decodes legacy flat `pedals` arrays; computed `pedals` exposes the linear subset; throws on a file missing both keys. BoardSegmentState wire discriminators documented. - applyState (lightweight recall) extended to branch pedals + routing modes. - Unknown pedal types skipped on load, including inside branches. - Tests: parallel / stereo / mergeToMono file round-trips, legacy decode, unknown-pedal-in-branch, branch-param recall. Suite 116/116; demo builds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
40 lines
1.3 KiB
Swift
40 lines
1.3 KiB
Swift
// StereoSplitState.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/// Serialisable snapshot of a stereo split region (`splitStereo()` → two branches →
|
|
/// `collectStereo()`).
|
|
///
|
|
/// Captures the left and right branch pedal chains in signal-flow order plus the active
|
|
/// ``StereoRoute``. Reconstructed by `loadRig`/`rebuildBoard` via `board.splitStereo()`,
|
|
/// adding the branch pedals, `board.collectStereo(_:)`, then restoring `route`.
|
|
public struct StereoSplitState: Codable, Equatable {
|
|
|
|
/// Left-branch pedal snapshots in signal-flow order (becomes the left channel).
|
|
public let left: [PedalState]
|
|
|
|
/// Right-branch pedal snapshots in signal-flow order (becomes the right channel).
|
|
public let right: [PedalState]
|
|
|
|
/// The output route mode (`.stereo` / `.leftOnly` / `.rightOnly` / `.bypass`).
|
|
public let route: StereoRoute
|
|
|
|
/// Creates a stereo split snapshot.
|
|
///
|
|
/// - Parameters:
|
|
/// - left: Left-branch pedal snapshots in order.
|
|
/// - right: Right-branch pedal snapshots in order.
|
|
/// - route: The output route mode.
|
|
public init(
|
|
left: [PedalState],
|
|
right: [PedalState],
|
|
route: StereoRoute
|
|
) {
|
|
self.left = left
|
|
self.right = right
|
|
self.route = route
|
|
}
|
|
}
|