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

Runtime configuration class of dynamic compression plugin dc. More...

Inheritance diagram for dc::dc_t:
Inheritance graph

Public Member Functions

 dc_t (dc_vars_t vars, mha_real_t filter_rate, unsigned int nch_, MHA_AC::algo_comm_t &ac, mha_domain_t domain, unsigned int fftlen, unsigned int naudiochannels_, const std::string &configured_name, const std::vector< mha_real_t > &rmslevel_state={}, const std::vector< mha_real_t > &attack_state={}, const std::vector< mha_real_t > &decay_state={})
 Constructor. More...
 
mha_wave_tprocess (mha_wave_t *s_in)
 Process method extracts band-specific input levels using the rmslevel, attack and decay filters on each input sample, looks up the gains and applies them to each sample of the signal in place. More...
 
mha_spec_tprocess (mha_spec_t *s_in)
 Process method extracts band-specific input levels using the attack and decay filters on the latest STFT spectrum, looks up the gains and applies them in place. More...
 
void explicit_insert ()
 
unsigned get_nbands () const
 
unsigned get_nch () const
 
const MHASignal::waveform_tget_level_in_db () const
 
const MHASignal::waveform_tget_level_in_db_adjusted () const
 
std::vector< mha_real_tget_rmslevel_filter_state () const
 
std::vector< mha_real_tget_attack_filter_state () const
 
std::vector< mha_real_tget_decay_filter_state () const
 

Private Attributes

std::vector< MHATableLookup::linear_table_tgt
 Dynamic compression gains. More...
 
std::vector< mha_real_toffset
 band-specific dB offsets added to measured input levels before gain lookup is performed. More...
 
MHAFilter::o1flt_lowpass_t rmslevel
 Envelope extraction filters used in waveform processing. More...
 
MHAFilter::o1flt_lowpass_t attack
 Attack filters used in input level estimation. More...
 
MHAFilter::o1flt_maxtrack_t decay
 Maximum-tracking decay filters used in input level estimation. More...
 
bool bypass
 Dynamic compression is not applied if bypass == true. More...
 
bool log_interp
 Flag whether gain table interpolation should be done in dB domain. More...
 
unsigned int naudiochannels
 Number of broadband audio channels (before the upstream filterbank) More...
 
unsigned int nbands
 Number of bands per broadband audio channel. More...
 
unsigned int nch
 nbands * naudiochannels More...
 
MHA_AC::waveform_t level_in_db
 Matrix of latest input levels before attack/decay filter. More...
 
MHA_AC::waveform_t level_in_db_adjusted
 Matrix of latest input levels after attack/decay filter. More...
 
unsigned int fftlen
 FFT length in samples, required for computing levels correctly. More...
 

Additional Inherited Members

- Private Member Functions inherited from dc::dc_vars_validator_t
 dc_vars_validator_t (dc_vars_t &v, unsigned int s, mha_domain_t domain)
 Expands vectors in v, checks for consistency. More...
 

Detailed Description

Runtime configuration class of dynamic compression plugin dc.

Constructor & Destructor Documentation

◆ dc_t()

dc::dc_t::dc_t ( dc_vars_t  vars,
mha_real_t  filter_rate,
unsigned int  nch_,
MHA_AC::algo_comm_t ac,
mha_domain_t  domain,
unsigned int  fftlen,
unsigned int  naudiochannels_,
const std::string &  configured_name,
const std::vector< mha_real_t > &  rmslevel_state = {},
const std::vector< mha_real_t > &  attack_state = {},
const std::vector< mha_real_t > &  decay_state = {} 
)

Constructor.

Parameters
varsA copy of all configuration language variables of dc.
filter_rateThe rate in Hz with which the level filters of plugin dc are called. For waveform processing this is equal to the audio sampling rate. For spectral processing, this is equal to the audio block rate.
nch_Total number of compression bands: bands x channels.
acAlgorithm communication variable space. The constructor will not interact with it.
domainMHA_WAVEFORM or MHA_SPECTRUM.
fftlenFFT length used for STFT processing, in samples.
naudiochannels_Number of broadband audio channels (before the upstream filterbank).
configured_nameThe configured name of this plugin in the MHA configuration. Used to derive the names of the AC variables published by this plugin.
rmslevel_stateStart state of rmslevel filters.
attack_stateStart state of attack level filters.
decay_stateStart state of decay level filters.

