MythTV  0.26-pre
Public Member Functions | Protected Member Functions | Protected Attributes
BPMDetect Class Reference

Class for calculating BPM rate for audio data. More...

#include <BPMDetect.h>

List of all members.

Public Member Functions

 BPMDetect (int numChannels, int sampleRate)
 Constructor.
virtual ~BPMDetect ()
 Destructor.
void inputSamples (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.

Protected Member Functions

void init (int numChannels, int sampleRate)
 Initialize the class for processing.
void updateXCorr (int process_samples)
 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).
int decimate (soundtouch::SAMPLETYPE *dest, const soundtouch::SAMPLETYPE *src, int numsamples)
 Decimates samples to approx.
void calcEnvelope (soundtouch::SAMPLETYPE *samples, int numsamples)
 Calculates amplitude envelope for the buffer of samples.

Protected Attributes

float * xcorr
 Auto-correlation accumulator bins.
float envelopeAccu
 Amplitude envelope sliding average approximation level accumulator.
float RMSVolumeAccu
 RMS volume sliding average approximation level accumulator.
int decimateCount
 Sample average counter.
soundtouch::LONG_SAMPLETYPE decimateSum
 Sample average accumulator for FIFO-like decimation.
int decimateBy
 Decimate sound by this coefficient to reach approx. 500 Hz.
int windowLen
 Auto-correlation window length.
int channels
 Number of channels (1 = mono, 2 = stereo)
int sampleRate
 sample rate
int windowStart
 Beginning of auto-correlation window: Autocorrelation isn't being updated for the first these many correlation bins.
soundtouch::FIFOSampleBufferbuffer
 FIFO-buffer for decimated processing samples.

Detailed Description

Class for calculating BPM rate for audio data.

Definition at line 71 of file BPMDetect.h.


Constructor & Destructor Documentation

BPMDetect::BPMDetect ( int  numChannels,
int  sampleRate 
)

Constructor.

Parameters:
numChannelsNumber of channels in sample data.
sampleRateSample rate in Hz.
virtual BPMDetect::~BPMDetect ( ) [virtual]

Destructor.


Member Function Documentation

void BPMDetect::init ( int  numChannels,
int  sampleRate 
) [protected]

Initialize the class for processing.

void 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_samplesHow many samples are processed.
int BPMDetect::decimate ( soundtouch::SAMPLETYPE dest,
const soundtouch::SAMPLETYPE src,
int  numsamples 
) [protected]

Decimates samples to approx.

500 Hz.

Returns:
Number of output samples.
Parameters:
destDestination buffer
srcSource sample buffer
numsamplesNumber of source samples.
void BPMDetect::calcEnvelope ( soundtouch::SAMPLETYPE samples,
int  numsamples 
) [protected]

Calculates amplitude envelope for the buffer of samples.

Result is output to 'samples'.

Parameters:
samplesPointer to input/output data buffer
numsamplesNumber of samples in buffer
void BPMDetect::inputSamples ( soundtouch::SAMPLETYPE samples,
int  numSamples 
)

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:
samplesPointer to input/working data buffer
numSamplesNumber of samples in buffer
float 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.

Member Data Documentation

float* BPMDetect::xcorr [protected]

Auto-correlation accumulator bins.

Definition at line 75 of file BPMDetect.h.

float BPMDetect::envelopeAccu [protected]

Amplitude envelope sliding average approximation level accumulator.

Definition at line 78 of file BPMDetect.h.

float BPMDetect::RMSVolumeAccu [protected]

RMS volume sliding average approximation level accumulator.

Definition at line 81 of file BPMDetect.h.

Sample average counter.

Definition at line 84 of file BPMDetect.h.

Sample average accumulator for FIFO-like decimation.

Definition at line 87 of file BPMDetect.h.

Decimate sound by this coefficient to reach approx. 500 Hz.

Definition at line 90 of file BPMDetect.h.

Auto-correlation window length.

Definition at line 93 of file BPMDetect.h.

int BPMDetect::channels [protected]

Number of channels (1 = mono, 2 = stereo)

Definition at line 96 of file BPMDetect.h.

sample rate

Definition at line 99 of file BPMDetect.h.

Beginning of auto-correlation window: Autocorrelation isn't being updated for the first these many correlation bins.

Definition at line 103 of file BPMDetect.h.

FIFO-buffer for decimated processing samples.

Definition at line 106 of file BPMDetect.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends