diff --git a/Sources/LyrebirdShoeGaze/MIDI/MIDIController.swift b/Sources/LyrebirdShoeGaze/MIDI/MIDIController.swift index 33353b8..0f5a7c6 100644 --- a/Sources/LyrebirdShoeGaze/MIDI/MIDIController.swift +++ b/Sources/LyrebirdShoeGaze/MIDI/MIDIController.swift @@ -317,6 +317,9 @@ public final class MIDIController { switch action { case .rigBypass: shoeGaze.toggleRigBypassed() + case .allBoards: + // One-shot: cancel any solo and bring every board back up. + shoeGaze.selectAllBoards(crossfadeSeconds: boardActionCrossfade) case .boardSolo(let boardIndex): guard let board: PedalBoard = board(at: boardIndex), matchesBoard(board, hint) else { return } shoeGaze.soloBoard(board, crossfadeSeconds: boardActionCrossfade) @@ -339,7 +342,7 @@ public final class MIDIController { /// A display-name hint for an action, captured at learn time for stale-binding detection. private func hint(for action: MIDIMap.Action) -> String? { switch action { - case .rigBypass: + case .rigBypass, .allBoards: return nil case .boardSolo(let index), .boardAudible(let index), .boardBypass(let index): return board(at: index)?.label diff --git a/Sources/LyrebirdShoeGaze/MIDI/MIDIMap.swift b/Sources/LyrebirdShoeGaze/MIDI/MIDIMap.swift index 9e22b9b..417fe8f 100644 --- a/Sources/LyrebirdShoeGaze/MIDI/MIDIMap.swift +++ b/Sources/LyrebirdShoeGaze/MIDI/MIDIMap.swift @@ -41,6 +41,8 @@ public struct MIDIMap: Codable, Equatable, Sendable { /// so boolean actions latch in software; `boardSolo` is exclusive (radio). public enum Action: Codable, Equatable, Sendable { case rigBypass + /// Cancels any solo and makes every board audible again (the "All" button). + case allBoards case boardSolo(boardIndex: Int) case boardAudible(boardIndex: Int) case boardBypass(boardIndex: Int) diff --git a/Sources/LyrebirdShoeGazeUI/MIDIMappingSheet.swift b/Sources/LyrebirdShoeGazeUI/MIDIMappingSheet.swift index e2375fb..e355a5d 100644 --- a/Sources/LyrebirdShoeGazeUI/MIDIMappingSheet.swift +++ b/Sources/LyrebirdShoeGazeUI/MIDIMappingSheet.swift @@ -99,6 +99,7 @@ public struct MIDIMappingSheet: View { private var switchRowModels: [SwitchRowModel] { var rows: [SwitchRowModel] = [ SwitchRowModel(id: "sw-rig", action: .rigBypass, label: "Rig Bypass"), + SwitchRowModel(id: "sw-all", action: .allBoards, label: "All Boards On"), ] for boardPair in shoeGaze.boards.enumerated() { let boardIndex: Int = boardPair.offset diff --git a/Tests/LyrebirdShoeGazeTests/MIDIControllerPCTests.swift b/Tests/LyrebirdShoeGazeTests/MIDIControllerPCTests.swift index 41cddbe..c7ce353 100644 --- a/Tests/LyrebirdShoeGazeTests/MIDIControllerPCTests.swift +++ b/Tests/LyrebirdShoeGazeTests/MIDIControllerPCTests.swift @@ -108,6 +108,26 @@ struct MIDIControllerPCTests { } } + @Test func allBoardsActionCancelsSolo() throws { + let (controller, sg, boards, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = + try makeRig(boardCount: 2) + defer { try? FileManager.default.removeItem(at: url) } + + withExtendedLifetime(sg) { + // Solo board 2 first, then map + fire the All-Boards action. + sg.soloBoard(boards[1], crossfadeSeconds: 0) + #expect(sg.activeBoardIndex == 1) + + controller.armSwitchLearn(.allBoards) + controller.ingestForTesting(.programChange(channel: 0, program: 4)) // learn + controller.ingestForTesting(.programChange(channel: 0, program: 4)) // fire + + #expect(sg.activeBoardIndex == nil, "All Boards should clear the solo") + #expect(sg.isBoardAudible(boards[0]) == true) + #expect(sg.isBoardAudible(boards[1]) == true) + } + } + @Test func channelFilterBlocksOtherChannels() throws { let (controller, sg, _, url): (MIDIController, ShoeGaze, [PedalBoard], URL) = try makeRig() defer { try? FileManager.default.removeItem(at: url) }