Looper: MIDI-mappable A/B/C/D track taps
Add looperTrack(index:) PedalActionKind dispatched to LooperPedal.tapTrack, and Track A–D rows in the MIDI mapping sheet (one per track, up to trackCount). A mapped switch/Program Change taps the dot — selecting the track, or muting it when it's already selected and recorded — matching the timeline dots. Covered by pedalActionTapsLooperTrack. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -403,6 +403,8 @@ public final class MIDIController {
|
||||
(pedal as? LooperPedal)?.toggleReverse()
|
||||
case .looperSyncToggle:
|
||||
(pedal as? LooperPedal)?.cycleSyncMode()
|
||||
case .looperTrack(let index):
|
||||
(pedal as? LooperPedal)?.tapTrack(index)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,9 @@ public struct MIDIMap: Codable, Equatable, Sendable {
|
||||
case looperReverse
|
||||
/// Looper: cycles the Sync/Free transport mode (`LooperPedal.cycleSyncMode()`).
|
||||
case looperSyncToggle
|
||||
/// Looper: taps track `index` (0 = A) — selects it, or mutes it if already selected and
|
||||
/// recorded (`LooperPedal.tapTrack(_:)`), matching the A/B/C/D dots.
|
||||
case looperTrack(index: Int)
|
||||
}
|
||||
|
||||
// MARK: - Switch binding
|
||||
|
||||
@@ -120,7 +120,7 @@ public struct MIDIMappingSheet: View {
|
||||
label: "\(board.label) · \(pedal.displayName) · Bypass"))
|
||||
// Loopers expose their transport footswitches as mappable switch actions.
|
||||
if pedal is LooperPedal {
|
||||
let looperActions: [(String, String, MIDIMap.PedalActionKind)] = [
|
||||
var looperActions: [(String, String, MIDIMap.PedalActionKind)] = [
|
||||
("rec", "Record", .looperRecordStop),
|
||||
("stop", "Stop", .looperStop),
|
||||
("cue", "Cue Stop", .looperCueStop),
|
||||
@@ -128,6 +128,11 @@ public struct MIDIMappingSheet: View {
|
||||
("sync", "Sync", .looperSyncToggle),
|
||||
("reset", "Reset", .looperReset),
|
||||
]
|
||||
// A/B/C/D track taps (select / mute), matching the timeline dots.
|
||||
for i: Int in 0 ..< LooperPedal.trackCount {
|
||||
let letter: String = LooperPedal.trackLabel(i)
|
||||
looperActions.append(("track\(letter)", "Track \(letter)", .looperTrack(index: i)))
|
||||
}
|
||||
for (slug, name, kind): (String, String, MIDIMap.PedalActionKind) in looperActions {
|
||||
rows.append(SwitchRowModel(
|
||||
id: "sw-la-\(slug)-\(pedal.id)",
|
||||
|
||||
@@ -306,4 +306,31 @@ struct MIDIControllerPCTests {
|
||||
#expect(looper.syncToBeat == 0.0, "mapped Program Change should oscillate Sync through its options")
|
||||
}
|
||||
}
|
||||
|
||||
@Test func pedalActionTapsLooperTrack() throws {
|
||||
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(duration: 0.05, numAudioBuses: 256)
|
||||
let sg: ShoeGaze = ShoeGaze(engine: engine)
|
||||
let board: PedalBoard = try sg.addBoard()
|
||||
let looper: LooperPedal = LooperPedal()
|
||||
try board.add(looper)
|
||||
try sg.finalizeBoard(board)
|
||||
let controller: MIDIController = MIDIController(engine: engine, shoeGaze: sg)
|
||||
defer { try? FileManager.default.removeItem(at: url) }
|
||||
|
||||
withExtendedLifetime(sg) {
|
||||
// Get a recorded, selected track A (immediate transport).
|
||||
looper.clock = nil
|
||||
looper.pressLoop()
|
||||
looper.pressLoop()
|
||||
#expect(looper.trackHasContent(0))
|
||||
#expect(!looper.isTrackMuted(0))
|
||||
|
||||
controller.armSwitchLearn(.pedalAction(pedalID: looper.id, kind: .looperTrack(index: 0)))
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 22)) // learn only
|
||||
#expect(!looper.isTrackMuted(0))
|
||||
|
||||
controller.ingestForTesting(.programChange(channel: 0, program: 22)) // fire → tapTrack(0) → mute A
|
||||
#expect(looper.isTrackMuted(0), "mapped Program Change should tap (mute) the selected recorded track")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user