This is an enhancement fork with the explicit aim of supporting current shipping Raspbian/Ubuntu kernels without requiring downgrading. Please donate at https://hintak.github.io/ if it works for you. Use vX.Y branch for kernel version vX.Y
Find a file
Hin-Tak Leung ebcf755c1a v5.9: .digital_mute merged into .mute_stream with adjustments
Reference:

commit e2978c45e5ed3bab7f69477b882ef588185b30cc
Author: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date:   Fri Jul 17 09:21:54 2020 +0900

    ASoC: soc-dai: remove .digital_mute

    All drivers are now using .mute_stream.
    Let's remove .digital_mute.

commit 22e9b54307987787efa0ee534aa9e31982ec1161
Merge: dc9584c5a3b8 a0234d0e6014
Author: Mark Brown <broonie@kernel.org>
Date:   Fri Jul 17 14:47:04 2020 +0100

    Merge series "ASoC: merge .digital_mute() into .mute_stream()" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

    These are v4 digital_mute() patch which adjusts
    to atmel which had conflict on v3.

    v3 -> v4
            - tidyup for atmel which had conflict

$ git diff dc9584c5a3b8...a0234d0e6014

commit bdd0c277d9846977ec3f175341d4e7475ed26ef7
Merge: d235b2823698 50891431aaad
Author: Mark Brown <broonie@kernel.org>
Date:   Thu Jul 16 23:51:51 2020 +0100

    Merge series "ASoC: merge .digital_mute() into .mute_stream()" from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

    These are v3 patch-set.
    ALSA SoC has 2 mute callbacks (= .digital_mute(), .mute_stream()).
    But the difference between these 2 are very small.
            .digital_mute() is for Playback
            .mute_stream()  is for Playback/Capture

    This patch-set adds new .no_capture_mute flag and emulate
    .digital_mute() by .mute_stream().

    v2 -> v3
            - uses "xxx_mute_stream" for .mute_stream naming
              if it was better
            - removed verbose Cc email address

$ git diff d235b2823698...50891431aaad

commit 350d993510115e3d9e78f1b3359bff7b68e88418
Author: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Date:   Thu Jul 9 10:55:41 2020 +0900

    ASoC: soc-dai.c: add .no_capture_mute support
2020-11-27 00:07:47 +00:00
ac108_plugin remove debug message, increase ac108 buf size 2017-10-09 14:58:35 +08:00
pulseaudio update: more convenient way to apply udev rules 2018-10-11 17:54:51 +08:00
tools test hardware mic phase position 2018-12-25 09:36:27 +08:00
ac10x.h Add: compatible to linux-4.18 or higher 2019-03-14 03:13:25 +00:00
ac101.c Merge branch 'v5.7' into v5.8 2020-09-28 17:11:24 +01:00
ac101_regs.h Add: headset detection for 6-Mics Circular Array Kit and 4-Mics Linear Array Kit 2018-04-02 08:43:20 +00:00
ac108.c v5.9: .digital_mute merged into .mute_stream with adjustments 2020-11-27 00:07:47 +00:00
ac108.h add respeaker 4mic audio card driver 2017-09-14 08:29:26 +00:00
ac108_6mic.state Following Standard ALSA Control Names convention 2020-09-28 16:38:30 +01:00
ac108_asound.state change asound.state for 4mic array, lower down PGA to reduce static noise 2018-09-29 14:49:19 +08:00
asound_2mic.conf use card id to identify cards 2018-07-24 11:28:55 +08:00
asound_4mic.conf use card id to identify cards 2018-07-24 11:28:55 +08:00
asound_6mic.conf update 6 mic gain controls 2018-08-06 06:32:46 +00:00
builddtbo.sh Adding missing shebang 2020-09-18 01:06:57 +01:00
default.pa add pulseaudio default configuration file 2017-09-08 04:12:53 +00:00
dkms.conf Move: simple-audio-card -> seeed-voicecard, module removing & inserting again supported 2018-04-04 09:36:18 +00:00
install.sh Remove: useless dd message in get_kernel_version() 2020-09-27 18:12:57 +01:00
LICENSE Create LICENSE 2017-09-15 10:14:31 +08:00
Makefile Add: compatible to linux-4.18 or higher 2019-03-14 03:13:25 +00:00
README.md Add: document about "query sound card number" 2020-10-04 19:15:39 +01:00
seeed-2mic-voicecard-overlay.dts Fix 2mic hat install failed 2018-03-30 03:21:40 +00:00
seeed-2mic-voicecard.dtbo Fix 2mic hat install failed 2018-03-30 03:21:40 +00:00
seeed-4mic-voicecard-overlay.dts relocating fixed-clock entry, based on upstream advice 2020-09-14 14:41:47 +01:00
seeed-4mic-voicecard.dtbo rebuilt dtbo on current Raspbian 2020-09-14 14:46:10 +01:00
seeed-8mic-voicecard-overlay.dts relocating fixed-clock entry, based on upstream advice 2020-09-14 14:41:47 +01:00
seeed-8mic-voicecard.dtbo rebuilt dtbo on current Raspbian 2020-09-14 14:46:10 +01:00
seeed-voicecard comment about Raspberry Pi 4 having two HDMI ports 2020-09-10 23:21:45 +01:00
seeed-voicecard.c Merge branch 'v5.7' into v5.8 2020-09-14 14:56:27 +01:00
seeed-voicecard.service add seeed-voicecard manger service 2018-02-01 16:07:02 +08:00
sound-compatible-4.18.h compatibility - fallthrough' pseudo keyword was introduced in v5.4 2020-04-27 21:30:34 +01:00
ubuntu-prerequisite.sh adding new ubuntu-prerequisite.sh script 2020-08-23 20:37:52 +01:00
uninstall.sh stop systemd service before diabling in uninstall, taken from upstream c1c2e5ca 2020-09-28 17:02:11 +01:00
wm8960.c v5.9: .digital_mute merged into .mute_stream with adjustments 2020-11-27 00:07:47 +00:00
wm8960.h add wm8960.h header file 2017-04-27 16:52:22 +08:00
wm8960_asound.state optimize some options 2017-09-15 02:01:53 +00:00