Member Function Documentation

◆ process() [1/2]

mha_wave_t * dc_t::process ( mha_wave_t s_in)

Process method extracts band-specific input levels using the rmslevel, attack and decay filters on each input sample, looks up the gains and applies them to each sample of the signal in place.

Parameters
s_inLatest block of time-domain input signal.
Returns
s_in after modifying the signal in place.

◆ process() [2/2]

mha_spec_t * dc_t::process ( mha_spec_t s_in)

Process method extracts band-specific input levels using the attack and decay filters on the latest STFT spectrum, looks up the gains and applies them in place.

Parameters
s_inLatest spectrum of the STFT input signal.
Returns
s_in after modifying the signal in place.

◆ explicit_insert()

void dc_t::explicit_insert ( )

◆ get_nbands()

unsigned dc::dc_t::get_nbands ( ) const
inline
Returns
Number of frequency bands per broadband input channels.

◆ get_nch()

unsigned dc::dc_t::get_nch ( ) const
inline
Returns
Number of frequency bands times broadband input channels.

◆ get_level_in_db()

const MHASignal::waveform_t& dc::dc_t::get_level_in_db ( ) const
inline
Returns
Const reference to the Matrix of input levels as computed before processed by the attack/decay filter.

◆ get_level_in_db_adjusted()

const MHASignal::waveform_t& dc::dc_t::get_level_in_db_adjusted ( ) const
inline
Returns
Const reference to the Matrix of input levels after being filtered by the attack/decay filter.

◆ get_rmslevel_filter_state()

std::vector<mha_real_t> dc::dc_t::get_rmslevel_filter_state ( ) const
inline
Returns
Filter states of first-order rmslevel low-pass filters.

◆ get_attack_filter_state()

std::vector<mha_real_t> dc::dc_t::get_attack_filter_state ( ) const
inline
Returns
Filter states of first-order attack low-pass filters.

◆ get_decay_filter_state()

std::vector<mha_real_t> dc::dc_t::get_decay_filter_state ( ) const
inline
Returns
Filter states of max-tracking decay low-pass filters.

Member Data Documentation

◆ gt

std::vector<MHATableLookup::linear_table_t> dc::dc_t::gt
private

Dynamic compression gains.

If log_interp is true, then they are stored as dB gains, otherwise they are stored as linear gains.

◆ offset

std::vector<mha_real_t> dc::dc_t::offset
private

band-specific dB offsets added to measured input levels before gain lookup is performed.

◆ rmslevel

MHAFilter::o1flt_lowpass_t dc::dc_t::rmslevel
private

Envelope extraction filters used in waveform processing.

◆ attack

MHAFilter::o1flt_lowpass_t dc::dc_t::attack
private

Attack filters used in input level estimation.

◆ decay

MHAFilter::o1flt_maxtrack_t dc::dc_t::decay
private

Maximum-tracking decay filters used in input level estimation.

◆ bypass

bool dc::dc_t::bypass
private

Dynamic compression is not applied if bypass == true.

◆ log_interp

bool dc::dc_t::log_interp
private

Flag whether gain table interpolation should be done in dB domain.

◆ naudiochannels

unsigned int dc::dc_t::naudiochannels
private

Number of broadband audio channels (before the upstream filterbank)

◆ nbands

unsigned int dc::dc_t::nbands
private

Number of bands per broadband audio channel.

◆ nch

unsigned int dc::dc_t::nch
private

nbands * naudiochannels

◆ level_in_db

MHA_AC::waveform_t dc::dc_t::level_in_db
private

Matrix of latest input levels before attack/decay filter.

◆ level_in_db_adjusted

MHA_AC::waveform_t dc::dc_t::level_in_db_adjusted
private

Matrix of latest input levels after attack/decay filter.

◆ fftlen

unsigned int dc::dc_t::fftlen
private

FFT length in samples, required for computing levels correctly.


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