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:
@@ -104,6 +104,9 @@ public final class ChainRouter {
|
||||
|
||||
private let engine: SynthesisEngine
|
||||
|
||||
/// Shared tempo clock, forwarded to both sub-boards so tempo-aware pedals quantize to beats.
|
||||
private let clock: LyrebirdClock?
|
||||
|
||||
/// The shared input source (either a `TestLoopSource` or `HardwareInputPassThrough`).
|
||||
private let source: any Synthesizer
|
||||
|
||||
@@ -152,9 +155,11 @@ public final class ChainRouter {
|
||||
/// - `EngineAddError` if the engine rejects any node insertion.
|
||||
public init(
|
||||
engine: SynthesisEngine,
|
||||
inputSource: InputSource = .testLoop
|
||||
inputSource: InputSource = .testLoop,
|
||||
clock: LyrebirdClock? = nil
|
||||
) throws {
|
||||
self.engine = engine
|
||||
self.clock = clock
|
||||
|
||||
// Step 1 — allocate the shared input bus.
|
||||
let inputBus: AudioBus = try engine.busAllocator.allocateAudioBus(channelCount: 1)
|
||||
@@ -186,8 +191,8 @@ public final class ChainRouter {
|
||||
self.source = addedSource
|
||||
|
||||
// Step 3 — create both boards (each allocates its own head bus).
|
||||
let createdBoardA: PedalBoard = try PedalBoard(engine: engine)
|
||||
let createdBoardB: PedalBoard = try PedalBoard(engine: engine)
|
||||
let createdBoardA: PedalBoard = try PedalBoard(engine: engine, clock: clock)
|
||||
let createdBoardB: PedalBoard = try PedalBoard(engine: engine, clock: clock)
|
||||
self.boardA = createdBoardA
|
||||
self.boardB = createdBoardB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user