1893576718
Headline: MIDI control for a Behringer FCB1010 (four phases). - MIDIController (Lyrebird MIDI client): connection indicator via source polling, background-queue->main-actor hop, MIDI Learn. - Volume and Wah pedals (Wah reuses the SVF bandpass sweep, driven by pedal position instead of an envelope follower). - CC -> any pedal knob (0-127 mapped across the knob range). - Program Change -> pedal/board/rig toggles: software latch for booleans, exclusive radio for board solo. Positional addressing with display-name hints; stale/out-of-range bindings are skipped, not fired. - Per-rig MIDIMap embedded in ShoeGazeState as an optional field (old rigs decode to nil; no preset version bump). Central MIDI Mapping sheet with Learn/Clear per control. Also included (same working branch): - Full board bypass and rig bypass (dry passthrough via cascaded crossfades in BoardOutputMaster), with UI toggles. - Horizontal pedal picker grouped by category in filter order. - Drag a palette pedal onto a chain card to insert before it (ShoeGaze.insertPedal); tap still appends. - iOS: guard macOS-only .menuStyle(.borderlessButton) to silence the _UIReparentingView warning; iCloud-unavailable alert; keep the device awake while audio runs. Tests: 24 added (Volume/Wah, MIDIMap Codable incl. legacy decode, CC and PC controller behavior, insert/bypass API). Full suite green; macOS and iOS app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
53 lines
2.0 KiB
Swift
53 lines
2.0 KiB
Swift
// ShoeGazeState.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/// Format version written into every saved preset file.
|
|
///
|
|
/// Increment this constant when the `ShoeGazeState` schema changes in a way that
|
|
/// requires migration logic on load.
|
|
public let presetFormatVersion: Int = 1
|
|
|
|
/// Serialisable snapshot of an entire `ShoeGaze` rig — all boards and their pedals.
|
|
///
|
|
/// Use `ShoeGaze.saveRig(to:)` to write and `ShoeGaze.loadRig(from:)` to restore.
|
|
/// The `version` field allows future migrations: loaders that read a file with a
|
|
/// higher `version` than `presetFormatVersion` should reject or warn, while loaders
|
|
/// reading older versions may apply forward-compatibility mappings.
|
|
///
|
|
/// Unknown pedal types encountered during load are silently skipped so presets made
|
|
/// with custom third-party pedals degrade gracefully on systems without those pedals.
|
|
public struct ShoeGazeState: Codable, Equatable {
|
|
|
|
/// Preset format version. Written as `presetFormatVersion` at save time.
|
|
public let version: Int
|
|
|
|
/// All board snapshots in the order they were created.
|
|
public let boards: [BoardState]
|
|
|
|
/// The rig's MIDI foot-controller bindings, or `nil` for a rig saved without any.
|
|
///
|
|
/// Optional so rigs written before MIDI mapping existed decode cleanly (the synthesized
|
|
/// `init(from:)` uses `decodeIfPresent`, yielding `nil` for the missing key) — no format
|
|
/// version bump is required for this additive field.
|
|
public let midiMap: MIDIMap?
|
|
|
|
/// Creates a rig state snapshot.
|
|
///
|
|
/// - Parameters:
|
|
/// - version: Preset format version. Defaults to `presetFormatVersion`.
|
|
/// - boards: Ordered list of board state snapshots.
|
|
/// - midiMap: The rig's MIDI bindings, or `nil` when there are none. Defaults to `nil`.
|
|
public init(
|
|
version: Int = presetFormatVersion,
|
|
boards: [BoardState],
|
|
midiMap: MIDIMap? = nil
|
|
) {
|
|
self.version = version
|
|
self.boards = boards
|
|
self.midiMap = midiMap
|
|
}
|
|
}
|