2.1.1: ignore MIDI CC on tempo-synced parameters

A CC bound to a pedal parameter locked to a note division is now ignored while
synced — the value is tempo-derived and a CC write would be overwritten on the next
tempo change. Index-stable: ccMappableControls is unchanged (persisted bindings resolve
by position), and only the CC *write* is skipped. MIDIController.applyCC checks
Pedal.isNodeTempoSynced(_:) (node-identity match against tempoSyncableParams) and
skips the update; the binding stays intact and resumes control once set back to Free.

Test: MIDIControllerCCTests.ccIsIgnoredWhileParameterIsTempoSynced. 455 tests pass.
Docs: CHANGELOG.md, RELEASES.md, plan MIDI section updated to "implemented".

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-10 08:55:33 -07:00
parent 2772abdc56
commit 7e39842eb2
6 changed files with 85 additions and 8 deletions
@@ -181,6 +181,42 @@ struct MIDIControllerCCTests {
}
}
@Test func ccIsIgnoredWhileParameterIsTempoSynced() throws {
// A CC bound to a parameter that is locked to a note division must be ignored — the value is
// tempo-derived and a CC write would be overwritten on the next tempo change. The binding
// stays intact and resumes control once the parameter is set back to Free.
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.05, numAudioBuses: 128)
defer { try? FileManager.default.removeItem(at: url) }
let sg: ShoeGaze = ShoeGaze(engine: engine)
sg.clock.bpm = 120.0
let board: PedalBoard = try sg.addBoard()
let delay: DelayPedal = DelayPedal()
try board.add(delay)
try sg.finalizeBoard(board)
let controller: MIDIController = MIDIController(engine: engine, shoeGaze: sg)
withExtendedLifetime(sg) {
// Bind CC 21 to Time (control 0 on a Delay pedal).
controller.armCCLearn(pedalControl(delay.id, 0))
controller.ingestForTesting(.controlChange(channel: 0, controller: 21, value: 0))
// Lock Time to a quarter note — 0.5 s at 120 BPM.
delay.setSync(.division(.quarter), for: "time")
let syncedValue: Double = delay.$time.value
#expect(abs(syncedValue - 0.5) < 1e-9)
// A CC while synced must not move the value.
controller.ingestForTesting(.controlChange(channel: 0, controller: 21, value: 127))
#expect(abs(delay.$time.value - syncedValue) < 1e-9, "CC must not drive a tempo-synced parameter")
// Back to Free — the same binding drives the control again.
delay.setSync(.free, for: "time")
let timeMax: Double = delay.ccMappableControls[0].range.upperBound
controller.ingestForTesting(.controlChange(channel: 0, controller: 21, value: 127))
#expect(abs(delay.$time.value - timeMax) < 1e-9, "CC resumes control once the parameter is Free")
}
}
@Test func unboundCCIsIgnored() throws {
let (controller, sg, board, url): (MIDIController, ShoeGaze, PedalBoard, URL) = try makeRig()
defer { try? FileManager.default.removeItem(at: url) }