The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
Our representation of one alsa device. More...
Public Member Functions | |
alsa_t (const alsa_dev_par_parser_t &par, unsigned int rate, unsigned int fragsize, unsigned int channels) | |
Constructor receives the parameters for this device. More... | |
~alsa_t () | |
Destructor closes the sound device. More... | |
void | start () override |
start puts alsa device in usable state More... | |
void | stop () override |
stop informs alsa device that we do not need any more samples / will not provide any more samples More... | |
bool | read (mha_wave_t **) override |
read audio samples from the device into an internal mha_wave_t buffer, then update the pointer given as parameter to point to the internal structure. More... | |
bool | write (mha_wave_t *) override |
write audio samples from the given waveform buffer to the sound device. More... | |
Public Member Functions inherited from alsa_base_t | |
alsa_base_t () | |
virtual | ~alsa_base_t ()=default |
Private Attributes | |
unsigned int | channels |
unsigned int | fragsize |
T * | buffer |
std::vector< mha_real_t > | frame_data |
MHASignal::waveform_t | wave |
internal buffer to store sound samples coming from the sound card. More... | |
const mha_real_t | gain |
const mha_real_t | invgain |
snd_pcm_format_t | pcm_format |
Additional Inherited Members | |
Public Attributes inherited from alsa_base_t | |
snd_pcm_t * | pcm |
The underlying alsa handle to this sound card. More... | |
Our representation of one alsa device.
We can start and stop the device, and depending on the direction, read or write samples.
alsa_t< T >::alsa_t | ( | const alsa_dev_par_parser_t & | par, |
unsigned int | rate, | ||
unsigned int | fragsize, | ||
unsigned int | channels | ||
) |
Constructor receives the parameters for this device.
It opens the sound device using the alsa library and selects the given parameters, but does not yet start the sound device to perform real I/O.
par | our parser variable aggregator (containing direction, device name, and number of periods to place in alsa buffer) |
rate | sampling rate in Hz |
fragsize | samples per block per channel |
channels | number of audio channels to open |
|
overridevirtual |
start puts alsa device in usable state
Implements alsa_base_t.
|
overridevirtual |
stop informs alsa device that we do not need any more samples / will not provide any more samples
Implements alsa_base_t.
|
overridevirtual |
read audio samples from the device into an internal mha_wave_t buffer, then update the pointer given as parameter to point to the internal structure.
Converts sound samples from the integer data type provided by the sound card to floating-point values needed by the MHA in the range [-1.0,1.0]
Implements alsa_base_t.
|
overridevirtual |
write audio samples from the given waveform buffer to the sound device.
converts the floating point values coming from the MHA to the integer samples required by the sound card.
Implements alsa_base_t.
|
private |
|
private |
|
private |
|
private |
|
private |
internal buffer to store sound samples coming from the sound card.
|
private |
|
private |
|
private |