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>
39 lines
1.2 KiB
Swift
39 lines
1.2 KiB
Swift
// ParallelSectionState.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/// Serialisable snapshot of a parallel section (`split()` → two branches → `merge()`).
|
|
///
|
|
/// Captures each branch's pedal chain in signal-flow order plus the splitter's current
|
|
/// routing `mode`. Reconstructed by `loadRig`/`rebuildBoard` via `board.split()`, adding the
|
|
/// branch pedals, `board.merge(_:)`, then restoring `mode`.
|
|
public struct ParallelSectionState: Codable, Equatable {
|
|
|
|
/// Branch A pedal snapshots in signal-flow order.
|
|
public let branchA: [PedalState]
|
|
|
|
/// Branch B pedal snapshots in signal-flow order.
|
|
public let branchB: [PedalState]
|
|
|
|
/// The splitter routing mode (`.a` / `.b` / `.both`).
|
|
public let mode: SplitMode
|
|
|
|
/// Creates a parallel section snapshot.
|
|
///
|
|
/// - Parameters:
|
|
/// - branchA: Branch A pedal snapshots in order.
|
|
/// - branchB: Branch B pedal snapshots in order.
|
|
/// - mode: The splitter routing mode.
|
|
public init(
|
|
branchA: [PedalState],
|
|
branchB: [PedalState],
|
|
mode: SplitMode
|
|
) {
|
|
self.branchA = branchA
|
|
self.branchB = branchB
|
|
self.mode = mode
|
|
}
|
|
}
|