The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
Reads sound from file and resamples it if necessary and wanted. More...
Public Member Functions | |
resampled_soundfile_t (const std::string &name, float mha_sampling_rate, addsndfile_resampling_mode_t resampling_mode) | |
Reads sound from file and resamples if necessary and wanted. More... | |
Public Member Functions inherited from addsndfile::waveform_proxy_t | |
waveform_proxy_t (unsigned frames, unsigned channels) | |
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_t > | flatten () const |
operator std::vector< mha_real_t > () const | |
void | operator= (const mha_real_t &v) |
mha_real_t & | operator[] (unsigned int k) |
const mha_real_t & | operator[] (unsigned int k) const |
mha_real_t & | value (unsigned int t, unsigned int ch) |
Element accessor. More... | |
mha_real_t & | operator() (unsigned int t, unsigned int ch) |
Element accessor. More... | |
const mha_real_t & | value (unsigned int t, unsigned int ch) const |
Constant element accessor. More... | |
const mha_real_t & | operator() (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_t * | buf |
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_t * | channel_info |
detailed channel description More... | |
Private Member Functions inherited from MHASndFile::sf_wave_t | |
sf_wave_t (const std::string &fname, mha_real_t peaklevel_db, unsigned int maxlen=std::numeric_limits< unsigned int >::max(), unsigned int startpos=0, std::vector< int > channel_map=std::vector< int >()) | |
Private 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_t > | flatten () const |
operator std::vector< mha_real_t > () const | |
void | operator= (const mha_real_t &v) |
mha_real_t & | operator[] (unsigned int k) |
const mha_real_t & | operator[] (unsigned int k) const |
mha_real_t & | value (unsigned int t, unsigned int ch) |
Element accessor. More... | |
mha_real_t & | operator() (unsigned int t, unsigned int ch) |
Element accessor. More... | |
const mha_real_t & | value (unsigned int t, unsigned int ch) const |
Constant element accessor. More... | |
const mha_real_t & | operator() (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 inherited from mha_wave_t | |
mha_real_t * | buf |
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_t * | channel_info |
detailed channel description More... | |
Reads sound from file and resamples it if necessary and wanted.
Sound data can then be used by addsndfile.
addsndfile::resampled_soundfile_t::resampled_soundfile_t | ( | const std::string & | name, |
float | mha_sampling_rate, | ||
addsndfile_resampling_mode_t | resampling_mode | ||
) |
Reads sound from file and resamples if necessary and wanted.
If the sound file does not specify a sampling rate, then the sound data is always used without resampling.
name | Sound file name |
mha_sampling_rate | The sampling rate of the MHA signal processing at the point of the addsndfile plugin |
resampling_mode | DONT_RESAMPLE_STRICT: Do not resample, just use the samples from the sound file at the current sample rate, even if the sample rate of the sound file differs. DONT_RESAMPLE_PERMISSIVE: Do not resample, if the sample rate of the MHA differs from the sample rate of the sound file, raise an error. DO_RESAMPLE: Resample. |
MHA_Error | If the sampling rate of the file does not match the sampling rate of the MHA and DONT_RESAMPLE_STRICT was requested. If resampling failed (e.g. due to non-rational quotient of MHA sampling rate and sound file sampling rate). |