Ardour  9.0-pre0-582-g084a23a80d
breakfastquay::MiniBPM Class Reference

#include <minibpm.h>

Public Member Functions

 MiniBPM (float sampleRate)
 
 ~MiniBPM ()
 
void setBPMRange (double min, double max)
 
void getBPMRange (double &min, double &max) const
 
void setBeatsPerBar (int bpb)
 
int getBeatsPerBar () const
 
double estimateTempoOfSamples (const float *samples, int nsamples)
 
void process (const float *samples, int nsamples)
 
double estimateTempo ()
 
std::vector< double > getTempoCandidates () const
 
void reset ()
 

Private Attributes

D * m_d
 

Detailed Description

A fixed-tempo BPM estimator, self-contained and implemented in a single C++ file.

This may be used in two ways: either call estimateTempoOfSamples() with a single in-memory buffer of all audio samples, or (if the input data is streamed or cannot fit in memory) call process() repeatedly with consecutive sample blocks of any size, followed by estimateTempo() when all samples have been supplied.

A single channel of audio only may be supplied (multi-channel is not supported). To process multi-channel audio, average the channels first.

Definition at line 45 of file minibpm.h.

Constructor & Destructor Documentation

◆ MiniBPM()

breakfastquay::MiniBPM::MiniBPM ( float  sampleRate)

◆ ~MiniBPM()

breakfastquay::MiniBPM::~MiniBPM ( )

Member Function Documentation

◆ estimateTempo()

double breakfastquay::MiniBPM::estimateTempo ( )

Return the estimated tempo in bpm of the music audio in the sequence of samples previously supplied through a series of calls to process(). If the tempo cannot be estimated because the clip is too short, return 0.

◆ estimateTempoOfSamples()

double breakfastquay::MiniBPM::estimateTempoOfSamples ( const float *  samples,
int  nsamples 
)

Return the estimated tempo in bpm of the music audio in the given sequence of samples. nsamples contains the number of samples. If the tempo cannot be estimated because the clip is too short, return 0.

You should use either this function, or a series of process() calls followed by an estimateTempo() call. Do not call both process() and estimateTempoOfSamples() on the same estimator object.

◆ getBeatsPerBar()

int breakfastquay::MiniBPM::getBeatsPerBar ( ) const

◆ getBPMRange()

void breakfastquay::MiniBPM::getBPMRange ( double &  min,
double &  max 
) const

◆ getTempoCandidates()

std::vector<double> breakfastquay::MiniBPM::getTempoCandidates ( ) const

Return all candidate tempi for the last tempo estimation that was carried out, in order of likelihood (best first). The value returned from estimateTempo or estimateTempoOfSamples will therefore be the first in the returned sequence.

◆ process()

void breakfastquay::MiniBPM::process ( const float *  samples,
int  nsamples 
)

Supply a single block of audio for processing. The block may be of any length. Blocks are assumed to be contiguous (i.e. without overlap).

◆ reset()

void breakfastquay::MiniBPM::reset ( )

Prepare the object to carry out another tempo estimation on a new audio clip. You can either call this between uses, or simply destroy this object and construct a new one.

◆ setBeatsPerBar()

void breakfastquay::MiniBPM::setBeatsPerBar ( int  bpb)

Set the number of beats per bar, if known. If unknown, leave at the default (which is 4).

◆ setBPMRange()

void breakfastquay::MiniBPM::setBPMRange ( double  min,
double  max 
)

Set the range of valid tempi. The default is 55-190bpm.

Member Data Documentation

◆ m_d

D* breakfastquay::MiniBPM::m_d
private

Definition at line 109 of file minibpm.h.


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