The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
Convenience class for inserting a spectrum into the AC space. More...
Public Member Functions | |
spectrum_t (algo_comm_t &ac, const std::string &name, unsigned int bins, unsigned int channels, bool insert_now) | |
Initialize memory and metadata of the AC variable. More... | |
~spectrum_t () | |
Destroy the AC variable: deallocate its memory. More... | |
void | insert () |
Insert or re-insert AC variable into AC space. More... | |
void | remove () |
Remove the AC variable by reference from the AC variable space. More... | |
Public Member Functions inherited from MHASignal::spectrum_t | |
spectrum_t (const unsigned int &frames, const unsigned int &channels) | |
constructor of spectrum class More... | |
spectrum_t (const mha_spec_t &) | |
Copy constructor. More... | |
spectrum_t (const MHASignal::spectrum_t &) | |
Copy constructor. More... | |
spectrum_t (const std::vector< mha_complex_t > &) | |
mha_complex_t & | operator() (unsigned int f, unsigned int ch) |
Access to element. More... | |
mha_complex_t & | operator[] (unsigned int k) |
Access to a single element, direct index into data buffer. More... | |
mha_complex_t & | value (unsigned int f, unsigned int ch) |
Access to element. More... | |
void | copy (const mha_spec_t &) |
copy all elements from a spectrum More... | |
void | copy_channel (const mha_spec_t &s, unsigned sch, unsigned dch) |
Copy one channel of a given spectrum signal to a target channel. More... | |
void | export_to (mha_spec_t &) |
copy elements to spectrum structure More... | |
void | scale (const unsigned int &, const unsigned int &, const unsigned int &, const mha_real_t &) |
scale section [a,b) in channel "ch" by "val" More... | |
void | scale_channel (const unsigned int &, const mha_real_t &) |
scale all elements in one channel More... | |
Protected Attributes | |
algo_comm_t & | ac |
AC variable space. More... | |
const std::string | name |
Name of this AC variable in the AC variable space. More... | |
const bool | remove_during_destructor |
flag whether to remove from AC variable space in destructor. More... | |
Additional Inherited Members | |
Public Attributes inherited from mha_spec_t | |
mha_complex_t * | buf |
signal buffer More... | |
unsigned int | num_channels |
number of channels More... | |
unsigned int | num_frames |
number of frames in each channel More... | |
mha_channel_info_t * | channel_info |
detailed channel description More... | |
Convenience class for inserting a spectrum into the AC space.
In MHA, spectra are stored non-interleaved: First all bins of the first channel are stored, then all bins of the second channel, etc.
The stride of the AC variable is set to the number of stored bins, which is equal to floor(fftlen/2)+1 in MHA (negative frequency bins are not stored).
MHA_AC::spectrum_t::spectrum_t | ( | algo_comm_t & | ac, |
const std::string & | name, | ||
unsigned int | bins, | ||
unsigned int | channels, | ||
bool | insert_now | ||
) |
Initialize memory and metadata of the AC variable.
All spectral bins are initially set to 0.
ac | AC handle |
name | Name of variable in AC space |
bins | Number of FFT bins per channel in the spectrum_t class |
channels | Number of audio channels in the spectrum_t class |
insert_now | If true, then the constructor inserts the new variable into the AC space, and the destructor will remove the variable from AC space when it executes. |
|
virtual |
Destroy the AC variable: deallocate its memory.
If the constructor parameter insert_now was true, then the destruc- tor removes the AC variable from AC space when it executes.
Reimplemented from MHASignal::spectrum_t.
void MHA_AC::spectrum_t::insert | ( | ) |
Insert or re-insert AC variable into AC space.
Plugins should call this method from their prepare() and process() functions.
void MHA_AC::spectrum_t::remove | ( | ) |
Remove the AC variable by reference from the AC variable space.
Plugins may call this method only from their prepare(), release() methods or their plugin destructor. It is not necessary to remove the AC variable from AC space at all if either another AC variable with the same name has replaced this variable before this variable is destroyed, or if no plugin will access this variable between its destruction and either its replacement or the MHA exit.
|
protected |
AC variable space.
|
protected |
Name of this AC variable in the AC variable space.
|
protected |
flag whether to remove from AC variable space in destructor.