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:
@@ -4,6 +4,8 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import Foundation
|
||||
|
||||
/// Serialisable snapshot of one pedal's parameter values.
|
||||
///
|
||||
/// `type` stores the pedal's `displayName` and is used by `PedalRegistry` to
|
||||
@@ -16,6 +18,12 @@
|
||||
/// knobs at their current value.
|
||||
public struct PedalState: Codable, Equatable {
|
||||
|
||||
/// Stable per-pedal identity, persisted so MIDI bindings can address a pedal by id rather
|
||||
/// than by chain position. Survives capture → rebuild round-trips (an edit rebuilds the board
|
||||
/// from captured segments, carrying each pedal's id forward). Legacy presets without an id
|
||||
/// decode to a fresh `UUID()`.
|
||||
public let id: UUID
|
||||
|
||||
/// The pedal's `displayName` — used as a factory key by `PedalRegistry`.
|
||||
public let type: String
|
||||
|
||||
@@ -47,6 +55,7 @@ public struct PedalState: Codable, Equatable {
|
||||
/// - selectorValues: Current selector values in `Pedal.effectSelectors` order. Defaults to empty.
|
||||
/// - bypass: Bypass parameter value (`0.0` = engaged, `1.0` = bypassed).
|
||||
public init(
|
||||
id: UUID = UUID(),
|
||||
type: String,
|
||||
knobValues: [Double],
|
||||
switchValues: [Double] = [],
|
||||
@@ -54,6 +63,7 @@ public struct PedalState: Codable, Equatable {
|
||||
selectorValues: [Double] = [],
|
||||
bypass: Double
|
||||
) {
|
||||
self.id = id
|
||||
self.type = type
|
||||
self.knobValues = knobValues
|
||||
self.switchValues = switchValues
|
||||
@@ -63,6 +73,7 @@ public struct PedalState: Codable, Equatable {
|
||||
}
|
||||
|
||||
private enum CodingKeys: String, CodingKey {
|
||||
case id
|
||||
case type
|
||||
case knobValues
|
||||
case switchValues
|
||||
@@ -75,6 +86,7 @@ public struct PedalState: Codable, Equatable {
|
||||
/// `selectorValues` existed by defaulting the missing keys to an empty array.
|
||||
public init(from decoder: any Decoder) throws {
|
||||
let container: KeyedDecodingContainer<CodingKeys> = try decoder.container(keyedBy: CodingKeys.self)
|
||||
self.id = try container.decodeIfPresent(UUID.self, forKey: .id) ?? UUID()
|
||||
self.type = try container.decode(String.self, forKey: .type)
|
||||
self.knobValues = try container.decode([Double].self, forKey: .knobValues)
|
||||
self.switchValues = try container.decodeIfPresent([Double].self, forKey: .switchValues) ?? []
|
||||
|
||||
Reference in New Issue
Block a user