Serialize split-region topology in presets
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>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// BoardSegment.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// One ordered element of a ``PedalBoard``'s signal chain, used to capture full topology
|
||||
/// (including parallel and stereo split regions) in signal-flow order.
|
||||
///
|
||||
/// `PedalBoard` records these as pedals and split regions are added, so a board can be
|
||||
/// serialized and rebuilt faithfully rather than as a flat pedal list. Branch pedals live
|
||||
/// inside their section objects, not as separate segments.
|
||||
enum BoardSegment {
|
||||
|
||||
/// A single linear pedal in the main chain.
|
||||
case pedal(Pedal)
|
||||
|
||||
/// A parallel section (`split()` → two branches → `merge()`).
|
||||
case parallel(ParallelSection)
|
||||
|
||||
/// A stereo split region (`splitStereo()` → two branches → `collectStereo()`).
|
||||
case stereoSplit(StereoSplitSection)
|
||||
|
||||
/// A `mergeToMono()` collapse — narrows a stereo tail back to mono. Carries no state;
|
||||
/// recorded so the width transition replays on rebuild.
|
||||
case mergeToMono
|
||||
}
|
||||
Reference in New Issue
Block a user