The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHAFilter::smoothspec_t Class Reference

Smooth spectral gains, create a windowed impulse response. More...

Public Member Functions

 smoothspec_t (unsigned int fftlen, unsigned int nchannels, const MHAWindow::base_t &window, bool minphase, bool linphase_asym=false)
 Constructor. More...
 
void smoothspec (const mha_spec_t &s_in, mha_spec_t &s_out)
 Create a smoothed spectrum. More...
 
void smoothspec (mha_spec_t &spec)
 Create a smoothed spectrum (in place) More...
 
void spec2fir (const mha_spec_t &spec, mha_wave_t &fir)
 Return FIR coefficients. More...
 
 ~smoothspec_t ()
 

Private Member Functions

void internal_fir (const mha_spec_t &)
 

Private Attributes

unsigned int fftlen
 
unsigned int nchannels
 
MHAWindow::base_t window
 
MHASignal::waveform_t tmp_wave
 
MHASignal::spectrum_t tmp_spec
 
MHASignal::minphase_tminphase
 
bool _linphase_asym
 
mha_fft_t fft
 

Detailed Description

Smooth spectral gains, create a windowed impulse response.

Spectral gains are smoothed by multiplying the impulse response with a window function.

If a minimal phase is used, then the original phase is discarded and replaced by the minimal phase function. In this case, the window is applied to the beginning of the inverse Fourier transform of the input spectrum, and the remaining signal set to zero. If the original phase is kept, the window is applied symmetrically arround zero, i.e. to the first and last samples of the inverse Fourier transform of the input spectrum. The spec2fir() function creates a causal impulse response by circularly shifting the impulse response by half of the window length.

The signal dimensions of the arguments of smoothspec() must correspond to the FFT length and number of channels provided in the constructor. The function spec2fir() can fill signal structures with more than window length frames.

Constructor & Destructor Documentation

◆ smoothspec_t()

MHAFilter::smoothspec_t::smoothspec_t ( unsigned int  fftlen,
unsigned int  nchannels,
const MHAWindow::base_t window,
bool  minphase,
bool  linphase_asym = false 
)

Constructor.

Parameters
fftlenFFT length of input spectrum (fftlen/2+1 bins)
nchannelsNumber of channels in input spectrum
windowWindow used for smoothing
minphaseUse minimal phase (true) or original phase (false)
linphase_asymKeep phase, but apply full window at beginning of IRS

◆ ~smoothspec_t()

MHAFilter::smoothspec_t::~smoothspec_t ( )

Member Function Documentation

◆ smoothspec() [1/2]

void MHAFilter::smoothspec_t::smoothspec ( const mha_spec_t s_in,
mha_spec_t s_out 
)

Create a smoothed spectrum.

Parameters
s_inInput spectrum
Return values
s_outOutput spectrum

◆ smoothspec() [2/2]

void MHAFilter::smoothspec_t::smoothspec ( mha_spec_t spec)
inline

Create a smoothed spectrum (in place)

Parameters
specSpectrum to be smoothed.

◆ spec2fir()

void MHAFilter::smoothspec_t::spec2fir ( const mha_spec_t spec,
mha_wave_t fir 
)

Return FIR coefficients.

Parameters
specInput spectrum
Return values
firFIR coefficients, minimum length is window length

◆ internal_fir()

void MHAFilter::smoothspec_t::internal_fir ( const mha_spec_t s_in)
private

Member Data Documentation

◆ fftlen

unsigned int MHAFilter::smoothspec_t::fftlen
private

◆ nchannels

unsigned int MHAFilter::smoothspec_t::nchannels
private

◆ window

MHAWindow::base_t MHAFilter::smoothspec_t::window
private

◆ tmp_wave

MHASignal::waveform_t MHAFilter::smoothspec_t::tmp_wave
private

◆ tmp_spec

MHASignal::spectrum_t MHAFilter::smoothspec_t::tmp_spec
private

◆ minphase

MHASignal::minphase_t* MHAFilter::smoothspec_t::minphase
private

◆ _linphase_asym

bool MHAFilter::smoothspec_t::_linphase_asym
private

◆ fft

mha_fft_t MHAFilter::smoothspec_t::fft
private

The documentation for this class was generated from the following files: