ODAS and Matrix record mics does not work together

I’m trying to combine the capabilities of ODAS and microphone array libraries from matrix-hal to detect a sound and record it together with its energy and position. However, in a first test something went wrong, when I run the code to record audios https://matrix-io.github.io/matrix-documentation/matrix-hal/examples/microphone/ it works very well, however if next to this I try to run the example of arrival direction using ODAS https://www.hackster.io/matrix-labs/direction-of-arrival-for-matrix-voice-creator-using-odas-b7a15b it does not work because the device is busy. The same error appeared if I try to record a sound using arecord.

An this moment, the only way to fix this error that I found is to shutdown and power on the Pi. Someone know what it happens? Why if I run the audio record demo, it blocks the device? How to free the device?

Thanks for your help.


Check this, it might help



You could also try integrating the mic recording code from HAL into the MATRIX ODAS example.

You would have to edit the file matrix-odas.cpp and incorporate the mic recording to file code from here into it so that the MATRIX ODAS program itself is also recording.

I haven’t tried this myself but technically it should work since the MATRIX ODAS example uses MATRIX HAL. The only thing is that the recording and DoA using ODAS won’t be happening at exactly the same time since C++ executes line by line.

To run them simultaneously, something along the lines of @Romkabouter’s suggestion would be better.

At this time, I’m testing to find options to synchronize the detection of the sound and record it, thus I’m not running the matrix-odas.cpp and the mic recording at the same time. However something went wrong because if I first run the mic-recording sample, the device is blocked, because although the mic-recording is finished, The matrix-odas example does not run because the device hw:2,0 is busy. But if I run the mic-recording again, it run without problem.

I think that there is a bug in the code mic-recording which block the device but I don’t kow how to fix it.

Below you will find a sequence of this:

Thank you for your help


Hi @dagocs,

In order to have more than one application use the mics at the same time, you will have to modify the asound.conf file as mentioned in the thread Rom had posted earlier:

Check out the thread and see if it helps.

Though, I do see that it says the device is busy after the recording is finished. I will test this and let you know.

Many thanks for your response

I’ll to check the thread,

I look forward for your response


Hi @Samreen

I modified the asound.conf as below:

But it does not work and it appears the same errors as the last post.

I look forward some help…


Quick question. Did the ODAS example run properly by itself before you tried to record using the mics?

Yes, it worked properly before to run mic-recording example…

Hi @dagocs,

We tested ODAS with MATRIX HAL, and were able to replicate your issue. The main thing is that using MATRIX kernel modules (required for audio from ALSA to ODAS) and MATRIX HAL together can cause complications.

Likely explanation below:

ODAS uses ALSA to get sound. The MATRIX kernel modules use ALSA as a way to expose audio to applications, this audio is coming from the MATRIX Creator board via SPI.

MATRIX HAL directly communicates with the MATRIX Creator board to obtain audio via SPI. Therefore, when you run MATRIX HAL code, it somehow blocks the SPI bus, and blocks audio data from passing through ALSA to ODAS.

Potential solutions:

  • You could use a simple C/C++ library that records from ALSA. I found one here. Scroll down to Listing 4 to see how it works.

    For this solution, you will need to edit the asound.conf file to split the mic output into 2 channels, similar to what you had done before, since ALSA currently only allows one program to use the mics at a time.

  • ODAS uses ALSA to get sound so you may be able to record the sound ODAS captures internally. For that, you will have to look into the ODAS code and see if they provide any simple API or way of doing so. This file may be a good starting point for that.

Hope this helps.


Hello Samrine , I’ve tried this one also added system(“arecord…”) ti matrix-odas.cpp , make ; ad run it but did not work cause the odas-live code is already using the mic. thank you


Did one of you succeed with this task? I don’t event have to have a recording, I just need the volume level during direction detection.

Would be very nice if you could give me a hint how to achieve with that.

Best wishes

Hello @27leaves,

Welcome to our community!

Currently, it is not possible for our microphones to be used by more than one application using our kernel modules.

Can you expand on what you need with the volume level? We may be able to help there!


Hi @Samreen :slight_smile: Thank you!

Sorry for replying so late. As I just needed an approximated value, I ended up just using the energy level (E) and this worked pretty well.

Best wishes