Add per-binding CC invert toggle
Each CC binding gains an "Invert" toggle in the mapping sheet (shown once the control is bound). Inverting swaps the sweep — CC 0 drives the control to its max, 127 to its min — so a single expression pedal can crossfade two controls: map both to the same CC and invert one. The MIDICCBinding.inverted field and applyCC already honored inversion; this adds isCCInverted / setCCInverted plus the sheet toggle, and the binding label now notes "· inverted". Test: an inverted binding reverses the mapped output. 321 green; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -121,6 +121,24 @@ struct MIDIControllerCCTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test func invertedCCReversesTheSweep() throws {
|
||||
let (controller, sg, board, url): (MIDIController, ShoeGaze, PedalBoard, URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
withExtendedLifetime(sg) {
|
||||
controller.armCCLearn(pedalControl(0, 0, 0))
|
||||
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 0))
|
||||
controller.setCCInverted(for: pedalControl(0, 0, 0), true)
|
||||
#expect(controller.isCCInverted(for: pedalControl(0, 0, 0)))
|
||||
|
||||
let node: UIParamNode = board.pedals[0].ccMappableControls[0].node
|
||||
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 127))
|
||||
#expect(abs(node.value - 0.0) < 1e-9, "inverted CC 127 should map to the control min")
|
||||
controller.ingestForTesting(.controlChange(channel: 0, controller: 20, value: 0))
|
||||
#expect(abs(node.value - 1.0) < 1e-9, "inverted CC 0 should map to the control max")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func unboundCCIsIgnored() throws {
|
||||
let (controller, sg, board, url): (MIDIController, ShoeGaze, PedalBoard, URL) = try makeRig()
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
Reference in New Issue
Block a user