HoerTech-gGmbH / openMHA

The open Master Hearing Aid (openMHA)
http://www.openmha.org
GNU Affero General Public License v3.0
252 stars 74 forks source link

MHAIOalsa Read Failed error while connected to MATLAB #29

Closed JEEaton001 closed 5 years ago

JEEaton001 commented 5 years ago

I have openMHA installed and running, and I have been able to get a live passthrough working with the iolib: MHAIOalsa. Though once I connect openMHA to MATLAB over Ethernet it will start displaying read and write errors when I try to change parameters in the filter menu. Is there a way around this error? Also is the fitting dialog not supposed to make live changes to openMHA?

alsaReadError

tobiasherzke commented 5 years ago

Which sound card are you using and how is it configured?

JEEaton001 commented 5 years ago

It is a custom sound card using the audio codek. sampling rate of 48000Hz, format is S32_LE, 2 channels. That fallows the Linux simple sound card design. I can pass-through, play, and record sound using arecord and aplay, and have not had an issue with missing frames before.

tobiasherzke commented 5 years ago

It is exciting that you want to use your own custom sound card with openMHA. Please keep us informed about your progress.

As you can see in the source code https://github.com/HoerTech-gGmbH/openMHA/blob/master/mha/plugins/io/src/MHAIOalsa.cpp#L148, we are using blocking alsa I/O. The alsa library documentation states at https://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#ga4c2c7bd26cf221268d59dc3bbeb9c048 for the snd_pcm_readi function:

If the blocking behaviour was selected and it is running, then routine waits until all requested frames are filled. The returned number of frames can be less only if a signal or underrun occurred.

So it seems you have xruns when network traffic occurs. If I remember correctly we do not do XRun recovery in the MHAIOalsa alsa I/O library. Your options:

Also is the fitting dialog not supposed to make live changes to openMHA?

Yes, you can make live changes in a running openMHA. Of course, your system needs to be able to handle signal processing and network communication simultaneously, otherwise xruns may occur.