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:
@@ -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 {
|
||||
let (sg, _, url, board): (ShoeGaze, SynthesisEngine, URL, PedalBoard) =
|
||||
try makeRig(pedals: ["Overdrive"])
|
||||
|
||||
@@ -54,7 +54,7 @@ struct MIDIControllerCCTests {
|
||||
let (controller, sg, pedal, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: 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()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
let node: UIParamNode = pedal.knobs[0].node
|
||||
let before: Double = node.value
|
||||
// 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()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
// Learn on channel 0 (the binding captures that channel).
|
||||
controller.armCCLearn(boardIndex: 0, pedalIndex: 0, knobIndex: 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 {
|
||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, Pedal, URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
@@ -34,7 +34,7 @@ struct MIDIControllerPCTests {
|
||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
var changed: Bool = false
|
||||
controller.onMapChanged = { changed = true }
|
||||
controller.armSwitchLearn(.rigBypass)
|
||||
@@ -51,7 +51,7 @@ struct MIDIControllerPCTests {
|
||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armSwitchLearn(.rigBypass)
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 1)) // learn only
|
||||
#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()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
let node: UIParamNode = boards[0].pedals[0].$bypass
|
||||
controller.armSwitchLearn(.pedalBypass(boardIndex: 0, pedalIndex: 0))
|
||||
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()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armSwitchLearn(.boardBypass(boardIndex: 0))
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 3)) // learn
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 3))
|
||||
@@ -98,7 +98,7 @@ struct MIDIControllerPCTests {
|
||||
try makeRig(boardCount: 2)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armSwitchLearn(.boardSolo(boardIndex: 1))
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 2)) // learn
|
||||
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()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armSwitchLearn(.rigBypass)
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 1)) // learn on ch 0
|
||||
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()
|
||||
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.
|
||||
controller.armSwitchLearn(.pedalBypass(boardIndex: 0, pedalIndex: 9))
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 6)) // learn
|
||||
@@ -137,7 +137,7 @@ struct MIDIControllerPCTests {
|
||||
let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
try withExtendedLifetime(sg) {
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armSwitchLearn(.rigBypass)
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 8))
|
||||
controller.armSwitchLearn(.boardBypass(boardIndex: 0))
|
||||
|
||||
Reference in New Issue
Block a user