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

Schroeder tone complex class. More...

Inheritance diagram for MHASignal::schroeder_t:
Inheritance graph

Public Types

enum  sign_t { up , down }
 Enumerator for sign of Schroeder tone complex sweep direction. More...
 
typedef float(* groupdelay_t) (float f, float fmin, float fmax)
 Function type for group delay definition. More...
 

Public Member Functions

 schroeder_t (unsigned int len, unsigned int channels=1, schroeder_t::sign_t sign=up, mha_real_t speed=1)
 Constructor. More...
 
 schroeder_t (unsigned int len, unsigned int channels=1, schroeder_t::groupdelay_t freqfun=MHASignal::schroeder_t::identity, float fmin=0, float fmax=1, float eps=1e-10)
 Construct create Schroeder tone complex from a given frequency function. 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...
 
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
 

Static Public Member Functions

static float identity (float x, float, float)
 
static float log_up (float x, float fmin, float fmax)
 
static float log_down (float x, float fmin, float fmax)
 

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

Schroeder tone complex class.

The Schroeder tone complex is a sweep defined in the sampled spectrum:

\[ \Phi(f) = \sigma 2\pi \tau (2f/f_s)^{2\alpha},\quad S(f) = e^{i\Phi(f)} \]

$f$ is the sampled frequency in Hz, $\sigma$ is the sign of the sweep (-1 for up sweep, +1 for down sweep), $\tau$ is the sweep duration in samples, $f_s$ is the sampling rate in Hz and $\alpha$ is the relative sweep speed.

Member Typedef Documentation

◆ groupdelay_t

typedef float(* MHASignal::schroeder_t::groupdelay_t) (float f, float fmin, float fmax)

Function type for group delay definition.

Parameters
fFrequency relative to Nyquist frequency.
fminMinimum frequency relative to Nyquist frequency.
fmaxMaximum frequency relative to Nyquist frequency.

Member Enumeration Documentation

◆ sign_t

Enumerator for sign of Schroeder tone complex sweep direction.

Enumerator
up 

Sweep from zero to Nyquist frequency ( $\sigma = -1$)

down 

Sweep from Nyquist frequency to zero ( $\sigma = +1$)

Constructor & Destructor Documentation

◆ schroeder_t() [1/2]

MHASignal::schroeder_t::schroeder_t ( unsigned int  len,
unsigned int  channels = 1,
schroeder_t::sign_t  sign = up,
mha_real_t  speed = 1 
)

Constructor.

Parameters of the Schroeder tone complex are configured in the constructor.

Parameters
lenLength $\tau$ of the Schroeder tone complex in samples
channelsNumber of channels
signSign $\sigma$ of Schroeder sweep
speedRelative speed $\alpha$ (curvature of phase function)

◆ schroeder_t() [2/2]

MHASignal::schroeder_t::schroeder_t ( unsigned int  len,
unsigned int  channels = 1,
schroeder_t::groupdelay_t  freqfun = MHASignal::schroeder_t::identity,
float  fmin = 0,
float  fmax = 1,
float  eps = 1e-10 
)

Construct create Schroeder tone complex from a given frequency function.

The frequency function $g(f)$ defines the sweep speed and sign (based on the group delay). It must be defined in the interval [0,1) and should return values in the interval [0,1].

\[ \Phi(f) = -4\pi\tau\int\limits_0^\tau g(f)\, {\textrm{d}}f,\quad S(f) = e^{i\Phi(f)} \]

Parameters
lenLength $\tau$ of the Schroeder tone complex in samples.
channelsNumber of channels.
freqfunFrequency function $g(f)$.
fminStart frequency (relative to Nyquist frequency).
fmaxEnd frequency (relative to Nyquist frequency).
epsStability constant for frequency ranges not covered by Schroeder tone complex.

Member Function Documentation

◆ identity()

static float MHASignal::schroeder_t::identity ( float  x,
float  ,
float   
)
inlinestatic

◆ log_up()

static float MHASignal::schroeder_t::log_up ( float  x,
float  fmin,
float  fmax 
)
inlinestatic

◆ log_down()

static float MHASignal::schroeder_t::log_down ( float  x,
float  fmin,
float  fmax 
)
inlinestatic

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