#include <SpectralWhitening.h>
Public Member Functions | |
SpectralWhitening (int fftSize=1024, Real lowFrequency=50.0, Real highFrequency=6000.0, Real samplerate=44100.0, Real compressionFactor=0.33, int bandCount=40, MelBands::ScaleType scaleType=MelBands::GREENWOOD) | |
~SpectralWhitening () | |
void | process (const MatrixXR &spectrums, MatrixXR *whitened) |
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) |
Real | compressionFactor () const |
void | setCompressionFactor (Real factor, bool callSetup=true) |
This class represents an object to perform spectral whitening on vectors of Real values. Which is a useful technique to make the peaks of a spectrum magnitude stand out in harmonic sounds.
This implementation consists in calculating the Mel bands and create a linear interpolation between these to be used as a wheighting parameter of the spectrum's compression.
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 Mel bands is specified using setBandCount().
The compression factor of the whitening process is specified by setCompressionFactor().
SpectralWhitening | ( | int | fftSize = 1024 , |
|
Real | lowFrequency = 50.0 , |
|||
Real | highFrequency = 6000.0 , |
|||
Real | samplerate = 44100.0 , |
|||
Real | compressionFactor = 0.33 , |
|||
int | bandCount = 40 , |
|||
MelBands::ScaleType | scaleType = MelBands::GREENWOOD | |||
) |
Constructs a spectral whitening object with the specified lowFrequency, highFrequency, bandCount, samplerate, fftSize, compressionFactor 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. | |
compressionFactor | factor of the compression process in the whitening. | |
scaleType | scale used for the frequency warping. |
References setBandCount(), setCompressionFactor(), setFftSize(), setHighFrequency(), setLowFrequency(), setSamplerate(), and setScaleType().
~SpectralWhitening | ( | ) |
Destroys the algorithm and frees its resources.
void process | ( | const MatrixXR & | spectrums, | |
MatrixXR * | whitened | |||
) |
Performs a whitening on each of the rows of spectrums. Puts the resulting whitened spectrum in the rows of whitened.
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(). | |
whitened | pointer to a matrix of Real values representing one whitened spectrum per row. The matrix should have the same number of rows and columns as spectrums. |
References MelBands::process().
int bandCount | ( | ) | const |
void setBandCount | ( | int | count, | |
bool | callSetup = true | |||
) |
Specifies the count of bands to be performed.
Referenced by SpectralWhitening().
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 SpectralWhitening().
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 SpectralWhitening().
Real samplerate | ( | ) | const |
void setSamplerate | ( | Real | frequency, | |
bool | callSetup = true | |||
) |
Specifies the samplerate frequency of the input signal.
Referenced by SpectralWhitening().
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 SpectralWhitening().
MelBands::ScaleType scaleType | ( | ) | const |
void setScaleType | ( | MelBands::ScaleType | type, | |
bool | callSetup = true | |||
) |
Specify the type of the frequency warping scale.
Referenced by SpectralWhitening().
Real compressionFactor | ( | ) | const |
void setCompressionFactor | ( | Real | factor, | |
bool | callSetup = true | |||
) |
Specifies the compression factor of the whitening.
Referenced by SpectralWhitening().