seeed-voicecard

Join the chat at https://gitter.im/seeed-voicecard/Lobby

The drivers of ReSpeaker Mic Hat,ReSpeaker 4 Mic Array,6-Mics Circular Array Kit, and 4-Mics Linear Array Kit for Raspberry Pi.

Install seeed-voicecard

Get the seeed voice card source code. and install all linux kernel drivers

git clone https://github.com/respeaker/seeed-voicecard
cd seeed-voicecard
sudo ./install.sh
sudo reboot

It may probably happen that the driver won't compile with the latest kernel when raspbian rolls out new patches to the kernel. If so, please try sudo ./install.sh --compat-kernel which uses an older kernel but ensures that the driver can work.

ReSpeaker Mic Hat

While the upstream wm8960 codec is not currently supported by current Pi kernel builds, upstream wm8960 has some bugs, we had fixed it. we must it build manually.

Check that the sound card name matches the source code seeed-voicecard.

#for ReSpeaker 2-mic
pi@raspberrypi:~/seeed-voicecard $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: seeed2micvoicec [seeed-2mic-voicecard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
pi@raspberrypi:~/seeed-voicecard $ arecord -l
**** List of CAPTURE Hardware Devices ****
card 1: seeed2micvoicec [seeed-2mic-voicecard], device 0: bcm2835-i2s-wm8960-hifi wm8960-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
pi@raspberrypi:~/seeed-voicecard $ 

If you want to change the alsa settings, You can use sudo alsactl --file=/etc/voicecard/wm8960_asound.state store to save it.

Next step

Go to https://github.com/respeaker/mic_hat to build voice enabled projects with Google Assistant SDK or Alexa Voice Service.

ReSpeaker 4 Mic Array

The 4 Mic Array uses ac108 which includes 4 ADCs, we also write ac108 rapberry pi linux kernel driver.

Check that the sound card name matches the source code seeed-voicecard.

#for ReSpeaker 4 Mic Array
pi@raspberrypi:~ $ arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
playback
capture
dmixed
array
ac108
default:CARD=seeed4micvoicec
    seeed-4mic-voicecard, 
    Default Audio Device
sysdefault:CARD=seeed4micvoicec
    seeed-4mic-voicecard, 
    Default Audio Device
dmix:CARD=seeed4micvoicec,DEV=0
    seeed-4mic-voicecard, 
    Direct sample mixing device
dsnoop:CARD=seeed4micvoicec,DEV=0
    seeed-4mic-voicecard, 
    Direct sample snooping device
hw:CARD=seeed4micvoicec,DEV=0
    seeed-4mic-voicecard, 
    Direct hardware device without any conversions
plughw:CARD=seeed4micvoicec,DEV=0
    seeed-4mic-voicecard, 
    Hardware device with all software conversions
pi@raspberrypi:~ $ 

If you want to change the alsa settings, You can use sudo alsactl --file=/etc/voicecard/ac108_asound.state store to save it.

6-Mics Circular Array Kit

The 6 Mics Circular Array Kit uses ac108 x 2 / ac101 x 1 / micphones x 6, includes 8 ADCs and 2 DACs.

The driver is implemented with 8 input channels & 8 output channels.

The first 6 input channel are MIC recording data,
the rest 2 input channel are echo channel of playback
The first 2 output channel are playing data, the rest 6 output channel are dummy

Check that the sound card name matches the source code seeed-voicecard.

#for 6 Mic Circular Array
pi@raspberrypi:~ $ arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
playback
dmixed
ac108
multiapps
ac101
sysdefault:CARD=seeed8micvoicec
    seeed-8mic-voicecard,
    Default Audio Device
dmix:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Direct sample mixing device
dsnoop:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Direct sample snooping device
hw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Direct hardware device without any conversions
plughw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Hardware device with all software conversions
    
pi@raspberrypi:~ $ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
playback
dmixed
ac108
multiapps
ac101
sysdefault:CARD=ALSA
    bcm2835 ALSA, bcm2835 ALSA
    Default Audio Device
dmix:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample mixing device
dmix:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample mixing device
dsnoop:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct sample snooping device
dsnoop:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct sample snooping device
hw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Direct hardware device without any conversions
hw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Direct hardware device without any conversions
plughw:CARD=ALSA,DEV=0
    bcm2835 ALSA, bcm2835 ALSA
    Hardware device with all software conversions
plughw:CARD=ALSA,DEV=1
    bcm2835 ALSA, bcm2835 IEC958/HDMI
    Hardware device with all software conversions
sysdefault:CARD=seeed8micvoicec
    seeed-8mic-voicecard,
    Default Audio Device
dmix:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Direct sample mixing device
dsnoop:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Direct sample snooping device
hw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Direct hardware device without any conversions
plughw:CARD=seeed8micvoicec,DEV=0
    seeed-8mic-voicecard,
    Hardware device with all software conversions

4-Mics Linear Array Kit

In contrast to 6-Mics Circular Array Kit for Raspberry Pi, the difference is only first 4 input channels are valid capture data.

Usage:

#Query sound card number
# The sound card number used as arecord/aplay argument,
# ( like '-D hw:N' and '-D plughw:N', where N is the number )
# could be found by command:
  aplay -l
#or
  arecord -l
# Find the line in the command output which near below form:
card 1: seeed2micvoicec [seeed-2mic-voicecard], device 0: ...
# The number between first word `card` and char `:` is the Sound Card Number, here it's 1.
#for ReSpeaker 2-mic
#It will capture sound an playback on hw:1
arecord -f cd -Dhw:1 | aplay -Dhw:1
#for ReSpeaker 4-mic
#It will capture sound on AC108 and save as a.wav
arecord -Dac108 -f S32_LE -r 16000 -c 4 a.wav
#for 6-Mics Circular Array Kit and 4-Mics Linear Array Kit
#It will capture sound on AC108 and save as a.wav
arecord -Dac108 -f S32_LE -r 16000 -c 8 a.wav
#Take care of that the captured mic audio is on the first 6 channels

#It will play a mono channel sound file mono_to_play.wav
#The file to play must be mono channel or else the speaker output nothing.
aplay -D plughw:1,0 mono_to_play.wav

#Doing capture && playback the same time
arecord -D hw:1,0 -f S32_LE -r 16000 -c 8 to_be_record.wav &
#mono_to_play.wav is a mono channel wave file to play
aplay -D plughw:1,0 -r 16000 mono_to_play.wav

**Note: Limit for developer using 6-Mics Circular Array Kit(or 4-Mics Linear Array Kit) doing capture & playback the same time:

  1. capture must be start first, or else the capture channels will possibly be disorder.
  2. playback output channels must fill with 8 same channels data or 4 same stereo channels data, or else the speaker or headphone will output nothing possibly.**

Coherence

Estimate the magnitude squared coherence using Welchs method. 4-mics-linear-array-kit coherence
Note: 'CO 1-2' means the coherence between channel 1 and channel 2.

# How to get the coherence of the captured audio(a.wav for example).
sudo apt install python-numpy python-scipy python-matplotlib
python tools/coherence.py a.wav

# Requirement of the input audio file:
- format: WAV(Microsoft) signed 16-bit PCM
- channels: >=2

uninstall seeed-voicecard

If you want to upgrade the driver , you need uninstall the driver first.

pi@raspberrypi:~/seeed-voicecard $ sudo ./uninstall.sh 
...
------------------------------------------------------
Please reboot your raspberry pi to apply all settings
Thank you!
------------------------------------------------------

Enjoy !

FAQ

When you encounter any installation and use problems when you start your ReSpeaker Pi hat, please use the following image for testing. We have installed seeed-voicecard based on the latest PI image, which can be used by burning it directly on SD. If this still cannot solve your problem, you can ask in the issue. We will try our best to solve your problem.