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 } } 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/ 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 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 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