The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
MHA_AC::spectrum_t Class Reference
Inheritance diagram for MHA_AC::spectrum_t:
Inheritance graph

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_toperator() (unsigned int f, unsigned int ch)
 Access to element. More...
 
mha_complex_toperator[] (unsigned int k)
 Access to a single element, direct index into data buffer. More...
 
mha_complex_tvalue (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_tac
 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_tbuf
 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_tchannel_info
 detailed channel description More...
 

Detailed Description

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).

Constructor & Destructor Documentation

◆ spectrum_t()

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.

Parameters
acAC handle
nameName of variable in AC space
binsNumber of FFT bins per channel in the spectrum_t class
channelsNumber of audio channels in the spectrum_t class
insert_nowIf 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.

◆ ~spectrum_t()

MHA_AC::spectrum_t::~spectrum_t ( )
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.

Member Function Documentation

◆ insert()

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.

◆ remove()

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.

Member Data Documentation

◆ ac

algo_comm_t& MHA_AC::spectrum_t::ac
protected

AC variable space.

◆ name

const std::string MHA_AC::spectrum_t::name
protected

Name of this AC variable in the AC variable space.

◆ remove_during_destructor

const bool MHA_AC::spectrum_t::remove_during_destructor
protected

flag whether to remove from AC variable space in destructor.


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