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
+10
View File
@@ -4,6 +4,16 @@ All notable changes to ShoeGaze are recorded here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
[semantic versioning](https://semver.org/spec/v2.0.0.html).
## [2.1.1] — 2026-07-10
### Fixed
- **MIDI CC no longer fights tempo sync.** A Control Change bound to a pedal parameter
that is locked to a note division is ignored while synced — the value is derived from
the tempo, so a CC write would be overwritten on the next tempo change. The binding
stays intact (its slot index is unchanged, so other bindings are unaffected) and
resumes control the moment the parameter is set back to Free.
## [2.1.0] — 2026-07-10
Tempo comes to the pedals. Delay times and modulation rates can lock to a note
+7
View File
@@ -1,4 +1,11 @@
# Releases
## ShoeGaze 2.1.1
### Fixed
- **MIDI CC vs. tempo sync** — a CC bound to a parameter locked to a note division is
ignored while synced (the tempo drives the value); the binding stays intact and
resumes control once the parameter is set back to Free.
## ShoeGaze 2.1.0
Tempo comes to the pedals. Delay times and LFO rates can lock to note divisions of the
@@ -250,6 +250,14 @@ public final class MIDIController {
continue
}
guard let resolved: ResolvedCC = resolveCC(binding.target) else { continue }
// A parameter locked to a note division is driven by the tempo; a CC write would be
// overwritten on the next tempo change, so ignore it here. The binding stays intact and
// resumes control the moment the parameter is set back to Free.
if case let .pedalControl(pedalID, _, _, _) = binding.target,
let pedal: Pedal = pedal(id: pedalID),
pedal.isNodeTempoSynced(resolved.node) {
continue
}
let mapped: Double = resolved.range.lowerBound
+ norm * (resolved.range.upperBound - resolved.range.lowerBound)
resolved.node.update(mapped)
+14
View File
@@ -316,6 +316,20 @@ open class Pedal: SynthesizerBase {
applyTempoSync()
}
/// Whether `node` backs a tempo-syncable parameter currently locked to a note division.
///
/// Used by MIDI to leave a synced parameter alone: its value is derived from the tempo, so a CC
/// write would be immediately overwritten on the next tempo change. Matches by node identity, so
/// it stays correct regardless of control ordering. Returns `false` for a free or non-syncable node.
public func isNodeTempoSynced(_ node: UIParamNode) -> Bool {
for param: TempoSyncableParam in tempoSyncableParams where param.node === node {
if case .division = tempoSync[param.key] ?? .free {
return true
}
}
return false
}
// MARK: - Subclass hook
/// Returns the processed (wet) mono signal for this pedal.
@@ -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) }
+10 -8
View File
@@ -181,15 +181,17 @@ For each param that appears in `tempoSyncableParams`:
- Gate the whole affordance on the `shoeGazeTempoEnabled` environment flag — when tempo is
off, only the plain knob shows.
### MIDI — deferred
### MIDI — implemented (inert while synced)
A synced param's value is derived, so a CC bound to it is overwritten on the next tempo/division
change. The obvious fix — dropping `.division`-synced params from `ccMappableControls` — is
**deferred**: that list is addressed by a *stable index* (persisted CC bindings resolve by position),
so filtering it live would shift indices and silently re-point or break existing bindings. A correct
implementation needs an index-stable exclusion (e.g. keep the slot but mark it inert while synced),
which is out of scope for this change. Until then, binding a CC to a synced param is allowed but the
tempo wins — documented here as a known limitation, not an oversight.
A synced param's value is derived, so a CC bound to it would be overwritten on the next
tempo/division change. Rather than drop `.division`-synced params from `ccMappableControls` —
which is addressed by a *stable index* (persisted CC bindings resolve by position), so filtering it
live would shift indices and break existing bindings — the exclusion is **index-stable**: the slot
stays, and the CC *write* is skipped while the target parameter is division-synced.
`MIDIController.applyCC` checks `Pedal.isNodeTempoSynced(_:)` (node-identity match against
`tempoSyncableParams`) and ignores the incoming CC for a synced control; the binding stays intact and
resumes control the moment the parameter is set back to Free. Learning/binding a CC to a synced
param is still allowed — the tempo simply wins while synced.
## Testing