Compare commits
2 Commits
2772abdc56
...
v2.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| f61961b90b | |||
| 7e39842eb2 |
+2
-1
@@ -19,7 +19,8 @@ its MIDI / key binding right on the pedal.
|
||||
derived from the shared tempo, following tap tempo, the stepper, the BPM field, and
|
||||
MIDI. Delay time on Delay, Feedback Delay, Ping-Pong, Reverse Delay, and each of
|
||||
Multi-Tap's three taps; LFO rate on Tremolo, Vibrato, Chorus, Flanger, Phaser, and
|
||||
Modulation.
|
||||
Modulation. A MIDI CC bound to a synced parameter is ignored while it stays synced
|
||||
(the tempo drives the value) and resumes control once the parameter is set to Free.
|
||||
- **Note-value glyphs.** The division picker uses drawn music-notation glyphs —
|
||||
noteheads, stems, flags, an augmentation dot for dotted values, and a bracketed "3"
|
||||
over triplets — instead of text labels.
|
||||
|
||||
@@ -18,6 +18,8 @@ badges on every pedal.
|
||||
- **Longer delays** — maximum delay time raised to 5 s so slow synced values fit.
|
||||
- **Control mapping badges** — every pedal shows the PC (footswitch), CC (expression),
|
||||
or KEY (letter key) binding on each control, with a legend above the board.
|
||||
- **CC respects tempo sync** — a CC bound to a synced parameter is ignored while synced
|
||||
(the tempo drives it) and resumes control once the parameter is set back to Free.
|
||||
|
||||
### Compatibility
|
||||
Additive persistence — older rigs load unchanged (every parameter defaults to free),
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user