#include <MelBands.h>
Public Types | |
enum | ScaleType { STEVENS = 0, FANT = 1, GREENWOOD = 2 } |
Specifies the type of the scale used. More... | |
Public Member Functions | |
MelBands (Real lowFrequency=50.0, Real highFrequency=6000.0, int bandCount=40, Real samplerate=44100.0, int fftSize=1024, ScaleType scaleType=GREENWOOD) | |
void | process (const MatrixXR &spectrums, MatrixXR *bands) |
std::vector< MatrixXR > | weights () const |
void | bandWeights (int band, MatrixXR *bandWeights) const |
void | starts (MatrixXI *result) const |
int | bands () const |
void | centers (MatrixXR *result) const |
int | bandCount () const |
void | setBandCount (int count, bool callSetup=true) |
Real | lowFrequency () const |
void | setLowFrequency (Real frequency, bool callSetup=true) |
Real | highFrequency () const |
void | setHighFrequency (Real frequency, bool callSetup=true) |
Real | samplerate () const |
void | setSamplerate (Real frequency, bool callSetup=true) |
int | fftSize () const |
void | setFftSize (int size, bool callSetup=true) |
MelBands::ScaleType | scaleType () const |
void | setScaleType (MelBands::ScaleType type, bool callSetup=true) |
This class represents an object to Mel bands on vectors of Real values. This method is a special case of the Bands algorithm and is used in many other spectral algorithms such as MFCC and SpectralWhitening.
The method consists in a set triangular 50% overlapping windows spaced evenly on a Mel-frequency scale.
The samplerate and FFT size of the input spectrum are specified using setSamplerate() and setFftSize().
The frequency limits of the Mel scale mapping are specified using setLowFrequency() and setHighFrequency().
The number of bands is specified using setBandCount().
enum ScaleType |
Specifies the type of the scale used.
MelBands | ( | Real | lowFrequency = 50.0 , |
|
Real | highFrequency = 6000.0 , |
|||
int | bandCount = 40 , |
|||
Real | samplerate = 44100.0 , |
|||
int | fftSize = 1024 , |
|||
ScaleType | scaleType = GREENWOOD | |||
) |
Constructs a Mel bands object with the specified lowFrequency, highFrequency, bandCount, samplerate, fftSize and scaleType settings.
lowFrequency | frequency of the lowest Mel band, must be greater than zero 0 and lower than half the samplerate. | |
highFrequency | frequency of the highest Mel band, must be greater than zero 0 and lower than half the samplerate. | |
bandCount | number of Mel bands. | |
samplerate | samplerate frequency of the input signal. | |
fftSize | size of the FFT. | |
scaleType | scale used for the frequency warping. |
References setBandCount(), setFftSize(), setHighFrequency(), setLowFrequency(), setSamplerate(), and setScaleType().
void process | ( | const MatrixXR & | spectrums, | |
MatrixXR * | bands | |||
) |
Calculates the bands of spectrums.
spectrums | matrix of Real values. | |
bands | pointer to a matrix of Real values for the output. The matrix should have the same number of rows as spectrums and as many columns as the number of bands as specified by bandCount. |
References Bands::process().
Referenced by SpectralWhitening::process(), and MFCC::process().
std::vector< MatrixXR > weights | ( | ) | const |
Return the vector of weights.
References Bands::weights().
void bandWeights | ( | int | band, | |
MatrixXR * | bandWeights | |||
) | const |
Return in bandWeights the weights of the band given by the index band.
References Bands::bandWeights().
void starts | ( | MatrixXI * | result | ) | const |
Return in result the single column matrix of start indices of the bands.
References Bands::starts().
int bands | ( | ) | const |
Return number of bands.
References Bands::bands().
void centers | ( | MatrixXR * | result | ) | const |
Return in result the single column matrix of center fractional indices of the bands.
int bandCount | ( | ) | const |
void setBandCount | ( | int | count, | |
bool | callSetup = true | |||
) |
Real lowFrequency | ( | ) | const |
Return the low frequency of the spectral whitening. The default is 50.0.
void setLowFrequency | ( | Real | frequency, | |
bool | callSetup = true | |||
) |
Specifies the low frequency of the spectral whitening. The given frequency must be in the range of 0 to the samplerate / 2.
Referenced by MelBands().
Real highFrequency | ( | ) | const |
Return the high frequency of the spectral whitening. The default is 6000.0.
void setHighFrequency | ( | Real | frequency, | |
bool | callSetup = true | |||
) |
Specifies the high frequency of the spectral whitening. The given frequency must be in the range of 0 to the samplerate / 2.
Referenced by MelBands().
Real samplerate | ( | ) | const |
void setSamplerate | ( | Real | frequency, | |
bool | callSetup = true | |||
) |
Specifies the samplerate frequency of the input signal.
Referenced by MelBands().
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 MelBands().
MelBands::ScaleType scaleType | ( | ) | const |
void setScaleType | ( | MelBands::ScaleType | type, | |
bool | callSetup = true | |||
) |