2772abdc56
Tempo sync - Lock a delay time or modulation LFO rate to a note division (whole..sixteenth, dotted, triplet) of the shared clock. Value is derived from the tempo and follows tap tempo, the stepper, the editable BPM field, and MIDI. - Delay time: Delay, FeedbackDelay, PingPong, ReverseDelay, MultiTap (per tap). LFO rate (inverse mapping): Tremolo, Vibrato, Chorus, Flanger, Phaser, Modulation. - Core types NoteDivision / TempoSync / TempoSyncableParam; Pedal.tempoSyncableParams / tempoSync / applyTempoSync / setSync; ShoeGaze.setBpm broadcast recomputes all pedals; tempoSync persisted in PedalState (lenient decode) and recomputed on load + recall. - Observable TempoSyncRevision so the sync badge refreshes on any state-change path. UI - Division picker with drawn music-notation glyphs (NoteGlyphView + rasterized cache): noteheads, stems, flags, augmentation dot, bracketed 3 for triplets. Presented as a height-capped popover so it stays on-screen on iOS. - Editable BPM text field: integer-only, live-filtered, clamped 30-300, commit on return / Done / blur. - Divisions that clamp at the current tempo are disabled in the picker; an active clamped sync shows a warning marker. - In-context control mapping badges (PC / CC / KEY) per pedal control, with a legend. Delays - Maximum delay time raised to 5 s across the delay pedals (was 1-2 s). Docs: CHANGELOG.md, RELEASES.md, docs/plans/2.2-tempo-synced-parameters.md. All 454 tests pass; passed lyrebird_external_review (RT-safe, main-thread param writes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
1.1 KiB
Swift
30 lines
1.1 KiB
Swift
// TempoSyncRevision.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Observation
|
|
|
|
/// An observable revision counter bumped whenever a pedal's ``Pedal/tempoSync`` state changes.
|
|
///
|
|
/// ``Pedal/tempoSync`` is a plain dictionary, not observable, so a SwiftUI view showing the sync
|
|
/// state (the note-division badge) needs a signal to re-render when the state changes through any
|
|
/// path — the knob's own picker, a preset load, or a lightweight recall. Reading ``value`` inside a
|
|
/// view body subscribes it; ``Pedal/setSync(_:for:)`` and `Pedal.applyState(_:)` bump it.
|
|
@Observable
|
|
public final class TempoSyncRevision {
|
|
|
|
/// Incremented on every ``Pedal/tempoSync`` mutation. Its magnitude is meaningless — only the
|
|
/// change matters, as an invalidation signal for observing views.
|
|
public internal(set) var value: Int = 0
|
|
|
|
/// Creates a revision counter starting at zero.
|
|
public init() {}
|
|
|
|
/// Bumps the counter, invalidating any view observing ``value``.
|
|
func bump() {
|
|
value &+= 1
|
|
}
|
|
}
|