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:
2026-07-01 08:34:30 -07:00
parent 1893576718
commit ae8f370fa8
8 changed files with 149 additions and 46 deletions
@@ -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) }