#include <PeakTracking.h>
Public Member Functions | |
PeakTracking (int trajectoryCount=20, Real maximumFrequencyChange=3.0, int silentFrameCount=3) | |
~PeakTracking () | |
void | process (const MatrixXC &ffts, const MatrixXR &peakPositions, const MatrixXR &peakMagnitudes, MatrixXR *trajectoryPositions, MatrixXR *trajectoryMagnitudes) |
int | trajectoryCount () const |
void | setTrajectoryCount (int count, bool callSetup=true) |
Real | maximumFrequencyChange () const |
void | setMaximumFrequencyChange (Real change, bool callSetup=true) |
int | silentFrameCount () const |
void | setSilentFrameCount (int count, bool callSetup=true) |
The algorithm finds a maximum number of peak trajectories and returns the positions of the trajectory positions (in fractional index units) and the trajectory magnitudes (in decibel units) in separate matrices.
The maximum number of trajectories can be specified using setTrajectoryCount().
The algorithm operates by matching the peaks in the current frames to the existing trajectories. During the matching process a maximum frequency change of a peak can be specified using setMaximumFrequencyChange().
The matching process also requires a trajectory to stay unmatched during a given number of frames for the trajectory to disappear and leave a slot for another trajectory to be found. The number fo silent frames can be specified using silentFrameCount().
PeakTracking | ( | int | trajectoryCount = 20 , |
|
Real | maximumFrequencyChange = 3.0 , |
|||
int | silentFrameCount = 3 | |||
) |
Constructs a peak tracking object with the given trajectoryCount, maximumFrequencyChange and silentFrameCount settings.
References setMaximumFrequencyChange(), setSilentFrameCount(), and setTrajectoryCount().
~PeakTracking | ( | ) |
Destroys the algorithm and frees its resources.
void process | ( | const MatrixXC & | ffts, | |
const MatrixXR & | peakPositions, | |||
const MatrixXR & | peakMagnitudes, | |||
MatrixXR * | trajectoryPositions, | |||
MatrixXR * | trajectoryMagnitudes | |||
) |
Tracks peaks on each of the rows of ffts, peakPositions, peakMagnitudes and puts the resulting trajectory indices and magnitudes in the rows of trajectoryPositions and trajectoryMagnitudes respectively.
ffts | matrix of Complex values representing the FFT frames. | |
peakPositions | matrix of Real values for the peak positions (in fractional index units). The matrix should have the same number of rows as ffts. | |
peakMagnitudes | matrix of Real values for the peak magnitudes (in decibel units). The matrix should have the same number of rows as ffts. | |
trajectoryPositions | pointer to a matrix of Real values for the trajectory positions (in fractional index units). The matrix should have the same number of rows as ffts and trajectoryCount columns. | |
trajectoryMagnitudes | pointer to a matrix of Real values for the trajectory magnitudes (in decibel units). The matrix should have the same number of rows as ffts and trajectoryCount columns. |
Note that if the output matrices are not of the required size they will be resized, reallocating a new memory space if necessary.
int trajectoryCount | ( | ) | const |
Returns the maximum number of trajectories to be detected by the algorithm.
By default it is 20.
void setTrajectoryCount | ( | int | count, | |
bool | callSetup = true | |||
) |
Specifies the maximum trajectory count to be detected by the algorithm. If <= 0, then all possible trajectories are detected.
count | the maximum number of trajectories to be tracked | |
callSetup | a flag specifying whether the setup() method must be called after setting the parameter. |
Referenced by PeakTracking().
Real maximumFrequencyChange | ( | ) | const |
Returns the maximum frequency change of a peak for it to be matched to an existing trajectory.
The change is specified in fractional index units.
By default it is 3.0.
void setMaximumFrequencyChange | ( | Real | change, | |
bool | callSetup = true | |||
) |
Specifies the maximum frequency change of a peak for it to be matched to an existing trajectory.
The change is specified in fractional index units.
change | the maximum changed allowed between a peak and an existing trajectory | |
callSetup | a flag specifying whether the setup() method must be called after setting the parameter. |
Referenced by PeakTracking().
int silentFrameCount | ( | ) | const |
Returns the count of frames a trajectory must stay unmatched for it to disappear and leave the slot for another possible trajectory.
By default it is 3.
void setSilentFrameCount | ( | int | count, | |
bool | callSetup = true | |||
) |
Specifies the count of frames a trajectory must stay unmatched for it to disappear and leave the slot for another possible trajectory.
count | the number of silent frames | |
callSetup | a flag specifying whether the setup() method must be called after setting the parameter. |
Referenced by PeakTracking().