Add looper pedal: beat-quantized transport, undo, reverse, timeline
Extend the looper into a double-width tempo-aware pedal: - Beat-quantized transport: record start and loop close both snap to the next beat via a LyrebirdRoutine waiting on the shared clock; loop length is an exact whole-beat span. Falls back to immediate/unquantized when no clock is present. - Loop-length read-outs (frames/seconds/beats), transport state, and a sample-clock-derived play-head position for the UI timeline. - Overdub undo (pre-dub snapshot + restore), reverse playback (live rate flip), and feedback-decay overdub (overdub preLevel via a Feedback knob). - Inject the shared LyrebirdClock + SynthesisEngine into Pedal via PedalBoard/ChainRouter so tempo-aware pedals can reach them. - New double-width LooperTimelineView (state badge, length read-out, sweeping play-head) wired into PedalView via Pedal.widthUnits. Concurrency hardening from RT-safety review: a transportGeneration counter drops superseded deferred beat/undo callbacks that LyrebirdRoutine.stop() cannot recall once enqueued; the undo restore is deferred past the RT overdub gate-close; transport routines use non-blocking stop(). Note: this commit also snapshots pre-existing uncommitted work-in-progress already in the tree (MIDI control refactor, Tuner, Tempo, preset changes), which is interleaved with the looper changes through shared files and could not be split into a separately-building commit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
// PedalButtonView.swift
|
||||
// Lyrebird
|
||||
//
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import SwiftUI
|
||||
import LyrebirdUI
|
||||
import LyrebirdShoeGaze
|
||||
|
||||
// MARK: - PedalButtonView
|
||||
|
||||
/// A stomp-style action button rendered from a ``PedalButton`` descriptor.
|
||||
///
|
||||
/// `.momentary` renders a plain `ParameterButton`. `.toggle` renders the same LED +
|
||||
/// footswitch look as the pedal's own bypass control (`PedalView`'s `LEDIndicator` /
|
||||
/// `FootswitchButton`), with a caption label beneath — so a looper's Overdub/Loop toggles
|
||||
/// read as stomp switches with state, not a segmented picker.
|
||||
///
|
||||
/// ## Usage
|
||||
/// ```swift
|
||||
/// PedalButtonView(pedalButton)
|
||||
/// ```
|
||||
public struct PedalButtonView: View {
|
||||
|
||||
private static let toggleOnThreshold: Double = 0.5
|
||||
private static let sectionSpacing: CGFloat = 6
|
||||
private static let captionFontSize: CGFloat = 11
|
||||
|
||||
private let pedalButton: PedalButton
|
||||
|
||||
/// Creates a button view from a descriptor.
|
||||
///
|
||||
/// - Parameter pedalButton: The button to render.
|
||||
public init(_ pedalButton: PedalButton) {
|
||||
self.pedalButton = pedalButton
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
switch pedalButton.style {
|
||||
case .momentary:
|
||||
ParameterButton(pedalButton.label, action: pedalButton.action ?? {})
|
||||
case .toggle:
|
||||
if let node: UIParamNode = pedalButton.node {
|
||||
// Reading `node.value` registers this view for @Observable re-render.
|
||||
let isOn: Bool = node.value >= PedalButtonView.toggleOnThreshold
|
||||
VStack(spacing: PedalButtonView.sectionSpacing) {
|
||||
LEDIndicator(isOn: isOn)
|
||||
FootswitchButton(node: node)
|
||||
Text(pedalButton.label)
|
||||
.font(.system(size: PedalButtonView.captionFontSize))
|
||||
.foregroundStyle(Color.white)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user