8c601e2029
Each board previously got its own TestLoopSource, so multiple boards ran independently-phased arpeggios and any rebuild restarted them out of sync — audible polyrhythms. Now a single global TestLoopSource writes a shared test bus, and each board gets a lightweight TestLoopTap (added .after the source) copying that bus into its head bus. The shared source survives board add/remove, so the test signal stays phase-locked and never restarts. - ShoeGaze: globalTestSource + globalTestBus (lazy via ensureGlobalTestSource), per-board testLoopTaps; teardown removes taps + source and releases the bus. - New TestLoopTap (generic bus copy, like HardwareInputPassThrough). - ShoeGazeError.testBusUnavailable for an exhausted bus pool. - Test: testLoop boards share the source via taps; removal leaves others intact. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
50 lines
1.7 KiB
Swift
50 lines
1.7 KiB
Swift
// TestLoopTap.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import LyrebirdSynth
|
|
|
|
/// Internal synthesizer that copies the shared global test-loop bus to a board head bus.
|
|
///
|
|
/// In `.testLoop` mode every board reads the **same** global ``TestLoopSource`` (so all boards
|
|
/// stay phase-locked instead of each running an independently-phased arpeggio). A `TestLoopTap`
|
|
/// per board reads the global test bus at `inputBusIndex` and writes it to the board's head bus
|
|
/// at `outputBusIndex`, so the first pedal still reads from a board-owned bus.
|
|
///
|
|
/// Added `.after(_:)` the global source so it evaluates once the source has written the test bus
|
|
/// for the current block.
|
|
///
|
|
/// - Note: Must be removed from the engine before the board's `teardown()` releases the head bus.
|
|
final class TestLoopTap: SynthesizerBase {
|
|
|
|
// MARK: - Routing
|
|
|
|
/// Index of the shared global test-loop bus to read from.
|
|
private let inputBusIndex: Int
|
|
|
|
/// Index of the board head bus to write to.
|
|
private let outputBusIndex: Int
|
|
|
|
// MARK: - Init
|
|
|
|
/// Creates a tap that copies `inputBusIndex` (the global test bus) to `outputBusIndex`
|
|
/// (a board head bus).
|
|
///
|
|
/// - Parameters:
|
|
/// - inputBusIndex: Shared global test-loop bus index to read from.
|
|
/// - outputBusIndex: Board head bus index to write to.
|
|
init(inputBusIndex: Int, outputBusIndex: Int) {
|
|
self.inputBusIndex = inputBusIndex
|
|
self.outputBusIndex = outputBusIndex
|
|
super.init()
|
|
}
|
|
|
|
// MARK: - Build
|
|
|
|
override func build() {
|
|
output(bus: outputBusIndex, source: input(bus: inputBusIndex))
|
|
}
|
|
}
|