Address review; make all pedal controls (incl. sliders) CC-mappable
Review fixes: - Remove stale phase-plan references from MIDIController / MIDIMappingSheet doc-comments (describe current behavior instead). - insertPedal: a board with no linear pedals but a trailing routing region now inserts at the head (before the region) instead of appending after it. - Drop the unused MIDIController.retarget (the app recreates the controller against a fresh engine rather than re-pointing it). - CC steal now matches controller AND channel, so per-channel CC bindings can coexist. Feature (requested): CC mapping now covers every continuous pedal control, not just rotary knobs. New PedalControl descriptor + Pedal.ccMappableControls (knobs followed by effect sliders); the Expression sheet lists them grouped per pedal with a header, so slider params (e.g. EQ bands) are assignable and labelled clearly. Knob-first ordering keeps existing CC bindings stable. Tests: +2 (CC drives a slider control; insert into a region-only board lands before the region). 318 total green; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -10,14 +10,14 @@ import LyrebirdUI
|
|||||||
|
|
||||||
/// Owns the Core MIDI connection for a ShoeGaze session and routes incoming messages to the rig.
|
/// Owns the Core MIDI connection for a ShoeGaze session and routes incoming messages to the rig.
|
||||||
///
|
///
|
||||||
/// Constructed once by the app (it must outlive `ShoeGaze` rebuilds), started with ``start()``, and
|
/// Constructed once by the app (it is recreated against a fresh engine when the engine is rebuilt),
|
||||||
/// re-pointed at a fresh `ShoeGaze` via ``retarget(_:)`` after an engine/rig rebuild. Handlers fire
|
/// and started with ``start()``. Handlers fire on Lyrebird's background MIDI queue; this controller
|
||||||
/// on Lyrebird's background MIDI queue; this controller hops to the main actor before touching any
|
/// hops to the main actor before touching any `@MainActor` rig state.
|
||||||
/// `@MainActor` rig state.
|
|
||||||
///
|
///
|
||||||
/// This is the Phase 1 surface: it establishes the connection, publishes device-connection state
|
/// It establishes the Core MIDI connection, publishes device-connection state for the UI indicator,
|
||||||
/// for the UI indicator, and installs a message handler whose body is filled in by later phases
|
/// and routes incoming messages to the rig: Control Change drives bound pedal controls, and Program
|
||||||
/// (CC → pedal position, Program Change → toggle actions).
|
/// Change toggles bound pedal / board / rig actions. MIDI Learn arms a control so the next matching
|
||||||
|
/// message binds to it.
|
||||||
@MainActor
|
@MainActor
|
||||||
@Observable
|
@Observable
|
||||||
public final class MIDIController {
|
public final class MIDIController {
|
||||||
@@ -111,11 +111,6 @@ public final class MIDIController {
|
|||||||
midi.stop()
|
midi.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Re-points the controller at a fresh `ShoeGaze` after an engine/rig rebuild.
|
|
||||||
public func retarget(_ shoeGaze: ShoeGaze) {
|
|
||||||
self.shoeGaze = shoeGaze
|
|
||||||
}
|
|
||||||
|
|
||||||
// MARK: - Message handling
|
// MARK: - Message handling
|
||||||
|
|
||||||
private func installHandler() {
|
private func installHandler() {
|
||||||
@@ -131,7 +126,8 @@ public final class MIDIController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Routes one incoming message to the rig: captures a binding when armed for Learn, otherwise
|
/// Routes one incoming message to the rig: captures a binding when armed for Learn, otherwise
|
||||||
/// applies any matching binding. (Program Change handling is added in a later phase.)
|
/// applies any matching binding. Control Change drives bound controls; Program Change toggles
|
||||||
|
/// bound actions.
|
||||||
private func handle(_ message: MIDIMessage) {
|
private func handle(_ message: MIDIMessage) {
|
||||||
switch message {
|
switch message {
|
||||||
case .controlChange(let channel, let controller, let value):
|
case .controlChange(let channel, let controller, let value):
|
||||||
@@ -209,14 +205,14 @@ public final class MIDIController {
|
|||||||
learnTarget = nil
|
learnTarget = nil
|
||||||
guard let shoeGaze: ShoeGaze = shoeGaze,
|
guard let shoeGaze: ShoeGaze = shoeGaze,
|
||||||
let pedal: Pedal = pedal(boardIndex: boardIndex, pedalIndex: pedalIndex),
|
let pedal: Pedal = pedal(boardIndex: boardIndex, pedalIndex: pedalIndex),
|
||||||
knobIndex >= 0, knobIndex < pedal.knobs.count else { return }
|
knobIndex >= 0, knobIndex < pedal.ccMappableControls.count else { return }
|
||||||
|
|
||||||
let target: MIDIMap.CCTarget = MIDIMap.CCTarget(
|
let target: MIDIMap.CCTarget = MIDIMap.CCTarget(
|
||||||
boardIndex: boardIndex,
|
boardIndex: boardIndex,
|
||||||
pedalIndex: pedalIndex,
|
pedalIndex: pedalIndex,
|
||||||
knobIndex: knobIndex,
|
knobIndex: knobIndex,
|
||||||
pedalNameHint: pedal.displayName,
|
pedalNameHint: pedal.displayName,
|
||||||
knobLabelHint: pedal.knobs[knobIndex].label
|
knobLabelHint: pedal.ccMappableControls[knobIndex].label
|
||||||
)
|
)
|
||||||
let binding: MIDIMap.CCBinding = MIDIMap.CCBinding(
|
let binding: MIDIMap.CCBinding = MIDIMap.CCBinding(
|
||||||
controller: controller,
|
controller: controller,
|
||||||
@@ -225,8 +221,9 @@ public final class MIDIController {
|
|||||||
)
|
)
|
||||||
|
|
||||||
var map: MIDIMap = shoeGaze.midiMap ?? MIDIMap.empty
|
var map: MIDIMap = shoeGaze.midiMap ?? MIDIMap.empty
|
||||||
// One knob → one CC, and reassigning a CC steals it from any other knob.
|
// One control → one CC, and reassigning a CC (same controller + channel) steals it from any
|
||||||
map.ccs.removeAll { $0.target == target || $0.controller == controller }
|
// other control so a given expression pedal drives exactly one thing.
|
||||||
|
map.ccs.removeAll { $0.target == target || ($0.controller == controller && $0.channel == channel) }
|
||||||
map.ccs.append(binding)
|
map.ccs.append(binding)
|
||||||
shoeGaze.midiMap = map
|
shoeGaze.midiMap = map
|
||||||
onMapChanged?()
|
onMapChanged?()
|
||||||
@@ -245,18 +242,18 @@ public final class MIDIController {
|
|||||||
private func applyCCBinding(_ binding: MIDIMap.CCBinding, value: UInt8) {
|
private func applyCCBinding(_ binding: MIDIMap.CCBinding, value: UInt8) {
|
||||||
let target: MIDIMap.CCTarget = binding.target
|
let target: MIDIMap.CCTarget = binding.target
|
||||||
guard let pedal: Pedal = pedal(boardIndex: target.boardIndex, pedalIndex: target.pedalIndex),
|
guard let pedal: Pedal = pedal(boardIndex: target.boardIndex, pedalIndex: target.pedalIndex),
|
||||||
target.knobIndex >= 0, target.knobIndex < pedal.knobs.count else { return }
|
target.knobIndex >= 0, target.knobIndex < pedal.ccMappableControls.count else { return }
|
||||||
let knob: PedalKnob = pedal.knobs[target.knobIndex]
|
let control: PedalControl = pedal.ccMappableControls[target.knobIndex]
|
||||||
// Stale-binding guard: the chain may have been edited under the positional address.
|
// Stale-binding guard: the chain may have been edited under the positional address.
|
||||||
if let nameHint: String = target.pedalNameHint, nameHint != pedal.displayName { return }
|
if let nameHint: String = target.pedalNameHint, nameHint != pedal.displayName { return }
|
||||||
if let labelHint: String = target.knobLabelHint, labelHint != knob.label { return }
|
if let labelHint: String = target.knobLabelHint, labelHint != control.label { return }
|
||||||
|
|
||||||
let ccMax: Double = 127.0
|
let ccMax: Double = 127.0
|
||||||
var norm: Double = Double(value) / ccMax
|
var norm: Double = Double(value) / ccMax
|
||||||
if binding.inverted { norm = 1.0 - norm }
|
if binding.inverted { norm = 1.0 - norm }
|
||||||
let mapped: Double = knob.range.lowerBound
|
let mapped: Double = control.range.lowerBound
|
||||||
+ norm * (knob.range.upperBound - knob.range.lowerBound)
|
+ norm * (control.range.upperBound - control.range.lowerBound)
|
||||||
knob.node.update(mapped)
|
control.node.update(mapped)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Switch (Program Change) learn + apply
|
// MARK: - Switch (Program Change) learn + apply
|
||||||
|
|||||||
@@ -187,6 +187,22 @@ open class Pedal: SynthesizerBase {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Every continuous control on this pedal that a MIDI Control Change can drive — the pedal's
|
||||||
|
/// knobs (effect knobs + Mix + Level) followed by its vertical-fader sliders. Discrete controls
|
||||||
|
/// (switches, stepped selectors) are excluded; they suit Program Change toggles, not CC sweeps.
|
||||||
|
///
|
||||||
|
/// Ordering is stable — knobs first, then sliders — so a persisted CC binding addressed by index
|
||||||
|
/// keeps resolving to the same control across launches. Used by MIDI mapping.
|
||||||
|
public var ccMappableControls: [PedalControl] {
|
||||||
|
let knobControls: [PedalControl] = knobs.map {
|
||||||
|
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||||
|
}
|
||||||
|
let sliderControls: [PedalControl] = effectSliders.map {
|
||||||
|
PedalControl(label: $0.label, node: $0.node, range: $0.range)
|
||||||
|
}
|
||||||
|
return knobControls + sliderControls
|
||||||
|
}
|
||||||
|
|
||||||
// MARK: - Subclass hook
|
// MARK: - Subclass hook
|
||||||
|
|
||||||
/// Returns the processed (wet) mono signal for this pedal.
|
/// Returns the processed (wet) mono signal for this pedal.
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// PedalControl.swift
|
||||||
|
// Lyrebird
|
||||||
|
//
|
||||||
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import LyrebirdUI
|
||||||
|
|
||||||
|
/// A continuous pedal control that can be driven by a MIDI Control Change — the common shape of a
|
||||||
|
/// ``PedalKnob`` and a ``PedalSlider`` (a labelled `UIParamNode` with a value range).
|
||||||
|
///
|
||||||
|
/// Used by MIDI mapping to enumerate every CC-assignable control on a pedal uniformly, regardless of
|
||||||
|
/// how the pedal chose to present it (rotary knob vs vertical fader). Discrete controls (switches,
|
||||||
|
/// stepped selectors) are intentionally excluded — they suit momentary Program Change bindings, not
|
||||||
|
/// continuous expression control.
|
||||||
|
public struct PedalControl {
|
||||||
|
|
||||||
|
/// Short display label (e.g. `"Rate"`, `"Position"`).
|
||||||
|
public let label: String
|
||||||
|
|
||||||
|
/// The live parameter node the CC drives.
|
||||||
|
public let node: UIParamNode
|
||||||
|
|
||||||
|
/// Inclusive value range the control spans, in the parameter's own units.
|
||||||
|
public let range: ClosedRange<Double>
|
||||||
|
|
||||||
|
/// Creates a pedal control descriptor.
|
||||||
|
///
|
||||||
|
/// - Parameters:
|
||||||
|
/// - label: Short display label.
|
||||||
|
/// - node: The live parameter node.
|
||||||
|
/// - range: Inclusive value range in the parameter's own units.
|
||||||
|
public init(label: String, node: UIParamNode, range: ClosedRange<Double>) {
|
||||||
|
self.label = label
|
||||||
|
self.node = node
|
||||||
|
self.range = range
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,7 +105,9 @@ extension ShoeGaze {
|
|||||||
// routing node — mirrors `appendPedal`'s placement rule.
|
// routing node — mirrors `appendPedal`'s placement rule.
|
||||||
segments.insert(.pedal(newState), at: lastPedalIndex + 1)
|
segments.insert(.pedal(newState), at: lastPedalIndex + 1)
|
||||||
} else {
|
} else {
|
||||||
segments.append(.pedal(newState))
|
// No linear pedals at all: insert-before means the head of the chain, ahead of any
|
||||||
|
// trailing routing region (e.g. a board that is only a stereo split).
|
||||||
|
segments.insert(.pedal(newState), at: 0)
|
||||||
}
|
}
|
||||||
case .left, .right:
|
case .left, .right:
|
||||||
try mutateBranch(&segments, lane: lane) { branch in
|
try mutateBranch(&segments, lane: lane) { branch in
|
||||||
|
|||||||
@@ -12,8 +12,9 @@ import LyrebirdUI
|
|||||||
/// pedal knobs via MIDI Learn.
|
/// pedal knobs via MIDI Learn.
|
||||||
///
|
///
|
||||||
/// Presented from the transport-row ``MIDIIndicatorView``. Rows are generated by walking the live
|
/// Presented from the transport-row ``MIDIIndicatorView``. Rows are generated by walking the live
|
||||||
/// `ShoeGaze.boards` / `board.pedals` / `pedal.knobs`, so bindings address controls positionally.
|
/// `ShoeGaze.boards` / `board.pedals` and each pedal's controls, so bindings address controls
|
||||||
/// (The Program-Change switch section is added in a later phase.)
|
/// positionally. A Switches section binds Program Change to toggle actions; an Expression section
|
||||||
|
/// binds Control Change to continuous pedal controls.
|
||||||
public struct MIDIMappingSheet: View {
|
public struct MIDIMappingSheet: View {
|
||||||
|
|
||||||
// MARK: - Constants
|
// MARK: - Constants
|
||||||
@@ -145,21 +146,29 @@ public struct MIDIMappingSheet: View {
|
|||||||
let boardIndex: Int = boardPair.offset
|
let boardIndex: Int = boardPair.offset
|
||||||
let board: PedalBoard = boardPair.element
|
let board: PedalBoard = boardPair.element
|
||||||
ForEach(Array(board.pedals.enumerated()), id: \.offset) { pedalPair in
|
ForEach(Array(board.pedals.enumerated()), id: \.offset) { pedalPair in
|
||||||
pedalRows(boardIndex: boardIndex, pedalIndex: pedalPair.offset, pedal: pedalPair.element)
|
pedalRows(
|
||||||
|
boardIndex: boardIndex,
|
||||||
|
pedalIndex: pedalPair.offset,
|
||||||
|
pedal: pedalPair.element,
|
||||||
|
boardLabel: board.label
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
private func pedalRows(boardIndex: Int, pedalIndex: Int, pedal: Pedal) -> some View {
|
private func pedalRows(boardIndex: Int, pedalIndex: Int, pedal: Pedal, boardLabel: String) -> some View {
|
||||||
ForEach(Array(pedal.knobs.enumerated()), id: \.offset) { knobPair in
|
// Per-pedal header so each control row can show just its own name.
|
||||||
|
Text("\(boardLabel) · \(pedal.displayName)")
|
||||||
|
.font(.subheadline.weight(.semibold))
|
||||||
|
.foregroundStyle(.secondary)
|
||||||
|
ForEach(Array(pedal.ccMappableControls.enumerated()), id: \.offset) { controlPair in
|
||||||
knobRow(
|
knobRow(
|
||||||
boardIndex: boardIndex,
|
boardIndex: boardIndex,
|
||||||
pedalIndex: pedalIndex,
|
pedalIndex: pedalIndex,
|
||||||
knobIndex: knobPair.offset,
|
knobIndex: controlPair.offset,
|
||||||
pedalName: pedal.displayName,
|
controlLabel: controlPair.element.label
|
||||||
knobLabel: knobPair.element.label
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -168,8 +177,7 @@ public struct MIDIMappingSheet: View {
|
|||||||
boardIndex: Int,
|
boardIndex: Int,
|
||||||
pedalIndex: Int,
|
pedalIndex: Int,
|
||||||
knobIndex: Int,
|
knobIndex: Int,
|
||||||
pedalName: String,
|
controlLabel: String
|
||||||
knobLabel: String
|
|
||||||
) -> some View {
|
) -> some View {
|
||||||
let isArmed: Bool = controller.learnTarget == .cc(
|
let isArmed: Bool = controller.learnTarget == .cc(
|
||||||
boardIndex: boardIndex, pedalIndex: pedalIndex, knobIndex: knobIndex
|
boardIndex: boardIndex, pedalIndex: pedalIndex, knobIndex: knobIndex
|
||||||
@@ -179,7 +187,7 @@ public struct MIDIMappingSheet: View {
|
|||||||
)
|
)
|
||||||
return HStack {
|
return HStack {
|
||||||
VStack(alignment: .leading, spacing: 1) {
|
VStack(alignment: .leading, spacing: 1) {
|
||||||
Text("\(pedalName) · \(knobLabel)")
|
Text(controlLabel)
|
||||||
Text(bindingLabel(isArmed: isArmed, binding: binding))
|
Text(bindingLabel(isArmed: isArmed, binding: binding))
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.foregroundStyle(isArmed ? Color.orange : .secondary)
|
.foregroundStyle(isArmed ? Color.orange : .secondary)
|
||||||
|
|||||||
@@ -191,6 +191,23 @@ struct BoardEditAPITests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func insertIntoRegionOnlyBoardLandsBeforeRegion() throws {
|
||||||
|
// A board with no linear pedals but a trailing split region: inserting at index 0 must place
|
||||||
|
// the pedal at the head of the chain, BEFORE the region — not after it.
|
||||||
|
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||||
|
try makeRig(pedals: [])
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
|
var live: PedalBoard = try sg.appendStereoSplit(to: board) // region-only board
|
||||||
|
live = try sg.insertPedal(.fuzz, at: 0, to: live, lane: .main)
|
||||||
|
|
||||||
|
#expect(names(live) == ["Fuzz"], "the inserted pedal joins the linear chain")
|
||||||
|
guard case .pedal = live.captureState().segments.first else {
|
||||||
|
Issue.record("pedal should be the first segment, ahead of the split region")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test func insertIntoBranchLaneBeforeTarget() throws {
|
@Test func insertIntoBranchLaneBeforeTarget() throws {
|
||||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||||
try makeRig(pedals: ["Overdrive"])
|
try makeRig(pedals: ["Overdrive"])
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ struct MIDIControllerCCTests {
|
|||||||
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: 0)
|
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: 0)
|
||||||
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 0))
|
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 0))
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ struct MIDIControllerCCTests {
|
|||||||
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
let node: UIParamNode = pedal.knobs[0].node
|
let node: UIParamNode = pedal.knobs[0].node
|
||||||
let before: Double = node.value
|
let before: Double = node.value
|
||||||
// No binding learned → an incoming CC must not touch anything.
|
// No binding learned → an incoming CC must not touch anything.
|
||||||
@@ -85,7 +85,7 @@ struct MIDIControllerCCTests {
|
|||||||
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
// Learn on channel 0 (the binding captures that channel).
|
// Learn on channel 0 (the binding captures that channel).
|
||||||
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: 0)
|
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: 0)
|
||||||
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 0))
|
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 0))
|
||||||
@@ -98,6 +98,31 @@ struct MIDIControllerCCTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test func ccCanTargetASliderControl() throws {
|
||||||
|
// A pedal whose controls include vertical-fader sliders (e.g. Graphic EQ bands) must expose
|
||||||
|
// those sliders as CC targets, not only its rotary knobs.
|
||||||
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.05, numAudioBuses: 128)
|
||||||
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
let sg: ShoeGaze = ShoeGaze(engine: engine)
|
||||||
|
let board: PedalBoard = try sg.addBoard()
|
||||||
|
try board.add(GraphicEQPedal())
|
||||||
|
try sg.finalizeBoard(board)
|
||||||
|
let controller: MIDIController = MIDIController(engine: engine, shoeGaze: sg)
|
||||||
|
|
||||||
|
withExtendedLifetime(sg) {
|
||||||
|
let pedal: Pedal = board.pedals[0]
|
||||||
|
#expect(pedal.ccMappableControls.count > pedal.knobs.count, "sliders should be mappable")
|
||||||
|
|
||||||
|
let sliderIndex: Int = pedal.knobs.count // first control past the knobs is a slider
|
||||||
|
let control: PedalControl = pedal.ccMappableControls[sliderIndex]
|
||||||
|
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: sliderIndex)
|
||||||
|
controller.ingestForTesting(.controlChange(channel: 0, controller: 30, value: 0))
|
||||||
|
controller.ingestForTesting(.controlChange(channel: 0, controller: 30, value: 127))
|
||||||
|
#expect(abs(control.node.value - control.range.upperBound) < 1e-9,
|
||||||
|
"CC 127 should drive the slider to its max")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test func clearRemovesBinding() throws {
|
@Test func clearRemovesBinding() throws {
|
||||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
let (controller, sg, _, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
var changed: Bool = false
|
var changed: Bool = false
|
||||||
controller.onMapChanged = { changed = true }
|
controller.onMapChanged = { changed = true }
|
||||||
controller.armSwitchLearn(.rigBypass)
|
controller.armSwitchLearn(.rigBypass)
|
||||||
@@ -51,7 +51,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
controller.armSwitchLearn(.rigBypass)
|
controller.armSwitchLearn(.rigBypass)
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 1)) // learn only
|
controller.ingestForTesting(.programChange(channel: 0, program: 1)) // learn only
|
||||||
#expect(sg.rigBypassed == false, "learn must not toggle")
|
#expect(sg.rigBypassed == false, "learn must not toggle")
|
||||||
@@ -67,7 +67,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, boards, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, boards, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
let node: UIParamNode = boards[0].pedals[0].$bypass
|
let node: UIParamNode = boards[0].pedals[0].$bypass
|
||||||
controller.armSwitchLearn(.pedalBypass(boardIndex: 0, pedalIndex: 0))
|
controller.armSwitchLearn(.pedalBypass(boardIndex: 0, pedalIndex: 0))
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 5)) // learn
|
controller.ingestForTesting(.programChange(channel: 0, program: 5)) // learn
|
||||||
@@ -83,7 +83,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, boards, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, boards, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
controller.armSwitchLearn(.boardBypass(boardIndex: 0))
|
controller.armSwitchLearn(.boardBypass(boardIndex: 0))
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 3)) // learn
|
controller.ingestForTesting(.programChange(channel: 0, program: 3)) // learn
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 3))
|
controller.ingestForTesting(.programChange(channel: 0, program: 3))
|
||||||
@@ -98,7 +98,7 @@ struct MIDIControllerPCTests {
|
|||||||
try makeRig(boardCount: 2)
|
try makeRig(boardCount: 2)
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
controller.armSwitchLearn(.boardSolo(boardIndex: 1))
|
controller.armSwitchLearn(.boardSolo(boardIndex: 1))
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 2)) // learn
|
controller.ingestForTesting(.programChange(channel: 0, program: 2)) // learn
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 2)) // solo board 2
|
controller.ingestForTesting(.programChange(channel: 0, program: 2)) // solo board 2
|
||||||
@@ -112,7 +112,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
controller.armSwitchLearn(.rigBypass)
|
controller.armSwitchLearn(.rigBypass)
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 1)) // learn on ch 0
|
controller.ingestForTesting(.programChange(channel: 0, program: 1)) // learn on ch 0
|
||||||
controller.ingestForTesting(.programChange(channel: 4, program: 1)) // other channel
|
controller.ingestForTesting(.programChange(channel: 4, program: 1)) // other channel
|
||||||
@@ -124,7 +124,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
// Bind to a pedal index that doesn't exist; applying it must be a safe no-op.
|
// Bind to a pedal index that doesn't exist; applying it must be a safe no-op.
|
||||||
controller.armSwitchLearn(.pedalBypass(boardIndex: 0, pedalIndex: 9))
|
controller.armSwitchLearn(.pedalBypass(boardIndex: 0, pedalIndex: 9))
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 6)) // learn
|
controller.ingestForTesting(.programChange(channel: 0, program: 6)) // learn
|
||||||
@@ -137,7 +137,7 @@ struct MIDIControllerPCTests {
|
|||||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||||
defer { try? FileManager.default.removeItem(at: url) }
|
defer { try? FileManager.default.removeItem(at: url) }
|
||||||
|
|
||||||
try withExtendedLifetime(sg) {
|
withExtendedLifetime(sg) {
|
||||||
controller.armSwitchLearn(.rigBypass)
|
controller.armSwitchLearn(.rigBypass)
|
||||||
controller.ingestForTesting(.programChange(channel: 0, program: 8))
|
controller.ingestForTesting(.programChange(channel: 0, program: 8))
|
||||||
controller.armSwitchLearn(.boardBypass(boardIndex: 0))
|
controller.armSwitchLearn(.boardBypass(boardIndex: 0))
|
||||||
|
|||||||
Reference in New Issue
Block a user