Add MIDI foot-controller control; board/rig bypass; iOS fixes
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>
This commit is contained in:
@@ -49,6 +49,10 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
private var engine: SynthesisEngine
|
||||
private var iosDriver: iOSAudioDriver
|
||||
|
||||
/// Foot-controller MIDI input. Owned here so it outlives the live-input engine rebuild; the
|
||||
/// underlying Core MIDI client is engine-bound, so it is recreated against each new engine.
|
||||
private(set) var midi: MIDIController
|
||||
|
||||
/// The shared rig library (iCloud-or-local). Independent of the engine, so it survives the
|
||||
/// live-input engine rebuild.
|
||||
private(set) var library: RigLibraryStore
|
||||
@@ -83,6 +87,11 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
// Construct the library instantly; it resolves iCloud + loads asynchronously via
|
||||
// startLibrary() from the app's .task.
|
||||
self.library = RigLibraryBootstrap.makeStore()
|
||||
|
||||
// Connect MIDI foot-controller input and begin listening for devices.
|
||||
self.midi = MIDIController(engine: built.engine, shoeGaze: shoeGaze)
|
||||
self.midi.start()
|
||||
self.midi.onMapChanged = { [weak self] in self?.save() }
|
||||
}
|
||||
|
||||
/// Persists the current rig. Call when the app moves to the background.
|
||||
@@ -201,6 +210,13 @@ final class ShoeGazeBuilderiOSAppModel {
|
||||
ShoeGazeBuilderiOSAppModel.seedFallbackBoard(into: shoeGaze)
|
||||
}
|
||||
|
||||
// The Core MIDI client is bound to the old engine — recreate it against the new one and
|
||||
// point it at the rebuilt rig, preserving the "MIDI outlives the rebuild" contract.
|
||||
midi.stop()
|
||||
midi = MIDIController(engine: rebuilt.engine, shoeGaze: shoeGaze)
|
||||
midi.start()
|
||||
midi.onMapChanged = { [weak self] in self?.save() }
|
||||
|
||||
selectLiveInputAndPersist()
|
||||
|
||||
if wasRunning { try? engine.start() }
|
||||
|
||||
Reference in New Issue
Block a user