The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research

signal processing class for waveform data (based on mha_wave_t) More...

Inheritance diagram for MHASignal::waveform_t:
Inheritance graph

Public Member Functions

 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
 

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

signal processing class for waveform data (based on mha_wave_t)

Constructor & Destructor Documentation

◆ waveform_t() [1/5]

waveform_t::waveform_t ( const unsigned int &  frames,
const unsigned int &  channels 
)

constructor of waveform_t

Allocates buffer memory and initializes values to zero.

Parameters
framesnumber of frames in each channel
channelsnumber of channels

◆ waveform_t() [2/5]

waveform_t::waveform_t ( const mhaconfig_t cf)
explicit

Constructor to create a waveform from plugin configuration.

Parameters
cfPlugin configuration

◆ waveform_t() [3/5]

waveform_t::waveform_t ( const mha_wave_t src)
explicit

Copy contructor for mha_wave_t source.

◆ waveform_t() [4/5]

waveform_t::waveform_t ( const MHASignal::waveform_t src)

Copy contructor.

◆ waveform_t() [5/5]

waveform_t::waveform_t ( const std::vector< mha_real_t > &  src)

Copy contructor for std::vector<mha_real_t> source.

A waveform structure with a single channel is created, the length is equal to the number of elements in the source vector.

◆ ~waveform_t()

waveform_t::~waveform_t ( void  )
virtual

Reimplemented in MHA_AC::waveform_t.

Member Function Documentation

◆ flatten()

std::vector< mha_real_t > waveform_t::flatten ( ) const

◆ operator std::vector< mha_real_t >()

MHASignal::waveform_t::operator std::vector< mha_real_t > ( ) const
explicit

◆ operator=()

void MHASignal::waveform_t::operator= ( const mha_real_t v)
inline

◆ operator[]() [1/2]

mha_real_t& MHASignal::waveform_t::operator[] ( unsigned int  k)
inline

◆ operator[]() [2/2]

const mha_real_t& MHASignal::waveform_t::operator[] ( unsigned int  k) const
inline

◆ value() [1/2]

mha_real_t& MHASignal::waveform_t::value ( unsigned int  t,
unsigned int  ch 
)
inline

Element accessor.

Parameters
tFrame number
chChannel number
Returns
Reference to element

◆ operator()() [1/2]

mha_real_t& MHASignal::waveform_t::operator() ( unsigned int  t,
unsigned int  ch 
)
inline

Element accessor.

Parameters
tFrame number
chChannel number
Returns
Reference to element

◆ value() [2/2]

const mha_real_t& MHASignal::waveform_t::value ( unsigned int  t,
unsigned int  ch 
) const
inline

Constant element accessor.

Parameters
tFrame number
chChannel number
Returns
Reference to element

◆ operator()() [2/2]

const mha_real_t& MHASignal::waveform_t::operator() ( unsigned int  t,
unsigned int  ch 
) const
inline

Constant element accessor.

Parameters
tFrame number
chChannel number
Returns
Reference to element

◆ sum() [1/3]

mha_real_t waveform_t::sum ( const unsigned int &  a,
const unsigned int &  b 
)

sum of all elements between [a,b) in all channels

Parameters
astarting frame
bend frame (excluded)
Returns
sum

◆ sum() [2/3]

mha_real_t waveform_t::sum ( const unsigned int &  a,
const unsigned int &  b,
const unsigned int &  ch 
)

sum of all elements between [a,b) in channel ch

Parameters
astarting frame
bend frame (exluded)
chchannel number
Returns
sum

◆ sum() [3/3]

mha_real_t waveform_t::sum ( )

sum of all elements

Returns
sum of all elements

◆ sumsqr()

mha_real_t waveform_t::sumsqr ( )

sum of square of all elements

Returns
sum of square of all elements

◆ sum_channel()

mha_real_t waveform_t::sum_channel ( const unsigned int &  ch)

return sum of all elements in one channel

Parameters
chchannel number
Returns
sum

◆ assign() [1/2]

void waveform_t::assign ( const unsigned int &  k,
const unsigned int &  ch,
const mha_real_t val 
)

set frame "k" in channel "ch" to value "val"

Parameters
kframe number
chchannel number
valnew value

◆ assign() [2/2]

void waveform_t::assign ( const mha_real_t val)

set all elements to value

Parameters
valnew value

◆ assign_frame()

void waveform_t::assign_frame ( const unsigned int &  k,
const mha_real_t val 
)

assign value "val" to frame k in all channels

Parameters
kframe number
valnew value

◆ assign_channel()

void waveform_t::assign_channel ( const unsigned int &  ch,
const mha_real_t val 
)

assign value "val" to channel ch in all frames

Parameters
chchannel number
valnew value

◆ copy() [1/3]

void waveform_t::copy ( const std::vector< mha_real_t > &  v)

◆ copy() [2/3]

void waveform_t::copy ( const mha_wave_t src)

copy data from source into current waveform

Parameters
srcinput data (need to be same size as target)

◆ copy() [3/3]

void waveform_t::copy ( const mha_wave_t src)

◆ copy_channel()

void waveform_t::copy_channel ( const mha_wave_t src,
unsigned int  src_channel,
unsigned int  dest_channel 
)

Copy one channel of a given waveform signal to a target channel.

Parameters
srcInput waveform signal
src_channelChannel in source signal
dest_channelChannel number in destination signal

◆ copy_from_at()

void waveform_t::copy_from_at ( unsigned int  to_pos,
unsigned int  len,
const mha_wave_t src,
unsigned int  from_pos 
)

Copy part of the source signal into part of this waveform object.

Source and target have to have the same number of channels.

Parameters
to_posOffset in target
lenNumber of frames copied
srcSource
from_posOffset in source

◆ export_to()

void waveform_t::export_to ( mha_wave_t dest)

copy data into allocated mha_wave_t structure

Parameters
destdestination structure

◆ limit()

void waveform_t::limit ( const mha_real_t min,
const mha_real_t max 
)

limit target to range [min,max]

Parameters
minlower limit
maxupper limit

◆ power()

void waveform_t::power ( const waveform_t src)

transform waveform signal (in Pa) to squared signal (in W/m^2)

Parameters
srclinear waveform signal (in Pa)

◆ powspec()

void waveform_t::powspec ( const mha_spec_t src)

get the power spectrum (in W/m^2) from a complex spectrum

Parameters
srccomplex spectrum (normalized to Pa)

◆ scale() [1/2]

void waveform_t::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"

Parameters
astarting frame
bend frame (excluded)
chchannel number
valscale factor

◆ scale() [2/2]

void waveform_t::scale ( const unsigned int &  k,
const unsigned int &  ch,
const mha_real_t val 
)

scale one element

Parameters
kframe number
chchannel number
valscale factor

◆ scale_channel()

void waveform_t::scale_channel ( const unsigned int &  ch,
const mha_real_t src 
)

scale one channel of target with a scalar

Parameters
chchannel number
srcfactor

◆ scale_frame()

void waveform_t::scale_frame ( const unsigned int &  frame,
const mha_real_t val 
)

◆ get_size()

unsigned int MHASignal::waveform_t::get_size ( ) const
inline

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