BTrack - A Real-Time Beat Tracker
 All Classes Files Functions Enumerations Pages
Public Member Functions | Static Public Member Functions | List of all members
BTrack Class Reference

#include <BTrack.h>

Public Member Functions

 BTrack ()
 
 BTrack (int hopSize_)
 
 BTrack (int hopSize_, int frameSize_)
 
void updateHopAndFrameSize (int hopSize_, int frameSize_)
 
void processAudioFrame (double *frame)
 
void processOnsetDetectionFunctionSample (double sample)
 
int getHopSize ()
 
bool beatDueInCurrentFrame ()
 
double getCurrentTempoEstimate ()
 
double getLatestCumulativeScoreValue ()
 
void setTempo (double tempo)
 
void fixTempo (double tempo)
 
void doNotFixTempo ()
 

Static Public Member Functions

static double getBeatTimeInSeconds (long frameNumber, int hopSize, int fs)
 
static double getBeatTimeInSeconds (int frameNumber, int hopSize, int fs)
 

Detailed Description

The main beat tracking class and the interface to the BTrack beat tracking algorithm. The algorithm can process either audio frames or onset detection function samples and also contains some static functions for calculating beat times in seconds

Constructor & Destructor Documentation

BTrack::BTrack ( )

Constructor assuming hop size of 512 and frame size of 1024

BTrack::BTrack ( int  hopSize_)

Constructor assuming frame size will be double the hopSize

Parameters
hopSizethe hop size in audio samples
BTrack::BTrack ( int  hopSize_,
int  frameSize_ 
)

Constructor taking both hopSize and frameSize

Parameters
hopSizethe hop size in audio samples
frameSizethe frame size in audio samples

Member Function Documentation

bool BTrack::beatDueInCurrentFrame ( )
Returns
true if a beat should occur in the current audio frame
void BTrack::doNotFixTempo ( )

Tell the algorithm to not fix the tempo anymore

void BTrack::fixTempo ( double  tempo)

Fix tempo to roughly around some value, so that the algorithm will only try to track tempi around the given tempo

Parameters
tempothe tempo in beats per minute (bpm)
double BTrack::getBeatTimeInSeconds ( long  frameNumber,
int  hopSize,
int  fs 
)
static

Calculates a beat time in seconds, given the frame number, hop size and sampling frequency. This version uses a long to represent the frame number

Parameters
frameNumberthe index of the current frame
hopSizethe hop size in audio samples
fsthe sampling frequency in Hz
Returns
a beat time in seconds
double BTrack::getBeatTimeInSeconds ( int  frameNumber,
int  hopSize,
int  fs 
)
static

Calculates a beat time in seconds, given the frame number, hop size and sampling frequency. This version uses an int to represent the frame number

Parameters
frameNumberthe index of the current frame
hopSizethe hop size in audio samples
fsthe sampling frequency in Hz
Returns
a beat time in seconds
double BTrack::getCurrentTempoEstimate ( )
Returns
the current tempo estimate being used by the beat tracker
int BTrack::getHopSize ( )
Returns
the current hop size being used by the beat tracker
double BTrack::getLatestCumulativeScoreValue ( )
Returns
the most recent value of the cumulative score function
void BTrack::processAudioFrame ( double *  frame)

Process a single audio frame

Parameters
framea pointer to an array containing an audio frame. The number of samples should match the frame size that the algorithm was initialised with.
void BTrack::processOnsetDetectionFunctionSample ( double  sample)

Add new onset detection function sample to buffer and apply beat tracking

Parameters
samplean onset detection function sample
void BTrack::setTempo ( double  tempo)

Set the tempo of the beat tracker

Parameters
tempothe tempo in beats per minute (bpm)
void BTrack::updateHopAndFrameSize ( int  hopSize_,
int  frameSize_ 
)

Updates the hop and frame size used by the beat tracker

Parameters
hopSizethe hop size in audio samples
frameSizethe frame size in audio samples

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