30 lines
1.3 KiB
Swift
30 lines
1.3 KiB
Swift
// BeatTrackODF.swift
|
|
// Lyrebird
|
|
//
|
|
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
import Foundation
|
|
|
|
/// Selects where ``BeatTrack`` gets its onset detection function (ODF) — the
|
|
/// one-dimensional signal whose peaks the tracker locks onto.
|
|
///
|
|
/// This is the implementation flag that folds the two SuperCollider beat-tracker
|
|
/// flavours into a single ``BeatTrack`` generator. The cases carry different
|
|
/// inputs (an FFT chain vs an arbitrary signal), so the selector is an enum
|
|
/// rather than a `Bool`.
|
|
public enum BeatTrackODF {
|
|
|
|
/// FFT-fed: compute the ODF internally as the spectral flux of `analysis`
|
|
/// (the same frame-to-frame magnitude-change measure as ``SpectralFlux``).
|
|
/// Drop-in — wire an analyze-only ``SpectralChain/Audio`` on the source you
|
|
/// want to track. Equivalent to SuperCollider's `BeatTrack`.
|
|
case spectralFlux(analysis: SpectralChain.Audio)
|
|
|
|
/// Feature-fed: take an externally supplied ODF — any signal whose peaks
|
|
/// coincide with onsets (``SpectralFlux``, ``OnsetDetector``, an
|
|
/// amplitude-difference feature, …). Reduced to one ODF value per audio
|
|
/// block (block max). Equivalent to SuperCollider's `BeatTrack2`.
|
|
case feature(any ValidGeneratorInput)
|
|
}
|