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

Public Member Functions

 waveform_t (algo_comm_t &ac, const std::string &name, unsigned int frames, unsigned int channels, bool insert_now)
 Initialize memory and metadata of the AC variable. More...
 
 ~waveform_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::waveform_t
 waveform_t (const unsigned int &frames, const unsigned int &channels)
 constructor of waveform_t More...
 
 waveform_t (const mhaconfig_t &cf)
 Constructor to create a waveform from plugin configuration. More...
 
 waveform_t (const mha_wave_t &src)
 Copy contructor for mha_wave_t source. More...
 
 waveform_t (const MHASignal::waveform_t &src)
 Copy contructor. More...
 
 waveform_t (const std::vector< mha_real_t > &src)
 Copy contructor for std::vector<mha_real_t> source. More...
 
std::vector< mha_real_tflatten () const
 
 operator std::vector< mha_real_t > () const
 
void operator= (const mha_real_t &v)
 
mha_real_toperator[] (unsigned int k)
 
const mha_real_toperator[] (unsigned int k) const
 
mha_real_tvalue (unsigned int t, unsigned int ch)
 Element accessor. More...
 
mha_real_toperator() (unsigned int t, unsigned int ch)
 Element accessor. More...
 
const mha_real_tvalue (unsigned int t, unsigned int ch) const
 Constant element accessor. More...
 
const mha_real_toperator() (unsigned int t, unsigned int ch) const
 Constant element accessor. More...
 
mha_real_t sum (const unsigned int &a, const unsigned int &b)
 sum of all elements between [a,b) in all channels More...
 
mha_real_t sum (const unsigned int &a, const unsigned int &b, const unsigned int &ch)
 sum of all elements between [a,b) in channel ch More...
 
mha_real_t sum ()
 sum of all elements More...
 
mha_real_t sumsqr ()
 sum of square of all elements More...
 
mha_real_t sum_channel (const unsigned int &)
 return sum of all elements in one channel More...
 
void assign (const unsigned int &k, const unsigned int &ch, const mha_real_t &val)
 set frame "k" in channel "ch" to value "val" More...
 
void assign (const mha_real_t &)
 set all elements to value More...
 
void assign_frame (const unsigned int &k, const mha_real_t &val)
 assign value "val" to frame k in all channels More...
 
void assign_channel (const unsigned int &c, const mha_real_t &val)
 assign value "val" to channel ch in all frames More...
 
void copy (const std::vector< mha_real_t > &v)
 
void copy (const mha_wave_t &)
 copy data from source into current waveform More...
 
void copy (const mha_wave_t *)
 
void copy_channel (const mha_wave_t &, unsigned int, unsigned int)
 Copy one channel of a given waveform signal to a target channel. More...
 
void copy_from_at (unsigned int, unsigned int, const mha_wave_t &, unsigned int)
 Copy part of the source signal into part of this waveform object. More...
 
void export_to (mha_wave_t &)
 copy data into allocated mha_wave_t structure More...
 
void limit (const mha_real_t &min, const mha_real_t &max)
 limit target to range [min,max] More...
 
void power (const waveform_t &)
 transform waveform signal (in Pa) to squared signal (in W/m^2) More...
 
void powspec (const mha_spec_t &)
 get the power spectrum (in W/m^2) from a complex spectrum More...
 
void scale (const unsigned int &a, const unsigned int &b, const unsigned int &ch, const mha_real_t &val)
 scale section [a,b) in channel "ch" by "val" More...
 
void scale (const unsigned int &k, const unsigned int &ch, const mha_real_t &val)
 scale one element More...
 
void scale_channel (const unsigned int &, const mha_real_t &)
 scale one channel of target with a scalar More...
 
void scale_frame (const unsigned int &, const mha_real_t &)
 
unsigned int get_size () const
 

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_wave_t
mha_real_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 waveform (a block of time-domain audio signal) into the AC space.

In MHA, waveforms are stored interleaved: The first sample of the first is followed by the first samples of all other channels before the second sample of the first sample is stored, etc.

The stride of the AC variable is set to the number of audio channels.

Constructor & Destructor Documentation

◆ waveform_t()

MHA_AC::waveform_t::waveform_t ( algo_comm_t ac,
const std::string &  name,
unsigned int  frames,
unsigned int  channels,
bool  insert_now 
)

Initialize memory and metadata of the AC variable.

All audio samples are initially set to 0.

Parameters
acAC handle
nameName of variable in AC space
framesNumber of samples per channel in the waveform_t class
channelsNumber of audio channels in the waveform_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.

◆ ~waveform_t()

MHA_AC::waveform_t::~waveform_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::waveform_t.

Member Function Documentation

◆ insert()

void MHA_AC::waveform_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::waveform_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::waveform_t::ac
protected

AC variable space.

◆ name

const std::string MHA_AC::waveform_t::name
protected

Name of this AC variable in the AC variable space.

◆ remove_during_destructor

const bool MHA_AC::waveform_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: