DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::DownbeatEstimator< T > Class Template Referencefinal

Names the beats that open a bar, from a signal and its beats. More...

#include <DownbeatEstimator.h>

Classes

struct  Result
 What estimate() returns. More...
 

Static Public Member Functions

static Result estimate (std::span< const T > mono, double sampleRate, std::span< const int64_t > beatSamples, int beatsPerBar=0)
 Estimates the bar length and the first beat of the bars.
 

Static Public Attributes

static constexpr int kMinBeats = 8
 Fewest beats estimate() reads: two bars of four.
 
static constexpr int kMaxBeatsPerBar = 8
 Longest bar a caller may ask for, in beats.
 

Detailed Description

template<FloatType T>
class dspark::DownbeatEstimator< T >

Names the beats that open a bar, from a signal and its beats.

Role: offline analysis readout. It reads const audio and returns a value.

Template Parameters
TSample type (float or double).

Definition at line 115 of file DownbeatEstimator.h.

Member Function Documentation

◆ estimate()

template<FloatType T>
static Result dspark::DownbeatEstimator< T >::estimate ( std::span< const T >  mono,
double  sampleRate,
std::span< const int64_t >  beatSamples,
int  beatsPerBar = 0 
)
inlinestatic

Estimates the bar length and the first beat of the bars.

The bars are taken as equal in length from the first beat to the last: a piece that changes its time signature, or drops a beat, gets the bar line that fits most of it.

Parameters
monoMono samples of the whole signal. Samples that are not finite read as zero.
sampleRateSample rate in Hz.
beatSamplesThe beats, as sample positions inside the signal, strictly ascending.
beatsPerBarBeats in a bar, 2 to kMaxBeatsPerBar, or 0 to have it estimated (as 3 or 4).
Returns
The bar length, the first beat that opens a bar and all of them. Empty (beatsPerBar 0, firstDownbeat -1) for an invalid rate or bar length, beats out of order or outside the signal, fewer than kMinBeats beats or than two bars and a beat of them, or a signal shorter than the analysis window (about 0.19 s).

Definition at line 157 of file DownbeatEstimator.h.

Member Data Documentation

◆ kMaxBeatsPerBar

template<FloatType T>
constexpr int dspark::DownbeatEstimator< T >::kMaxBeatsPerBar = 8
staticconstexpr

Longest bar a caller may ask for, in beats.

Definition at line 134 of file DownbeatEstimator.h.

◆ kMinBeats

template<FloatType T>
constexpr int dspark::DownbeatEstimator< T >::kMinBeats = 8
staticconstexpr

Fewest beats estimate() reads: two bars of four.

Definition at line 132 of file DownbeatEstimator.h.


The documentation for this class was generated from the following file: