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>
33 lines
1.4 KiB
Swift
33 lines
1.4 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 `mergeToMono()` collapse (no payload). Wire discriminator: `"mergeToMono"`.
|
|
case mergeToMono
|
|
}
|