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>
75 lines
2.5 KiB
Swift
75 lines
2.5 KiB
Swift
// NoteDivision.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Foundation
|
|
|
|
/// A rhythmic note value, expressed as a fraction of a bar and measured in quarter-note beats.
|
|
///
|
|
/// Used to lock a tempo-syncable pedal parameter (a delay time, an LFO rate) to the shared
|
|
/// ``ShoeGaze/clock``. The synced period in seconds is `(60 / bpm) * beats`; a delay time uses
|
|
/// that period directly, an LFO rate uses its inverse (one cycle per division).
|
|
///
|
|
/// Cases are ordered longest-first so a stepped selector reads top-to-bottom from slow to fast.
|
|
public enum NoteDivision: String, Codable, CaseIterable, Sendable {
|
|
|
|
/// Whole note — four quarter-note beats.
|
|
case whole
|
|
/// Dotted half note — three beats.
|
|
case dottedHalf
|
|
/// Half note — two beats.
|
|
case half
|
|
/// Dotted quarter note — one and a half beats.
|
|
case dottedQuarter
|
|
/// Quarter note — one beat.
|
|
case quarter
|
|
/// Dotted eighth note — three-quarters of a beat.
|
|
case dottedEighth
|
|
/// Quarter-note triplet — two-thirds of a beat.
|
|
case quarterTriplet
|
|
/// Eighth note — half a beat.
|
|
case eighth
|
|
/// Eighth-note triplet — one-third of a beat.
|
|
case eighthTriplet
|
|
/// Sixteenth note — a quarter of a beat.
|
|
case sixteenth
|
|
/// Sixteenth-note triplet — one-sixth of a beat.
|
|
case sixteenthTriplet
|
|
|
|
/// Length of this division in quarter-note beats (a quarter note is `1`).
|
|
public var beats: Double {
|
|
switch self {
|
|
case .whole: return 4.0
|
|
case .dottedHalf: return 3.0
|
|
case .half: return 2.0
|
|
case .dottedQuarter: return 1.5
|
|
case .quarter: return 1.0
|
|
case .quarterTriplet: return 2.0 / 3.0
|
|
case .dottedEighth: return 0.75
|
|
case .eighth: return 0.5
|
|
case .eighthTriplet: return 1.0 / 3.0
|
|
case .sixteenth: return 0.25
|
|
case .sixteenthTriplet: return 1.0 / 6.0
|
|
}
|
|
}
|
|
|
|
/// Short label for a selector stop (e.g. `"1/4"`, `"1/8."`, `"1/8T"`).
|
|
public var label: String {
|
|
switch self {
|
|
case .whole: return "1/1"
|
|
case .dottedHalf: return "1/2."
|
|
case .half: return "1/2"
|
|
case .dottedQuarter: return "1/4."
|
|
case .quarter: return "1/4"
|
|
case .quarterTriplet: return "1/4T"
|
|
case .dottedEighth: return "1/8."
|
|
case .eighth: return "1/8"
|
|
case .eighthTriplet: return "1/8T"
|
|
case .sixteenth: return "1/16"
|
|
case .sixteenthTriplet: return "1/16T"
|
|
}
|
|
}
|
|
}
|