#include <PitchACF.h>
Public Member Functions | |
PitchACF (int fftSize=1024, Real samplerate=1.0, int minimumPeakWidth=6, int peakCandidateCount=10) | |
~PitchACF () | |
void | process (const MatrixXR &spectrums, MatrixXR *pitches, MatrixXR *saliencies) |
int | fftSize () const |
void | setFftSize (int size, bool callSetup=true) |
int | minimumPeakWidth () const |
void | setMinimumPeakWidth (int width, bool callSetup=true) |
int | peakCandidateCount () const |
void | setPeakCandidateCount (int count, bool callSetup=true) |
Real | samplerate () const |
void | setSamplerate (Real frequency, bool callSetup=true) |
This class represents an object to estimate the most prominent pitch of a vector of Real values reprsenting the FFT of an audio frame using the Autocorrelation function.
The algorithm performs an autocorrelation on the input spectrums and finds the first peak of a set of highest magnitude candidates. The index of the peak and the values of the peak will determine the pitch frequency and saliency.
The minimum peak width can be specified using setMinimumPeakWidth().
The number of candidates at the peak detection stage be specified using setPeakCandidateCount().
PitchACF | ( | int | fftSize = 1024 , |
|
Real | samplerate = 1.0 , |
|||
int | minimumPeakWidth = 6 , |
|||
int | peakCandidateCount = 10 | |||
) |
Constructs an autocorrelation based pitch estimation function object with the specified fftSize, samplerate, minPeakWidth and peakCandidateCount settings.
fftSize | size of the input FFT frames, must be > 0. | |
samplerate | the samplerate of the input signal. By default it is 1.0, so the pitches will be returned in normalized frequencies. | |
minimumPeakWidth | the minimum width of a peak in the autocorrelation function for it to be detected. | |
peakCandidateCount | the number of highest magnitude candidates to be considered during the peak detection process of the autocorrelation function. |
References setFftSize(), setMinimumPeakWidth(), setPeakCandidateCount(), and setSamplerate().
~PitchACF | ( | ) |
Destroys the algorithm and frees its resources.
void process | ( | const MatrixXR & | spectrums, | |
MatrixXR * | pitches, | |||
MatrixXR * | saliencies | |||
) |
Performs a pitch estimation on each of the rows of spectrums. Puts the resulting estimated pitches in the rows of pitches and the saliencies of each pitch in the rows of saliencies.
spectrums | matrix of Real values representing one spectrum magnitude per row. The number of columns of spectrum must be equal to the fftSize / 2 + 1 where fftSize is specified using setFftSize(). | |
pitches | pointer to a matrix of Real values representing the frequencies of the estimated pitches as rows. The matrix should have the same number of rows as spectrums and as many columns as the count of estimated pitches. Note that this algorithm is only capable of detecting a single pitch at each frame, therefore pitches will be a single column matrix. | |
saliencies | pointer to a matrix of Real values representing the saliencies of the estimated pitches as rows. The matrix should have the same number of rows as spectrums and as many columns as the count of estimated pitches. Note that this algorithm is only capable of detecting a single pitch at each frame, therefore pitches will be a single column matrix. |
References PeakInterpolation::process(), PeakDetection::process(), and Autocorrelation::process().
int fftSize | ( | ) | const |
Returns the size of the FFT that has been performed for the input. The default is 1024.
void setFftSize | ( | int | size, | |
bool | callSetup = true | |||
) |
Specifies the size of the FFT that has been performed for the input. The given size must be higher than 0.
Referenced by PitchACF().
int minimumPeakWidth | ( | ) | const |
Returns the minimum width for a peak to be detected in the autocorrelation function. The default is 6.
void setMinimumPeakWidth | ( | int | width, | |
bool | callSetup = true | |||
) |
Specifies the minimum width for a peak to be detected in the autocorrelation function.
Referenced by PitchACF().
int peakCandidateCount | ( | ) | const |
Returns the number of highest magnitude candidates to be considered during the peak detection process of the autocorrelation function.
Note that if the value is <= 0, then no preselection is performed and all detected peaks are considered as candidates.
By default it is 6.
void setPeakCandidateCount | ( | int | count, | |
bool | callSetup = true | |||
) |
Specifies the number of highest magnitude candidates to be considered during the peak detection process of the autocorrelation function.
Note that if the value is <= 0, then no preselection is performed and all detected peaks are considered as candidates.
Referenced by PitchACF().
Real samplerate | ( | ) | const |
void setSamplerate | ( | Real | frequency, | |
bool | callSetup = true | |||
) |
Specifies the samplerate frequency of the input signal.
Referenced by PitchACF().