Class for calculating BPM rate for audio data.
More...
#include <tracktion_TempoDetect.h>
|
| | BPMDetect (int numChannels, int sampleRate) |
| | Constructor.
|
| virtual | ~BPMDetect () |
| | Destructor.
|
| void | inputSamples (const soundtouch::SAMPLETYPE *samples, int numSamples) |
| | Inputs a block of samples for analyzing: Envelopes the samples and then updates the autocorrelation estimation.
|
| float | getBpm () |
| | Analyzes the results and returns the BPM rate.
|
| int | getBeats (float *pos, float *strength, int max_num) |
| | Get beat position arrays.
|
Class for calculating BPM rate for audio data.
◆ BPMDetect()
| engine::soundtouch::BPMDetect::BPMDetect |
( |
int | numChannels, |
|
|
int | sampleRate ) |
Constructor.
- Parameters
-
| numChannels | Number of channels in sample data. |
| sampleRate | Sample rate in Hz. |
◆ ~BPMDetect()
| virtual engine::soundtouch::BPMDetect::~BPMDetect |
( |
| ) |
|
|
virtual |
◆ updateXCorr()
| void engine::soundtouch::BPMDetect::updateXCorr |
( |
int | process_samples | ) |
|
|
protected |
Updates auto-correlation function for given number of decimated samples that are read from the internal 'buffer' pipe (samples aren't removed from the pipe though).
- Parameters
-
| process_samples | How many samples are processed. |
◆ decimate()
Decimates samples to approx.
500 Hz.
- Returns
- Number of output samples.
- Parameters
-
| dest | Destination buffer |
| src | Source sample buffer |
| numsamples | Number of source samples. |
◆ calcEnvelope()
Calculates amplitude envelope for the buffer of samples.
Result is output to 'samples'.
- Parameters
-
| samples | Pointer to input/output data buffer |
| numsamples | Number of samples in buffer |
◆ removeBias()
| void engine::soundtouch::BPMDetect::removeBias |
( |
| ) |
|
|
protected |
remove constant bias from xcorr data
◆ updateBeatPos()
| void engine::soundtouch::BPMDetect::updateBeatPos |
( |
int | process_samples | ) |
|
|
protected |
◆ inputSamples()
Inputs a block of samples for analyzing: Envelopes the samples and then updates the autocorrelation estimation.
When whole song data has been input in smaller blocks using this function, read the resulting bpm with 'getBpm' function.
Notice that data in 'samples' array can be disrupted in processing.
- Parameters
-
| samples | Pointer to input/working data buffer |
| numSamples | Number of samples in buffer |
◆ getBpm()
| float engine::soundtouch::BPMDetect::getBpm |
( |
| ) |
|
Analyzes the results and returns the BPM rate.
Use this function to read result after whole song data has been input to the class by consecutive calls of 'inputSamples' function.
- Returns
- Beats-per-minute rate, or zero if detection failed.
◆ getBeats()
| int engine::soundtouch::BPMDetect::getBeats |
( |
float * | pos, |
|
|
float * | strength, |
|
|
int | max_num ) |
Get beat position arrays.
Note: The array includes also really low beat detection values in absence of clear strong beats. Consumer may wish to filter low values away.
- "pos" receive array of beat positions
- "values" receive array of beat detection strengths
- max_num indicates max.size of "pos" and "values" array.
You can query a suitable array sized by calling this with NULL in "pos" & "values".
- Returns
- number of beats in the arrays.
◆ xcorr
| float* engine::soundtouch::BPMDetect::xcorr |
|
protected |
Auto-correlation accumulator bins.
◆ decimateCount
| int engine::soundtouch::BPMDetect::decimateCount |
|
protected |
◆ decimateSum
Sample average accumulator for FIFO-like decimation.
◆ decimateBy
| int engine::soundtouch::BPMDetect::decimateBy |
|
protected |
Decimate sound by this coefficient to reach approx. 500 Hz.
◆ windowLen
| int engine::soundtouch::BPMDetect::windowLen |
|
protected |
Auto-correlation window length.
◆ channels
| int engine::soundtouch::BPMDetect::channels |
|
protected |
Number of channels (1 = mono, 2 = stereo).
◆ sampleRate
| int engine::soundtouch::BPMDetect::sampleRate |
|
protected |
◆ windowStart
| int engine::soundtouch::BPMDetect::windowStart |
|
protected |
Beginning of auto-correlation window: Autocorrelation isn't being updated for the first these many correlation bins.
◆ hamw
| float* engine::soundtouch::BPMDetect::hamw |
|
protected |
window functions for data preconditioning
◆ hamw2
| float* engine::soundtouch::BPMDetect::hamw2 |
|
protected |
◆ pos
| int engine::soundtouch::BPMDetect::pos |
|
protected |
◆ peakPos
| int engine::soundtouch::BPMDetect::peakPos |
|
protected |
◆ beatcorr_ringbuffpos
| int engine::soundtouch::BPMDetect::beatcorr_ringbuffpos |
|
protected |
◆ init_scaler
| int engine::soundtouch::BPMDetect::init_scaler |
|
protected |
◆ peakVal
| float engine::soundtouch::BPMDetect::peakVal |
|
protected |
◆ beatcorr_ringbuff
| float* engine::soundtouch::BPMDetect::beatcorr_ringbuff |
|
protected |
◆ buffer
FIFO-buffer for decimated processing samples.
◆ beats
| std::vector<BEAT> engine::soundtouch::BPMDetect::beats |
|
protected |
Collection of detected beat positions.
◆ beat_lpf
The documentation for this class was generated from the following file: