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

Copy a fixed waveform fragment to a series of waveform fragments of other size. More...

Inheritance diagram for MHASignal::loop_wavefragment_t:
Inheritance graph

Public Types

enum  level_mode_t { relative , peak , rms , rms_limit40 }
 Switch for playback level mode. More...
 
enum  playback_mode_t { add , replace , input , mute }
 Switch for playback mode. More...
 

Public Member Functions

 loop_wavefragment_t (const mha_wave_t &src, bool loop, level_mode_t level_mode, std::vector< int > channels, unsigned int startpos=0)
 Constructor to create an instance of loop_wavefragment_t based on an existing waveform block. More...
 
std::vector< int > get_mapping (unsigned int channels)
 
void playback (mha_wave_t *s, playback_mode_t pmode, mha_wave_t *level_pa, const std::vector< int > &channels)
 Add source waveform block to an output block. More...
 
void playback (mha_wave_t *s, playback_mode_t pmode, mha_wave_t *level_pa)
 Add source waveform block to an output block. More...
 
void playback (mha_wave_t *s, playback_mode_t pmode)
 Add source waveform block to an output block. More...
 
void set_level_lin (mha_real_t l)
 
void set_level_db (mha_real_t l)
 
void rewind ()
 
void locate_end ()
 
bool is_playback_active () const
 
- 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...
 
virtual ~waveform_t (void)
 
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
 

Private Attributes

std::vector< int > playback_channels
 
bool b_loop
 
unsigned int pos
 
MHASignal::waveform_t intern_level
 

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

Copy a fixed waveform fragment to a series of waveform fragments of other size.

This class is designed to continously play back a waveform to an output stream, with variable output block size.

Member Enumeration Documentation

◆ level_mode_t

Switch for playback level mode.

Enumerator
relative 

The nominal level is applied as a gain to the source signal.

peak 

The nominal level is the peak level of source signal in Pascal.

rms 

The nominal level is the RMS level of the source signal in Pascal.

rms_limit40 

◆ playback_mode_t

Switch for playback mode.

Enumerator
add 

Add source signal to output stream.

replace 

Replace output stream by source signal.

input 

Do nothing, keep output stream (source position is unchanged).

mute 

Mute output stream (source position is unchanged).

Constructor & Destructor Documentation

◆ loop_wavefragment_t()

MHASignal::loop_wavefragment_t::loop_wavefragment_t ( const mha_wave_t src,
bool  loop,
level_mode_t  level_mode,
std::vector< int >  channels,
unsigned int  startpos = 0 
)

Constructor to create an instance of loop_wavefragment_t based on an existing waveform block.

Parameters
srcWaveform block to copy data from.
loopFlag whether the block should be looped or played once.
level_modeConfiguration of playback level (see MHASignal::loop_wavefragment_t::level_mode_t for details)
channelsMapping of input to output channels.
startposStarting position

Member Function Documentation

◆ get_mapping()

std::vector< int > MHASignal::loop_wavefragment_t::get_mapping ( unsigned int  channels)

◆ playback() [1/3]

void MHASignal::loop_wavefragment_t::playback ( mha_wave_t s,
playback_mode_t  pmode,
mha_wave_t level_pa,
const std::vector< int > &  channels 
)

Add source waveform block to an output block.

Parameters
sOutput block (streamed signal).
pmodePlayback mode (add, replace, input, mute).
level_paLinear output level/gain (depending on level_mode parameter in constructor); one value for each sample in output block.
channelsOutput channels

◆ playback() [2/3]

void MHASignal::loop_wavefragment_t::playback ( mha_wave_t s,
playback_mode_t  pmode,
mha_wave_t level_pa 
)

Add source waveform block to an output block.

Parameters
sOutput block (streamed signal).
pmodePlayback mode (add, replace, input, mute).
level_paLinear output level/gain (depending on level_mode parameter in constructor); one value for each sample in output block.

◆ playback() [3/3]

void MHASignal::loop_wavefragment_t::playback ( mha_wave_t s,
playback_mode_t  pmode 
)

Add source waveform block to an output block.

Parameters
sOutput block (streamed signal).
pmodePlayback mode (add, replace, input, mute).

◆ set_level_lin()

void MHASignal::loop_wavefragment_t::set_level_lin ( mha_real_t  l)

◆ set_level_db()

void MHASignal::loop_wavefragment_t::set_level_db ( mha_real_t  l)

◆ rewind()

void MHASignal::loop_wavefragment_t::rewind ( )
inline

◆ locate_end()

void MHASignal::loop_wavefragment_t::locate_end ( )
inline

◆ is_playback_active()

bool MHASignal::loop_wavefragment_t::is_playback_active ( ) const
inline

Member Data Documentation

◆ playback_channels

std::vector<int> MHASignal::loop_wavefragment_t::playback_channels
private

◆ b_loop

bool MHASignal::loop_wavefragment_t::b_loop
private

◆ pos

unsigned int MHASignal::loop_wavefragment_t::pos
private

◆ intern_level

MHASignal::waveform_t MHASignal::loop_wavefragment_t::intern_level
private

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