c0605d295d
Multi-board playback was all-or-one: selectBoard soloed exclusively, selectAllBoards summed. There was no way to play an arbitrary subset, and the builder only exposed a dropdown that picked which board to *edit*. ShoeGaze API: - setBoard(_:audible:crossfadeSeconds:) toggles one board's select-gain in place without disturbing the others (Blend mixing); clears activeBoardIndex. - soloBoard(_:crossfadeSeconds:) — the "Solo" verb (wraps selectBoard). - isBoardAudible(_:) reports a board's live select-gain target. UI — BoardBarView (shared macOS/iOS): - Horizontal board-mixer strip. Each board is a channel cell: audible LED, Solo button, and a master-gain fader. Tapping a cell name sets the edit target (independent of what's audible); context menu silences/deletes. - Solo | Blend mode switch + an All button + a crossfade slider. - Replaces the builder's board dropdown and Add Board button; the cell's + adds a board. Tests: solo/blend/all audibility transitions and activeBoardIndex tracking; setBoard no-op for a board owned by another manager. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
172 lines
6.4 KiB
Swift
172 lines
6.4 KiB
Swift
// ShoeGazeMultiBoardTests.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Testing
|
|
import Foundation
|
|
import LyrebirdSynth
|
|
import LyrebirdUI
|
|
@testable import LyrebirdShoeGaze
|
|
|
|
@MainActor
|
|
@Suite("ShoeGaze multi-board")
|
|
struct ShoeGazeMultiBoardTests {
|
|
|
|
@Test func addBoardAssignsLabelAndFinalizeWiresMasterNode() throws {
|
|
let renderDuration: Double = 0.05
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
|
duration: renderDuration,
|
|
numAudioBuses: 64
|
|
)
|
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
|
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
|
|
|
let board1: PedalBoard = try shoeGaze.addBoard()
|
|
#expect(board1.label == "Board 1")
|
|
#expect(board1.masterGainNode == nil, "Master node is nil until finalizeBoard")
|
|
try board1.add(OverdrivePedal())
|
|
try shoeGaze.finalizeBoard(board1)
|
|
#expect(board1.masterGainNode != nil, "finalizeBoard must expose the master gain node")
|
|
|
|
let board2: PedalBoard = try shoeGaze.addBoard()
|
|
#expect(board2.label == "Board 2")
|
|
try board2.add(DelayPedal())
|
|
try shoeGaze.finalizeBoard(board2)
|
|
|
|
#expect(shoeGaze.boards.count == 2)
|
|
}
|
|
|
|
@Test func soloBlendAndAllControlBoardAudibility() throws {
|
|
let renderDuration: Double = 0.05
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
|
duration: renderDuration,
|
|
numAudioBuses: 64
|
|
)
|
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
|
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
|
|
|
let board1: PedalBoard = try shoeGaze.addBoard()
|
|
try board1.add(OverdrivePedal())
|
|
try shoeGaze.finalizeBoard(board1)
|
|
let board2: PedalBoard = try shoeGaze.addBoard()
|
|
try board2.add(DelayPedal())
|
|
try shoeGaze.finalizeBoard(board2)
|
|
let board3: PedalBoard = try shoeGaze.addBoard()
|
|
try board3.add(OverdrivePedal())
|
|
try shoeGaze.finalizeBoard(board3)
|
|
|
|
let instantCrossfade: Double = 0.0
|
|
|
|
// Default: every board audible, no solo.
|
|
#expect(shoeGaze.isBoardAudible(board1))
|
|
#expect(shoeGaze.isBoardAudible(board2))
|
|
#expect(shoeGaze.isBoardAudible(board3))
|
|
#expect(shoeGaze.activeBoardIndex == nil)
|
|
|
|
// Solo board2 — exclusive.
|
|
shoeGaze.soloBoard(board2, crossfadeSeconds: instantCrossfade)
|
|
#expect(!shoeGaze.isBoardAudible(board1))
|
|
#expect(shoeGaze.isBoardAudible(board2))
|
|
#expect(!shoeGaze.isBoardAudible(board3))
|
|
#expect(shoeGaze.activeBoardIndex == 1)
|
|
|
|
// Blend: re-enable board1 without disturbing the others, and clear the solo index.
|
|
shoeGaze.setBoard(board1, audible: true, crossfadeSeconds: instantCrossfade)
|
|
#expect(shoeGaze.isBoardAudible(board1))
|
|
#expect(shoeGaze.isBoardAudible(board2))
|
|
#expect(!shoeGaze.isBoardAudible(board3))
|
|
#expect(shoeGaze.activeBoardIndex == nil)
|
|
|
|
// Silence a single board.
|
|
shoeGaze.setBoard(board1, audible: false, crossfadeSeconds: instantCrossfade)
|
|
#expect(!shoeGaze.isBoardAudible(board1))
|
|
#expect(shoeGaze.isBoardAudible(board2))
|
|
|
|
// All back to summed.
|
|
shoeGaze.selectAllBoards(crossfadeSeconds: instantCrossfade)
|
|
#expect(shoeGaze.isBoardAudible(board1))
|
|
#expect(shoeGaze.isBoardAudible(board2))
|
|
#expect(shoeGaze.isBoardAudible(board3))
|
|
#expect(shoeGaze.activeBoardIndex == nil)
|
|
}
|
|
|
|
@Test func setBoardIgnoresUnmanagedBoard() throws {
|
|
let renderDuration: Double = 0.05
|
|
let (engineA, urlA): (SynthesisEngine, URL) = makeNRTEngine(duration: renderDuration, numAudioBuses: 64)
|
|
let (engineB, urlB): (SynthesisEngine, URL) = makeNRTEngine(duration: renderDuration, numAudioBuses: 64)
|
|
defer {
|
|
try? FileManager.default.removeItem(at: urlA)
|
|
try? FileManager.default.removeItem(at: urlB)
|
|
}
|
|
|
|
let shoeGazeA: ShoeGaze = ShoeGaze(engine: engineA)
|
|
let shoeGazeB: ShoeGaze = ShoeGaze(engine: engineB)
|
|
|
|
let boardA: PedalBoard = try shoeGazeA.addBoard()
|
|
try boardA.add(OverdrivePedal())
|
|
try shoeGazeA.finalizeBoard(boardA)
|
|
let boardB: PedalBoard = try shoeGazeB.addBoard()
|
|
try boardB.add(DelayPedal())
|
|
try shoeGazeB.finalizeBoard(boardB)
|
|
|
|
// Toggling a board not owned by this manager is a no-op and must not change state.
|
|
shoeGazeA.setBoard(boardB, audible: false, crossfadeSeconds: 0.0)
|
|
#expect(shoeGazeA.isBoardAudible(boardA))
|
|
#expect(shoeGazeB.isBoardAudible(boardB))
|
|
}
|
|
|
|
@Test func removeBoardLeavesOtherBoards() throws {
|
|
let renderDuration: Double = 0.05
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
|
duration: renderDuration,
|
|
numAudioBuses: 64
|
|
)
|
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
|
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
|
|
|
let board1: PedalBoard = try shoeGaze.addBoard()
|
|
try board1.add(OverdrivePedal())
|
|
try shoeGaze.finalizeBoard(board1)
|
|
|
|
let board2: PedalBoard = try shoeGaze.addBoard()
|
|
try board2.add(DelayPedal())
|
|
try shoeGaze.finalizeBoard(board2)
|
|
|
|
#expect(shoeGaze.boards.count == 2)
|
|
|
|
shoeGaze.removeBoard(board1)
|
|
#expect(shoeGaze.boards.count == 1)
|
|
#expect(shoeGaze.boards.first === board2, "Remaining board must be the one not removed")
|
|
}
|
|
|
|
@Test func twoBoardsRenderNonSilent() throws {
|
|
let renderDuration: Double = 0.2
|
|
let (engine, url): (SynthesisEngine, URL) = makeNRTEngine(
|
|
duration: renderDuration,
|
|
numAudioBuses: 64
|
|
)
|
|
defer { try? FileManager.default.removeItem(at: url) }
|
|
|
|
let shoeGaze: ShoeGaze = ShoeGaze(engine: engine)
|
|
|
|
let board1: PedalBoard = try shoeGaze.addBoard()
|
|
try board1.add(OverdrivePedal())
|
|
try shoeGaze.finalizeBoard(board1)
|
|
|
|
let board2: PedalBoard = try shoeGaze.addBoard()
|
|
try board2.add(DelayPedal())
|
|
try shoeGaze.finalizeBoard(board2)
|
|
|
|
try engine.start()
|
|
|
|
let samples: [Float] = readStereoCAF(url: url)
|
|
#expect(!samples.isEmpty, "Two-board ShoeGaze produced no samples")
|
|
#expect(hasNonSilentOutput(samples), "Two-board ShoeGaze produced silence")
|
|
}
|
|
}
|