pub struct BeatGrid {
pub beats: Vec<f64>,
pub downbeats: Vec<usize>,
pub segments: Vec<TempoSegment>,
pub bpm: f64,
pub confidence: f32,
pub downbeat_confidence: f32,
pub sample_rate: u32,
}Expand description
Beat grid for a track: tracked beat positions, downbeats, and a piecewise-constant tempo model.
Positions are fractional sample indices on the analyzed mono signal.
Constant-tempo material yields a single segment; tempo drift or steps
yield several. An empty beats with bpm == 0.0 means no tempo was
detected.
Fields§
§beats: Vec<f64>Fractional-sample positions of every tracked beat, ascending.
downbeats: Vec<usize>Indices into beats marking downbeats (bar starts), ascending.
segments: Vec<TempoSegment>Piecewise-constant tempo segments covering beats, ascending by
start_beat; never empty when beats is non-empty.
bpm: f64Representative tempo in BPM (median of multi-beat-baseline intervals, which cancels per-beat frame-grid quantization); 0.0 when undetected.
confidence: f32Overall grid confidence in [0, 1]: periodicity clarity, beat-level onset support, and interval regularity against the tempo curve.
downbeat_confidence: f32Confidence of the downbeat phase decision in [0, 1].
sample_rate: u32Sample rate the positions refer to.
Implementations§
Source§impl BeatGrid
impl BeatGrid
Sourcepub fn beat_interval_samples(&self) -> f64
pub fn beat_interval_samples(&self) -> f64
Returns the representative interval between beats in samples.
Sourcepub fn bpm_at(&self, position: f64) -> f64
pub fn bpm_at(&self, position: f64) -> f64
Tempo in BPM at a sample position, from the segment model. Returns the representative BPM outside the tracked range and 0.0 for an empty grid.
Sourcepub fn nearest_beat_index(&self, position: f64) -> Option<usize>
pub fn nearest_beat_index(&self, position: f64) -> Option<usize>
Index of the nearest beat to position, or None for an empty grid.
Sourcepub fn snap_to_grid(&self, position: usize) -> usize
pub fn snap_to_grid(&self, position: usize) -> usize
Snaps a sample position to the nearest beat.
Sourcepub fn snap_to_grid_fractional(&self, position: f64) -> f64
pub fn snap_to_grid_fractional(&self, position: f64) -> f64
Snaps a fractional sample position to the nearest beat.
Sourcepub fn beats_rounded(&self) -> Vec<usize>
pub fn beats_rounded(&self) -> Vec<usize>
Beat positions rounded to integer sample indices.
Sourcepub fn downbeat_positions(&self) -> Vec<f64>
pub fn downbeat_positions(&self) -> Vec<f64>
Fractional-sample positions of the downbeats.