add scope for debugging
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
// ShoeGazeScopeView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import LyrebirdSynth
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
/// Oscilloscope panel showing the live input and board-output waveforms.
|
||||
///
|
||||
/// Wraps Lyrebird's `LyrebirdScopeView` bound to ``ShoeGaze/scopeTap`` and adds a labelled
|
||||
/// legend so each lane is identifiable (`In 0`, `Out L`, `Out R`, …) — input lanes on top,
|
||||
/// outputs below. Use it to confirm signal flow: a flat input lane with audible test-tone
|
||||
/// output means the live input never reaches the board head bus; a live input lane with a flat
|
||||
/// output lane points downstream.
|
||||
///
|
||||
/// The lane colours match `LyrebirdScopeView` (cyan, orange, green, yellow, cycling). The view
|
||||
/// keys itself on the tap's object identity so a reconfigure that rebuilds the tap recreates the
|
||||
/// underlying scope.
|
||||
public struct ShoeGazeScopeView: View {
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
/// Colours used by `LyrebirdScopeView`, mirrored here for the legend swatches.
|
||||
private static let laneColors: [Color] = [.cyan, .orange, .green, .yellow]
|
||||
private static let scopeHeight: CGFloat = 120
|
||||
private static let legendSpacing: CGFloat = 14
|
||||
private static let swatchSize: CGFloat = 9
|
||||
private static let panelSpacing: CGFloat = 6
|
||||
private static let labelOpacity: Double = 0.75
|
||||
|
||||
// MARK: - Properties
|
||||
|
||||
private let shoeGaze: ShoeGaze
|
||||
|
||||
// MARK: - Init
|
||||
|
||||
/// - Parameter shoeGaze: The session whose ``ShoeGaze/scopeTap`` is visualised.
|
||||
public init(shoeGaze: ShoeGaze) {
|
||||
self.shoeGaze = shoeGaze
|
||||
}
|
||||
|
||||
// MARK: - Body
|
||||
|
||||
public var body: some View {
|
||||
VStack(alignment: .leading, spacing: ShoeGazeScopeView.panelSpacing) {
|
||||
if let capture: ScopeCapture = shoeGaze.scopeTap {
|
||||
legend(for: capture)
|
||||
LyrebirdScopeView(capture: capture)
|
||||
.frame(height: ShoeGazeScopeView.scopeHeight)
|
||||
.id(ObjectIdentifier(capture))
|
||||
} else {
|
||||
Text("Scope unavailable")
|
||||
.font(.caption)
|
||||
.foregroundStyle(Color.white.opacity(ShoeGazeScopeView.labelOpacity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Legend
|
||||
|
||||
/// A horizontal legend mapping each lane colour to its bus label.
|
||||
private func legend(for capture: ScopeCapture) -> some View {
|
||||
HStack(spacing: ShoeGazeScopeView.legendSpacing) {
|
||||
ForEach(Array(capture.buses.enumerated()), id: \.offset) { index, bus in
|
||||
HStack(spacing: 4) {
|
||||
Circle()
|
||||
.fill(ShoeGazeScopeView.laneColors[index % ShoeGazeScopeView.laneColors.count])
|
||||
.frame(
|
||||
width: ShoeGazeScopeView.swatchSize,
|
||||
height: ShoeGazeScopeView.swatchSize
|
||||
)
|
||||
Text(shoeGaze.scopeLaneLabel(forBus: bus))
|
||||
.font(.caption2)
|
||||
.foregroundStyle(Color.white.opacity(ShoeGazeScopeView.labelOpacity))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user