#include <SpectralODF.h>
Inherits SpectralODFBase.
Public Types | |
enum | ODFMethod { FLUX = 0, HIGH_FREQUENCY_CONTENT = 1, PHASE_DEVIATION = 2, WEIGHTED_PHASE_DEVIATION = 3, NORM_WEIGHTED_PHASE_DEVIATION = 4, MODIFIED_KULLBACK_LIEBLER = 5, COMPLEX_DOMAIN = 6, RECTIFIED_COMPLEX_DOMAIN = 7, CENTER_OF_GRAVITY = 8 } |
Specifies the method for calculating the onset detection function to be used. More... | |
Public Member Functions | |
SpectralODF (int fftSize=1024, ODFMethod odfMethod=COMPLEX_DOMAIN) | |
~SpectralODF () | |
void | process (const MatrixXC &ffts, MatrixXR *odfs) |
ODFMethod | odfMethod () const |
void | setOdfMethod (ODFMethod method, bool callSetup=true) |
This class wraps several kind of spectral Onset Detection Functions (ODF). A spectral onset detection function is a function mapping from an FFT of an audio signal to a Real value. The onset detection function represents a value proportional to the probability of the frame being an onset.
The algorithm takes as input N-point vectors of Complex values and returns Real values.
5 types of ODF methods are implemented:
The Phase deviation, Weighted phase deviation, Normalized weighted phase deviation, Complex domain and Rectified complex domain methods require the 2 past FFT frames. Therefore if any of these methods are specified, the process() method would require an input matrix of at least 3 rows and will output ODF values for all the rows but the first two.
The Spectral flux method requires the past FFT frame. Therefore if this method is used, the process() method would require an input matrix of at least 2 rows and will output ODF values for all the rows but the first.
The ODF method can be selected using the setOdfMethod() taking as argument an ODFMethod.
This function is often use to perform beat estimation and event segmentation tasks.
enum ODFMethod |
Specifies the method for calculating the onset detection function to be used.
SpectralODF | ( | int | fftSize = 1024 , |
|
ODFMethod | odfMethod = COMPLEX_DOMAIN | |||
) |
Constructs a spectral onset detection function object with the specified fftSize and odfMethod settings.
fftSize | size of the input FFT frames, must be > 0. | |
odfMethod | the onset detection method to be used |
References setOdfMethod().
~SpectralODF | ( | ) |
Destroys the algorithm and frees its resources.
void process | ( | const MatrixXC & | ffts, | |
MatrixXR * | odfs | |||
) |
Calculates the onset detection method on each of the rows of ffts and puts the resulting onset detection function values in the rows of odfs.
ffts | matrix of Complex values. The number of columns of ffts must be equal to the fftSize / 2 + 1. Some onset detection methods require a minimum of 2 (or 3) rows to calculate the one onset detection function value. In this cases onset detection values for the first 2 (or 3 respectively) rows will not be output. | |
odfs | pointer to a single-column matrix of Real values for the output. The matrix should have the same number of rows as ffts (minus 1 or 2 depending on the method used) and 1 single column. |
SpectralODF::ODFMethod odfMethod | ( | ) | const |
Returns the method for calculating the spectral onset detection function.
By default it is COMPLEX_DOMAIN.
void setOdfMethod | ( | ODFMethod | method, | |
bool | callSetup = true | |||
) |
Specifies the method for calculating the spectral onset detection function.
Note that PHASE_DEVIATION, WEIGHTED_PHASE_DEVIATION, NORM_WEIGHTED_PHASE_DEVIATION, COMPLEX_DOMAIN and RECTIFIED_COMPLEX_DOMAIN methods require at least 3 FFT frames, and therefore the input matrix to the process() method must have at least 3 rows. In these cases the output matrix will be 2 rows smaller than the input, since it only calculates ODF values for all the rows but the first two.
Note that SPECTRAL_FLUX method requires at least 2 FFT frames, and therefore the input matrix to the process() method must have at least 2 rows. In this case the output matrix will be 1 row smaller than the input, since it only calculates ODF values for all the rows but the first.
method | the method used for calculating the spectral onset detection function. | |
callSetup | a flag specifying whether the setup() method must be called after setting the parameter. |
Referenced by SpectralODF().