Python access to the 8 microphones?

I just got my first Matrix Creator kit. My main interest is in performing signal processing on the 8 microphones. To start, I want to record from the 8 microphones and send this info to my laptop through an internet cable.

Second, I want to understand how to interface with the microphones from python and how to program the DSP processors on the kit.

Any pointers would be appreciated.

Yoav Freund
UCSD

Hi @yoavfreund,

That should be doable!

The DSP of the mics resides on our FPGA, you can check out the MATRIX Creator FPGA code here. The FIR filter coefficients can be edited for the kernel modules using the instructions here. You would likely use the kernel modules for the microphone recordings. This gives you access to audio through ALSA which has a python wrapper called pyaudio.

Install the kernel modules using the steps provided here.

Then, set up pyaudio following the steps below.

Install the pip3 package manager.

sudo apt install python3-pip

Upgrade PIP3.

python3 -m pip install --upgrade pip

Install portaudio

sudo apt install portaudio19-dev

Install pyaudio using pip

sudo python3 -m pip install pyaudio

Then, you need to implement a little workaround as portaudio is having some issues with the latest Raspbian, since pyaudio relies on that.

On your RPi, in the /etc/asound.conf file, add the following line in the pcm.speaker section

rate 16000

image

Then, you can try out this example program here. You can edit th sampling rate, channels, and other mic characteristics in the file. You can access other MATRIX Creator sensor functionality through python with MATRIX Lite.

If the recording volume is too low for your liking, you can play with the mic gain by adding and editing the following line in /etc/asound.conf once you have the MATRIX kernel modules: max_dB.

pcm.mic {
   type softvol
   slave {
     pcm "array"
   }
   control {
     name "MicArray Master"
        card "MATRIXIOSOUND"
   }
   max_dB 15.0
}

You can also access audio through MATRIX HAL which doesn’t go through ALSA. Setup here & examples found here. You can edit the FIR coefficients for HAL by editing this file and compiling from source.

You should be able to use any of these methods, and use sockets to create streaming web servers to send the files/data buffers over WiFi/ethernet to a program on your laptop!

Hope this helps!

Best,
Samreen

1 Like

Thank you very much!! I’ll try it tomorrow.

Yoav