From 9a9f4368b43bbd6b7d117947fc9671f87b97425e Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Tue, 24 Jul 2018 11:28:55 +0800 Subject: [PATCH 1/5] use card id to identify cards --- asound_2mic.conf | 8 ++++-- asound_4mic.conf | 27 +++++++++++--------- asound_6mic.conf | 66 ++++++++++++++++++++---------------------------- 3 files changed, 48 insertions(+), 53 deletions(-) diff --git a/asound_2mic.conf b/asound_2mic.conf index 4b13cb1..2e26f0d 100644 --- a/asound_2mic.conf +++ b/asound_2mic.conf @@ -1,6 +1,10 @@ # The IPC key of dmix or dsnoop plugin must be unique # If 555555 or 666666 is used by other processes, use another one + +# use samplerate to resample as speexdsp resample is bad +defaults.pcm.rate_converter "samplerate" + pcm.!default { type asym playback.pcm "playback" @@ -19,14 +23,14 @@ pcm.capture { pcm.dmixed { type dmix - slave.pcm "hw:0,0" + slave.pcm "hw:seeed2micvoicec" ipc_key 555555 } pcm.array { type dsnoop slave { - pcm "hw:0,0" + pcm "hw:seeed2micvoicec" channels 2 } ipc_key 666666 diff --git a/asound_4mic.conf b/asound_4mic.conf index d3cb82c..12d2ab8 100644 --- a/asound_4mic.conf +++ b/asound_4mic.conf @@ -1,6 +1,9 @@ # The IPC key of dmix or dsnoop plugin must be unique # If 555555 or 666666 is used by other processes, use another one +# use samplerate to resample as speexdsp resample is bad +defaults.pcm.rate_converter "samplerate" + pcm.!default { type asym playback.pcm "playback" @@ -9,22 +12,22 @@ pcm.!default { pcm.playback { type plug - slave.pcm "hw:0,0" + slave.pcm "hw:ALSA" } -pcm.dmixed { - type dmix - slave.pcm "hw:0,0" - ipc_key 555555 -} +# pcm.dmixed { +# type dmix +# slave.pcm "hw:0,0" +# ipc_key 555555 +# } pcm.ac108 { type plug - slave.pcm "multiapps" + slave.pcm "hw:seeed4micvoicec" } -pcm.multiapps { - type dsnoop - ac108-slavepcm "hw:1,0" - ipc_key 666666 -} +# pcm.multiapps { +# type dsnoop +# ac108-slavepcm "hw:1,0" +# ipc_key 666666 +# } diff --git a/asound_6mic.conf b/asound_6mic.conf index 180aac0..9d2a19a 100644 --- a/asound_6mic.conf +++ b/asound_6mic.conf @@ -1,68 +1,56 @@ # The IPC key of dmix or dsnoop plugin must be unique # If 555555 or 666666 is used by other processes, use another one +# use samplerate to resample as speexdsp resample is bad +defaults.pcm.rate_converter "samplerate" + pcm.!default { type asym - playback.pcm "playback" + playback.pcm "ac101" capture.pcm "ac108" } -pcm.playback { - type plug - slave { - rate 48000 - format S32_LE - pcm "hw:1,0" - } -} - -pcm.dmixed { - type dmix - slave.pcm "hw:0,0" - ipc_key 555555 -} pcm.ac108 { type plug - slave.pcm "multiapps" -} - -pcm.multiapps { - type dsnoop slave { rate 48000 format S32_LE - pcm "hw:1,0" + pcm "hw:seeed8micvoicec" } - ipc_key 666666 } +# pcm.multiapps { +# type dsnoop +# slave { +# rate 48000 +# format S32_LE +# pcm "hw:seeed8micvoicec" +# } +# ipc_key 666666 +# } + pcm.ac101 { type plug slave { pcm { - type dmix - ipc_key 1048576 - slave { - pcm "hw:1,0" + type route + slave { + pcm "hw:seeed8micvoicec" format S32_LE - # rate 16000 channels 8 } - bindings { - # map 2 channels input to - # first 2 channels of 8 output - 0 0 - 1 1 - 0 2 - 1 3 - 0 4 - 1 5 - 0 6 - 1 7 - } + ttable.0.0 1 + ttable.1.1 1 + ttable.0.2 1 + ttable.1.3 1 + ttable.0.4 1 + ttable.1.5 1 + ttable.0.6 1 + ttable.1.7 1 } channels 2 + rate 48000 } } From 8c499c226894801fd20d2b714b3a29ff8555d5e5 Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Tue, 24 Jul 2018 11:30:22 +0800 Subject: [PATCH 2/5] create git repo to manage voicecard configs --- install.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e41610b..9b23560 100755 --- a/install.sh +++ b/install.sh @@ -20,7 +20,7 @@ marker="0.0.0" apt update apt-get -y install raspberrypi-kernel-headers raspberrypi-kernel -apt-get -y install dkms git i2c-tools +apt-get -y install dkms git i2c-tools libasound2-plugins # locate currently installed kernels (may be different to running kernel if # it's just been updated) @@ -82,6 +82,20 @@ mkdir /etc/voicecard || true cp *.conf /etc/voicecard cp *.state /etc/voicecard +#create git repo +git_email=$(git config --global --get user.email) +git_name=$(git config --global --get user.name) +if [ "x${git_email}" == "x" ] || [ "x${git_name}" == "x" ] ; then + echo "setup git config" + git config --global user.email "respeaker@seeed.cc" + git config --global user.name "respeaker" +fi +echo "git init" +git --git-dir=/etc/voicecard/.git init +echo "git add --all" +git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ add --all +echo "git commit -m \"origin configures\"" +git --git-dir=/etc/voicecard/.git --work-tree=/etc/voicecard/ commit -m "origin configures" cp seeed-voicecard /usr/bin/ cp seeed-voicecard.service /lib/systemd/system/ From 7009515ec9c6f83041138a85a42e0477db4c2a5e Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Tue, 24 Jul 2018 11:31:21 +0800 Subject: [PATCH 3/5] use link to replase copy operation --- seeed-voicecard | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/seeed-voicecard b/seeed-voicecard index 38bd5df..26648fa 100755 --- a/seeed-voicecard +++ b/seeed-voicecard @@ -36,56 +36,43 @@ is_1a=$(i2cdetect -y 1 0x1a 0x1a | grep 1a | awk '{print $2}') is_35=$(i2cdetect -y 1 0x35 0x35 | grep 35 | awk '{print $2}') is_3b=$(i2cdetect -y 1 0x3b 0x3b | grep 3b | awk '{print $2}') +rm /etc/asound.conf +rm /var/lib/alsa/asound.state + if [ "x${is_1a}" == "x1a" ] && [ "x${is_35}" == "x" ] ; then echo "install 2mic" dtoverlay seeed-2mic-voicecard sleep 1 - hw=$(aplay -l | grep seeed2micvoicec | awk '{print $2}' | sed 's/://') - cp /etc/voicecard/asound_2mic.conf /etc/asound.conf + echo "create 2mic asound configure file" + ln -s /etc/voicecard/asound_2mic.conf /etc/asound.conf - echo "get old hw number" - old=$(cat /etc/asound.conf | grep hw: | awk 'NR==1 {print $2}' | sed 's/\"//g') - - echo "replace new hw:${hw},0" - sed -i -e "s/${old}/hw:${hw},0/g" /etc/asound.conf - - cp /etc/voicecard/wm8960_asound.state /var/lib/alsa/asound.state + echo "create 2mic asound status file" + ln -s /etc/voicecard/wm8960_asound.state /var/lib/alsa/asound.state fi if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x" ] ; then echo "install 4mic" dtoverlay seeed-4mic-voicecard sleep 1 - hw=$(arecord -l | grep seeed4micvoicec | awk '{print $2}' | sed 's/://') - cp /etc/voicecard/asound_4mic.conf /etc/asound.conf + echo "create 4mic asound configure file" + ln -s /etc/voicecard/asound_4mic.conf /etc/asound.conf - echo "get slavepcm line number" - line=$(grep -n ac108-slavepcm /etc/asound.conf | awk '{print $1}' | sed 's/://') - - echo "delete ${line} slavepcm hw number" - sed -i -e "${line}d" /etc/asound.conf - - echo "insert slavepcm hw:${hw},0" - sed -i "${line}i slave.pcm \"hw:${hw},0\"" /etc/asound.conf - - cp /etc/voicecard/ac108_asound.state /var/lib/alsa/asound.state + echo "create 4mic asound status file" + ln -s /etc/voicecard/ac108_asound.state /var/lib/alsa/asound.state fi if [ "x${is_3b}" == "x3b" ] && [ "x${is_35}" == "x35" ] ; then echo "install 6mic" dtoverlay seeed-8mic-voicecard sleep 1 - hw=$(aplay -l | grep seeed8micvoicec | awk '{print $2}' | sed 's/://') - cp /etc/voicecard/asound_6mic.conf /etc/asound.conf + echo "create 6mic asound configure file" + ln -s /etc/voicecard/asound_6mic.conf /etc/asound.conf - old=$(cat /etc/asound.conf | grep hw: | awk 'NR==1 {print $2}' | sed 's/\"//g') - - sed -i -e "s/${old}/hw:${hw},0/g" /etc/asound.conf - - cp /etc/voicecard/ac108_6mic.state /var/lib/alsa/asound.state + echo "create 6mic asound status file" + ln -s /etc/voicecard/ac108_6mic.state /var/lib/alsa/asound.state fi alsactl restore From f85c98c4e03d224c579a521b95b8c7360ceb1308 Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Tue, 24 Jul 2018 11:38:38 +0800 Subject: [PATCH 4/5] 4mic doesnt have output interface, delete it --- .../pulse_config_4mic/seeed-voicecard.conf | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/pulseaudio/pulse_config_4mic/seeed-voicecard.conf b/pulseaudio/pulse_config_4mic/seeed-voicecard.conf index 61b7ff0..1c35e17 100644 --- a/pulseaudio/pulse_config_4mic/seeed-voicecard.conf +++ b/pulseaudio/pulse_config_4mic/seeed-voicecard.conf @@ -3,30 +3,14 @@ [General] auto-profiles = no [Mapping seeed-source] -device-strings = ac108 +device-strings = hw:%f channel-map = front-left,front-right,rear-left,rear-right exact-channels = false fallback = yes paths-input = seeed-source priority = 3 direction = input -[Mapping seeed-sink] -device-strings = playback -channel-map = front-left,front-right -exact-channels = false -fallback = yes -paths-output = seeed-sink -direction = output -priority = 2 -[Profile output:seeed-sink+input:seeed-source] -output-mappings = seeed-sink -input-mappings = seeed-source -priority = 100 -skip-probe = yes -[Profile output:seeed-sink] -output-mappings = seeed-sink -priority = 4 -skip-probe = yes + [Profile input:seeed-source] input-mappings = seeed-source priority = 5 From 58c6233325e685a647056c14d6b11acb07d91a7f Mon Sep 17 00:00:00 2001 From: Baozhu Zuo Date: Tue, 24 Jul 2018 11:39:01 +0800 Subject: [PATCH 5/5] use sound card id --- pulseaudio/pulse_config_6mic/seeed-voicecard.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulseaudio/pulse_config_6mic/seeed-voicecard.conf b/pulseaudio/pulse_config_6mic/seeed-voicecard.conf index 5712a67..282a646 100644 --- a/pulseaudio/pulse_config_6mic/seeed-voicecard.conf +++ b/pulseaudio/pulse_config_6mic/seeed-voicecard.conf @@ -3,7 +3,7 @@ [General] auto-profiles = no [Mapping seeed-8ch] -device-strings = hw:1,0 +device-strings = hw:%f channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right exact-channels = false fallback = yes @@ -11,7 +11,7 @@ paths-input = seeed-8ch priority = 3 direction = input [Mapping seeed-2ch] -device-strings = hw:1,0 +device-strings = hw:%f channel-map = front-left,front-right,rear-left,rear-right,front-center,lfe,side-left,side-right exact-channels = false exact-channels = false