Ardour
9.0-pre0-582-g084a23a80d
|
#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 |
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.
breakfastquay::MiniBPM::MiniBPM | ( | float | sampleRate | ) |
breakfastquay::MiniBPM::~MiniBPM | ( | ) |
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.
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.
int breakfastquay::MiniBPM::getBeatsPerBar | ( | ) | const |
void breakfastquay::MiniBPM::getBPMRange | ( | double & | min, |
double & | max | ||
) | const |
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.
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).
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.
void breakfastquay::MiniBPM::setBeatsPerBar | ( | int | bpb | ) |
Set the number of beats per bar, if known. If unknown, leave at the default (which is 4).
void breakfastquay::MiniBPM::setBPMRange | ( | double | min, |
double | max | ||
) |
Set the range of valid tempi. The default is 55-190bpm.