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:
@@ -28,6 +28,14 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// Defaults to a short 20 ms so normal use is click-free; raise it for a slow crossfade.
|
||||
@UIParam var crossfadeTime: Double = 0.02
|
||||
|
||||
/// Per-board full-bypass state. `0` = board engaged (processed output), `1` = bypassed
|
||||
/// (dry input passes straight through, skipping every pedal). Smoothed by `bypassLagTime`.
|
||||
@UIParam var boardBypass: Double = 0.0
|
||||
|
||||
/// Rig-wide full-bypass state, driven across every board at once. `0` = engaged,
|
||||
/// `1` = bypassed (dry). Independent of `boardBypass`; either engaged routes to dry.
|
||||
@UIParam var rigBypass: Double = 0.0
|
||||
|
||||
/// The live `UIParamNode` backing `masterGain`, exposed so the board (and its UI)
|
||||
/// can bind a master-volume knob to this stage.
|
||||
var gainNode: UIParamNode { $masterGain }
|
||||
@@ -38,6 +46,12 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// The live `UIParamNode` backing `crossfadeTime` (board crossfade seconds).
|
||||
var crossfadeTimeNode: UIParamNode { $crossfadeTime }
|
||||
|
||||
/// The live `UIParamNode` backing `boardBypass` (per-board full bypass).
|
||||
var boardBypassNode: UIParamNode { $boardBypass }
|
||||
|
||||
/// The live `UIParamNode` backing `rigBypass` (rig-wide full bypass).
|
||||
var rigBypassNode: UIParamNode { $rigBypass }
|
||||
|
||||
// MARK: - Routing
|
||||
|
||||
/// Left / mono board output bus index.
|
||||
@@ -48,11 +62,23 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// bypassing the mono `Pan2` spread.
|
||||
private let boardOutputBusRightIndex: Int?
|
||||
|
||||
/// The board's dry head-bus index (the mono input feeding the first pedal). Read as the
|
||||
/// bypass source so a bypassed board passes its untouched input straight through.
|
||||
private let dryInputBusIndex: Int
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Pan position for the board in the stereo field. Centre = 0.0. Used only for a mono board.
|
||||
private let stereoPan: Double = 0.0
|
||||
|
||||
/// Lag time constant in seconds for the bypass crossfades — smooths engaged ↔ bypassed
|
||||
/// transitions to prevent clicks. Matches the per-pedal bypass lag.
|
||||
private let bypassLagTime: Double = 0.02
|
||||
|
||||
/// Remaps a `[0, 1]` bypass value to CrossFade's `[-1, +1]` equal-power pan.
|
||||
private let bipolarSpan: Double = 2.0
|
||||
private let bipolarOffset: Double = 1.0
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// Creates a board output master.
|
||||
@@ -61,9 +87,11 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
/// - boardOutputBusIndex: Left / mono board output bus index.
|
||||
/// - boardOutputBusRightIndex: Right board output bus index for a stereo (width-2) board,
|
||||
/// or `nil` for a mono board (the signal is panned to centre instead).
|
||||
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil) {
|
||||
/// - dryInputBusIndex: The board's head-bus index, read as the dry bypass source.
|
||||
init(boardOutputBusIndex: Int, boardOutputBusRightIndex: Int? = nil, dryInputBusIndex: Int) {
|
||||
self.boardOutputBusIndex = boardOutputBusIndex
|
||||
self.boardOutputBusRightIndex = boardOutputBusRightIndex
|
||||
self.dryInputBusIndex = dryInputBusIndex
|
||||
super.init()
|
||||
}
|
||||
|
||||
@@ -74,13 +102,19 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
// seconds rather than clicking. The user master-gain knob is applied directly.
|
||||
let smoothedSelect: Lag.Control = Lag.Control(input: $selectGain, time: $crossfadeTime)
|
||||
|
||||
// The dry input tap — read once, used as the bypass source for both channels (the head
|
||||
// bus is mono, so a bypassed stereo board passes the same dry signal to both sides).
|
||||
let dry: In.Audio = input(bus: dryInputBusIndex)
|
||||
|
||||
let boardOutLeft: In.Audio = input(bus: boardOutputBusIndex)
|
||||
let gainedLeft: any ValidGeneratorInput = (boardOutLeft * smoothedSelect) * $masterGain
|
||||
let switchedLeft: any ValidGeneratorInput = applyBypass(wet: boardOutLeft, dry: dry)
|
||||
let gainedLeft: any ValidGeneratorInput = (switchedLeft * smoothedSelect) * $masterGain
|
||||
|
||||
if let rightIndex: Int = boardOutputBusRightIndex {
|
||||
// Stereo board: left tail → hardware 0, right tail → hardware 1, no pan spread.
|
||||
let boardOutRight: In.Audio = input(bus: rightIndex)
|
||||
let gainedRight: any ValidGeneratorInput = (boardOutRight * smoothedSelect) * $masterGain
|
||||
let switchedRight: any ValidGeneratorInput = applyBypass(wet: boardOutRight, dry: dry)
|
||||
let gainedRight: any ValidGeneratorInput = (switchedRight * smoothedSelect) * $masterGain
|
||||
output(bus: 0, source: gainedLeft)
|
||||
output(bus: 1, source: gainedRight)
|
||||
} else {
|
||||
@@ -88,4 +122,20 @@ final class BoardOutputMaster: SynthesizerBase {
|
||||
output(bus: 0, source: Pan2(input: gainedLeft, pan: stereoPan))
|
||||
}
|
||||
}
|
||||
|
||||
/// Routes `wet` to `dry` when either the per-board or rig-wide bypass is engaged. Two cascaded
|
||||
/// equal-power crossfades (each lagged to prevent clicks) give an independent "OR" of the two
|
||||
/// bypass sources: rig bypass overrides even a board that is otherwise engaged.
|
||||
private func applyBypass(
|
||||
wet: any ValidGeneratorInput,
|
||||
dry: any ValidGeneratorInput
|
||||
) -> any ValidGeneratorInput {
|
||||
let boardLagged: Lag.Control = Lag.Control(input: $boardBypass, time: bypassLagTime)
|
||||
let boardPan: any ValidGeneratorInput = (boardLagged * bipolarSpan) - bipolarOffset
|
||||
let afterBoard: CrossFade.Audio = CrossFade.Audio(inA: wet, inB: dry, pan: boardPan)
|
||||
|
||||
let rigLagged: Lag.Control = Lag.Control(input: $rigBypass, time: bypassLagTime)
|
||||
let rigPan: any ValidGeneratorInput = (rigLagged * bipolarSpan) - bipolarOffset
|
||||
return CrossFade.Audio(inA: afterBoard, inB: dry, pan: rigPan)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user