Add "All Boards On" as a mappable switch action
Maps the rig's "All" button (selectAllBoards — cancel any solo, bring every board back up) to a Program Change. One-shot (no latch); rig-level, so no board hint. Appears in the Switches section under Rig Bypass. Test: PC fires selectAllBoards, clearing an active solo. 320 green; both app targets build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
Reference in New Issue
Block a user