#include <SpectralNoiseSuppression.h>
Public Member Functions | |
SpectralNoiseSuppression (int fftSize=1024, Real lowFrequency=50.0, Real highFrequency=6000.0, Real samplerate=44100.0) | |
~SpectralNoiseSuppression () | |
void | process (const MatrixXR &spectrums, MatrixXR *noises, MatrixXR *suppressed) |
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) |
This class represents an object to perform spectral noise suppresion on vectors of Real values. Which is a useful technique to keep only the peaks of a spectrum magnitude in harmonic sounds.
This implementation consists in estimating the spectral noise by performing a moving average on the power warped spectrum magnitude using varying bandwidths. The spectral noise is then removed from the original spectrum, clipping the result to zero to avoid negative values.
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().
SpectralNoiseSuppression | ( | int | fftSize = 1024 , |
|
Real | lowFrequency = 50.0 , |
|||
Real | highFrequency = 6000.0 , |
|||
Real | samplerate = 44100.0 | |||
) |
Constructs a spectral noise suppression object with the specified lowFrequency, highFrequency, samplerate and fftSize settings.
lowFrequency | low frequency used for the magnitude warping function, must be greater than zero 0 and lower than half the samplerate. | |
highFrequency | high frequency used for the magnitude warping function, must be greater than zero 0 and lower than half the samplerate. | |
samplerate | samplerate frequency of the input signal. | |
fftSize | size of the FFT. |
References setFftSize(), setHighFrequency(), setLowFrequency(), and setSamplerate().
Destroys the algorithm and frees its resources.
void process | ( | const MatrixXR & | spectrums, | |
MatrixXR * | noises, | |||
MatrixXR * | suppressed | |||
) |
Performs the estimation and suppression of the noise on each of the rows of spectrums. Puts the resulting noise spectrums and noise-suppressed spectrums 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(). | |
noises | pointer to a matrix of Real values representing one noise spectrum per row. The matrix should have the same number of rows and columns as spectrums. | |
suppressed | pointer to a matrix of Real values representing one noise-suppressed spectrum per row. The matrix should have the same number of rows and columns as spectrums. |
References Bands::process().
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 SpectralNoiseSuppression().
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 SpectralNoiseSuppression().
Real samplerate | ( | ) | const |
void setSamplerate | ( | Real | frequency, | |
bool | callSetup = true | |||
) |
Specifies the samplerate frequency of the input signal.
Referenced by SpectralNoiseSuppression().
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 SpectralNoiseSuppression().