Maker Portal

View Original

Audio Processing with The QuadMic 4-Microphone Array on the Raspberry Pi

“As an Amazon Associates Program member, clicking on links may result in Maker Portal receiving a small commission that helps support future projects.”

See this content in the original post

See this content in the original post

The QuadMic and Raspberry Pi computer are sed for the analysis, along with an audio frequency generator developed for smartphones. The Raspberry Pi 4 is used to take advantage of the faster processor (1.5GHz Quad-Core Cortex-A72 (ARM v8) 64-bit SoC - Broadcom BCM2711). The parts used specifically for the tutorial are given below with links:

The QuadMic occupies the entire Raspberry Pi header, thus, there is no room for other devices to be connected to the RPi. Additionally, it is important to state that the QuadMic must be wired to all 40 pins and aligned correctly. Misaligning the QuadMic with the RPi’s 40-pin header can result in damage of either or both the QuadMic or/and Raspberry Pi.

See this product in the original post

See this content in the original post

See this content in the original post

See this content in the original post

The QuadMic installation procedure closely follows the one outlined in the Seeed Studio documentation for the “ReSpeaker 4-Mic Array for Raspberry Pi.” And while our tutorial uses the QuadMic instead of the ReSpeaker, both use the AC108 I2S analog-to-digital converter and have nearly identical form factor. Thus, a lot of the use cases are similar, particularly in the library preparation on the Raspberry Pi. Python will exclusively used for the analysis here, whereas the Seeed Studio documentation uses some proprietary software.

First, update and upgrade any Raspberry Pi packages by typing the following into the terminal command line:

See this content in the original post

Next, the audio card emulation for the QuadMic needs to be installed by cloning into the Seeed voice card repository for the ReSpeaker:

See this content in the original post

The installation will likely 1-2 minutes on the Raspberry Pi 4 (possibly longer on previous models). If any errors arise, make sure to update and upgrade, reboot, and make sure the RPi is connected to the internet - then try again. Finally, reboot the RPi:

See this content in the original post

Before verifying the QuadMic on the RPi, we need to install the Python pyaudio libraries:

See this content in the original post

Now, the QuadMic can be verified by opening Python and using the ‘pyaudio’ package to list all available audio devices and their properties. The code below uses pyaudio to do this and tells the user whether a QuadMic is detected or not:

See this content in the original post

Assuming the Seeed voice card library was installed correctly, the above should output the following to the Python shell:

The QuadMic device finder routine above will be used to specify the index to be read by the audio streaming function in pyaudio. If the above code snippet doesn’t print out information about a device - then it is likely that one or multiple issues are a result:

  • The Raspberry Pi needs to be restarted

  • The Seeed voice card was not properly installed

  • The QuadMic is improperly wired/aligned to the Raspberry Pi

  • The QuadMic is damaged

  • The Raspberry Pi Version and/or operating system is not compatible with the Seeed voice card

Under the assumption that the QuadMic has been found by pyaudio on the Raspberry Pi, the next section will test the four microphones and introduce methods for verifying the functionality of each.


See this content in the original post

The QuadMic can be tested by taking sample measurements while tapping each microphone. This will allow the user to ensure that each microphone is correlated correctly with the respective measurement and parsing of each data vector. The code below plots all four microphone responses in real time at a sample rate of 16kHz in chunks of 4000 points. This equates to roughly 250ms recordings for all four microphones simultaneously. The code (implemented and tested in Python 3.7 on a Raspberry Pi 4) is given below:

See this content in the original post

The code above should output a visualization similar to the one given below, which registers the taps on each of the four microphones:

One thing to note in the tap test is the peaking of the microphone signal. The microphones peak at 2 raised to the 15th power, both negatively and positively. Anytime the microphone is peaking it can cause damage, and thus, it shouldn’t be done often. Therefore, the tap test should serve as a starting method of ensuring that the channels are being parsed correctly. Going forward, only acoustic inputs will be used to force the microphones into a response.

See this content in the original post

See this content in the original post

The QuadMic 4-microphone array was introduced for the Raspberry Pi as a way to record four microphones simultaneously. Using Python, the QuadMic was read and all four microphones were tested and identified. The parsing of the four microphones was done and a real-time plot showed that each microphone corresponded correctly to the hardware label for each MEMS mic. This tutorial was meant as an introduction and getting started routine for setting up and testing the QuadMic for audio processing and acoustic analysis with multiple microphones, using the Raspberry Pi. In the next tutorial in the QuadMic series, a real-world example will be explored where algorithms for determining direction of arrival (DoA) or acoustic localization will be introduced. The sample rate limitations and frequency response of the QuadMic will also be covered in the next tutorial for the QuadMic analyses on the RPi. Use of the onboard RGB LEDs will also be covered, where the direction of arrival can be approximated with one of the 12 LEDs - this is similar to an Amazon Alexa or Echo. The goal of this tutorial series is to introduce the QuadMic as a viable piece of hardware for advanced acoustic analysis on the Raspberry Pi. Examples include: acoustic source directivity, noise reduction, room acoustic characterization, and multi-microphone frequency analysis.

See this content in the original post

See More in Raspberry Pi and Acoustics:

See this content in the original post