1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00

[WIP] More sound architecture changes

This commit is contained in:
j1nx
2021-05-12 11:26:35 +02:00
parent f1d0de3f6c
commit c2f4db8199
4 changed files with 225 additions and 54 deletions

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
##########################################################################
# ovos-i2csound
#
@@ -15,12 +15,7 @@
# limitations under the License.
##########################################################################
set -e
exec 1>/var/log/$(basename $0).log 2>&1
# Set default configurations
OVERLAYS=/boot/overlays
OVERLAY=""
ASOUND_STATE=/var/lib/alsa/default-asound.state
PULSE_SYSTEM=/etc/pulse/pulseaudio-system.pa
PULSE_DAEMON=/etc/pulse/pulseaudio-daemon.conf
@@ -29,57 +24,59 @@ PULSE_DAEMON=/etc/pulse/pulseaudio-daemon.conf
RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
# Scanning the I2C bus for know addresses
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}') # ReSpeaker 2-mic / WM8960
if [ is_1a == "1a" ] || [ is_1a == "UU" ] ; then
0x1a="found"
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}') # ReSpeaker 2-mic / WM8960
if [ $is_1a == "1a" ] || [ $is_1a == "UU" ] ; then
RESPEAKER2=found
fi
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared
if [ is_35 == "35" ] || [ is_35 == "UU" ] ; then
0x35="found"
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared
if [ $is_35 == "35" ] || [ $is_35 == "UU" ] ; then
RESPEAKER4=found
fi
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}') # ReSpeaker 4-mic lineair / 6-mic
if [ is_3b == "3b" ] || [ is_3b == "UU" ] ; then
0x3b="found"
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}') # ReSpeaker 4-mic lineair / 6-mic
if [ $is_3b == "3b" ] || [ $is_3b == "UU" ] ; then
RESPEAKER6=found
fi
is_4b=$(i2cdetect -y -a 1 0x4b 0x4b | egrep "(4b|UU)" | awk '{print $2}') # Adafruit
if [ is_4b == "4b" ] || [ is_4b == "UU" ] ; then
0x4b="found"
is_4b=$(i2cdetect -y 1 0x4b 0x4b | egrep "(4b|UU)" | awk '{print $2}') # Adafruit
if [ $is_4b == "4b" ] || [ $is_4b == "UU" ] ; then
ADAFRUIT=found
fi
is_2c=$(i2cdetect -y 1 0x2c 0x2c | egrep "(2c|UU)" | awk '{print $2}') # XMOS XVF3510
if [ is_2c == "2c" ] || [ is_2c == "UU" ] ; then
0x2c="found"
is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5806
if [ $is_2f == "2f" ] || [ $is_2f == "UU" ] ; then
TAS5806=found
fi
is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5860
if [ is_2f == "2f" ] || [ is_2f == "UU" ] ; then
0x2f="found"
fi
is_04=$(i2cdetect -y 1 0x04 0x04 | egrep "(04|UU)" | awk '{print $2}') # SJ201 Led Ring
if [ is_04 == "04" ] || [ is_04 == "UU" ] ; then
0x04="found"
is_04=$(i2cdetect -y -a 1 0x04 0x04 | egrep "(04|UU)" | awk '{print $2}') # SJ201 Led Ring
if [ $is_04 == "04" ] || [ $is_04 == "UU" ] ; then
SJ201LED=found
fi
# Remove old configurations
rm /var/lib/alsa/asound.state
rm /etc/ovos_asound.state
rm /etc/pulse/system.pa
rm /etc/pulse/daemon.conf
if [ -f /var/lib/alsa/asound.state ] ; then
rm /var/lib/alsa/asound.state
fi
if [ -f /etc/ovos_asound.state ] ; then
rm /etc/ovos_asound.state
fi
if [ -f /etc/pulse/system.pa ] ; then
rm /etc/pulse/system.pa
fi
if [ -f /etc/pulse/daemon.conf ] ; then
rm /etc/pulse/daemon.conf
fi
if [ 0x1a == "found" ] && [ 0x35 != "found" ] ; then
if [ $RESPEAKER2 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
echo "Installing and configuring ReSpeaker 2-mic"
modprobe snd-soc-wm8960
modprobe snd-soc-wm8960
OVERLAY=seeed-2mic-voicecard
ASOUND_STATE=/etc/voicecard/wm8960_asound.state
fi
if [ 0x3b == "found" ] && [ 0x35 != "found" ] ; then
if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
echo "Installing and configuring ReSpeaker 4-mic"
modprobe snd-soc-seeed-voicecard
modprobe snd-soc-ac108
@@ -89,8 +86,8 @@ if [ 0x3b == "found" ] && [ 0x35 != "found" ] ; then
PULSE_DAEMON=/etc/pulse/seeed-voicecard-4mic-daemon.conf
fi
if [ 0x3b == "found" ] && [ 0x35 == "found" ] ; then
echo "Installing and configuring 6mic"
if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 == "found" ] ; then
echo "Installing and configuring ReSpeaker 6mic"
modprobe snd-soc-seeed-voicecard
modprobe snd-soc-ac108
OVERLAY=seeed-8mic-voicecard
@@ -99,19 +96,19 @@ if [ 0x3b == "found" ] && [ 0x35 == "found" ] ; then
PULSE_DAEMON=/etc/pulse/seeed-voicecard-8mic-daemon.conf
fi
if [ 0x4b == "found" ] ; then
if [ $ADAFRUIT == "found" ] ; then
echo "Installing and configuring Adafruit"
/usr/sbin/i2cset -y 1 0x4b 30 # Set maximum volume to 30
/usr/sbin/i2cset -y 1 0x4b 30 # Set maximum volume to 30
fi
if [ 0x2c == "found" ] && [ 0x2f == "found" ] && [ 0x04 == "found" ]; then
if [ $TAS5860 == "found" ] && [ $SJ201LED == "found" ]; then
echo "Installing and configuring SJ201"
# Initializing XMOS xvf3510
/usr/sbin/xvf3510-start
# Initializing Texas Instruments 5860 DAC
/usr/bin/tas5806-init
# Initializing and resetting LED ring
/usr/bin/sj201-reset-led
/usr/sbin/xvf3510-start
# Initializing Texas Instruments 5806 Amplifier
/usr/bin/tas5806-init
# Initializing and resetting LED ring
/usr/bin/sj201-reset-led
PULSE_SYSTEM=/etc/pulse/mycroft-sj201-default.pa
PULSE_DAEMON=/etc/pulse/mycroft-sj201-daemon.conf
fi
@@ -121,18 +118,18 @@ if [ "$OVERLAY" ]; then
echo Loading $OVERLAY ...
# Make sure the driver loads correctly
dtoverlay -d $OVERLAYS $overlay || true
dtoverlay $OVERLAY || true
fi
# Install soundstate
echo "create $overlay asound status file"
ln -s $asound_state /etc/ovos_asound.state
echo "create asound status file"
ln -s $ASOUND_STATE /etc/ovos_asound.state
# Install pulseaudio files
echo "create $overlay pulse system file"
ln -s $pulse_default /etc/pulse/system.pa
echo "create $overlay pulse daemon file"
ln -s $pulse_daemon /etc/pulse/daemon.conf
echo "create pulse system file"
ln -s $PULSE_SYSTEM /etc/pulse/system.pa
echo "create pulse daemon file"
ln -s $PULSE_DAEMON /etc/pulse/daemon.conf
# Restore sound levels
alsactl -E HOME=/run/alsa -f /etc/ovos_asound.state restore