add scope for debugging
This commit is contained in:
@@ -53,5 +53,56 @@ extension ShoeGaze {
|
||||
}
|
||||
|
||||
try rebuildAllBoards(from: snapshot)
|
||||
|
||||
// The tapped bus indices depend on the channel layout (input buses follow the output
|
||||
// buses), so rebuild the scope tap for the new configuration.
|
||||
installScopeTap()
|
||||
}
|
||||
|
||||
/// Default samples-per-frame captured by the scope tap.
|
||||
public static let defaultScopeBufferSize: Int = 2_048
|
||||
|
||||
/// (Re)builds the ``scopeTap`` over the current hardware input + output buses and assigns it
|
||||
/// to the engine, so the debug scope view can visualise both the live input signal and the
|
||||
/// board output.
|
||||
///
|
||||
/// Lane order is **inputs first** (`In 0`, `In 1`, …) then **outputs** (`Out L`, `Out R`, …),
|
||||
/// so the input waveform sits at the top of the scope. Must be called while the engine is
|
||||
/// stopped — `SynthesisEngine` caches its scope tap at `start()`. Rebuilt automatically by
|
||||
/// ``reconfigureEngine(sampleRate:inputChannels:outputChannels:)`` and at init.
|
||||
///
|
||||
/// - Parameter bufferSize: Samples per channel per display frame. Defaults to 2048.
|
||||
public func installScopeTap(bufferSize: Int = ShoeGaze.defaultScopeBufferSize) {
|
||||
let numOut: Int = engine.numOutputChannels
|
||||
let numIn: Int = engine.numInputChannels
|
||||
|
||||
var buses: [Int] = []
|
||||
for ch: Int in 0..<numIn { buses.append(numOut + ch) } // hardware inputs (top lanes)
|
||||
for ch: Int in 0..<numOut { buses.append(ch) } // outputs (lower lanes)
|
||||
|
||||
guard !buses.isEmpty else {
|
||||
engine.scopeTap = nil
|
||||
scopeTap = nil
|
||||
return
|
||||
}
|
||||
|
||||
let capture: ScopeCapture = ScopeCapture(buses: buses, bufferSize: bufferSize)
|
||||
engine.scopeTap = capture
|
||||
scopeTap = capture
|
||||
}
|
||||
|
||||
/// Human-readable label for a tapped audio-bus index under the current engine layout.
|
||||
///
|
||||
/// Output buses (`bus < numOutputChannels`) are `Out L` / `Out R` / `Out N`; the remaining
|
||||
/// buses are hardware inputs `In 0`, `In 1`, … Used by the scope view to label each lane.
|
||||
///
|
||||
/// - Parameter bus: An audio-bus index, typically one of ``scopeTap``'s `buses`.
|
||||
public func scopeLaneLabel(forBus bus: Int) -> String {
|
||||
let numOut: Int = engine.numOutputChannels
|
||||
guard bus >= numOut else {
|
||||
let stereoNames: [String] = ["Out L", "Out R"]
|
||||
return bus < stereoNames.count ? stereoNames[bus] : "Out \(bus)"
|
||||
}
|
||||
return "In \(bus - numOut)"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,16 @@ public final class ShoeGaze {
|
||||
/// (same module, different file) can mutate it.
|
||||
internal var recordTaps: [RecordTap] = []
|
||||
|
||||
// MARK: - Scope state
|
||||
|
||||
/// Scope tap over the hardware input + output buses, feeding the debug scope view.
|
||||
///
|
||||
/// Rebuilt by ``installScopeTap(bufferSize:)`` whenever the engine layout changes (so the
|
||||
/// tapped bus indices follow the current input/output channel counts). `nil` until first
|
||||
/// installed. The setter is `internal` so ``installScopeTap(bufferSize:)`` (same module,
|
||||
/// different file) can assign it; external callers observe it through this `public` getter.
|
||||
public internal(set) var scopeTap: ScopeCapture?
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private var testLoopSources: [TestLoopSource] = []
|
||||
@@ -110,6 +120,7 @@ public final class ShoeGaze {
|
||||
) {
|
||||
self.engine = engine
|
||||
self.inputSource = inputSource
|
||||
installScopeTap()
|
||||
}
|
||||
|
||||
// MARK: - Board management
|
||||
|
||||
Reference in New Issue
Block a user