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:
@@ -0,0 +1 @@
|
|||||||
|
i2c-dev
|
@@ -0,0 +1,99 @@
|
|||||||
|
# This file is part of PulseAudio.
|
||||||
|
#
|
||||||
|
# PulseAudio is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# PulseAudio is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
## Configuration file for the PulseAudio daemon. See pulse-daemon.conf(5) for
|
||||||
|
## more information. Default values are commented out. Use either ; or # for
|
||||||
|
## commenting.
|
||||||
|
|
||||||
|
; daemonize = no
|
||||||
|
; fail = yes
|
||||||
|
; allow-module-loading = yes
|
||||||
|
; allow-exit = yes
|
||||||
|
; use-pid-file = yes
|
||||||
|
; system-instance = no
|
||||||
|
; local-server-type = user
|
||||||
|
; enable-shm = yes
|
||||||
|
; enable-memfd = yes
|
||||||
|
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
|
||||||
|
; lock-memory = no
|
||||||
|
; cpu-limit = no
|
||||||
|
|
||||||
|
; high-priority = yes
|
||||||
|
; nice-level = -11
|
||||||
|
|
||||||
|
; realtime-scheduling = yes
|
||||||
|
; realtime-priority = 5
|
||||||
|
|
||||||
|
; exit-idle-time = 20
|
||||||
|
; scache-idle-time = 20
|
||||||
|
|
||||||
|
; dl-search-path = (depends on architecture)
|
||||||
|
|
||||||
|
; load-default-script-file = yes
|
||||||
|
; default-script-file = /etc/pulse/default.pa
|
||||||
|
|
||||||
|
; log-target = auto
|
||||||
|
; log-level = notice
|
||||||
|
; log-meta = no
|
||||||
|
; log-time = no
|
||||||
|
; log-backtrace = 0
|
||||||
|
|
||||||
|
; resample-method = speex-float-1
|
||||||
|
; avoid-resampling = false
|
||||||
|
; enable-remixing = yes
|
||||||
|
; remixing-use-all-sink-channels = yes
|
||||||
|
; enable-lfe-remixing = no
|
||||||
|
; lfe-crossover-freq = 0
|
||||||
|
|
||||||
|
; flat-volumes = yes
|
||||||
|
|
||||||
|
; rlimit-fsize = -1
|
||||||
|
; rlimit-data = -1
|
||||||
|
; rlimit-stack = -1
|
||||||
|
; rlimit-core = -1
|
||||||
|
; rlimit-as = -1
|
||||||
|
; rlimit-rss = -1
|
||||||
|
; rlimit-nproc = -1
|
||||||
|
; rlimit-nofile = 256
|
||||||
|
; rlimit-memlock = -1
|
||||||
|
; rlimit-locks = -1
|
||||||
|
; rlimit-sigpending = -1
|
||||||
|
; rlimit-msgqueue = -1
|
||||||
|
; rlimit-nice = 31
|
||||||
|
; rlimit-rtprio = 9
|
||||||
|
; rlimit-rttime = 200000
|
||||||
|
|
||||||
|
; default-sample-format = s16le
|
||||||
|
; default-sample-rate = 44100
|
||||||
|
; alternate-sample-rate = 48000
|
||||||
|
; default-sample-channels = 2
|
||||||
|
; default-channel-map = front-left,front-right
|
||||||
|
|
||||||
|
; default-fragments = 4
|
||||||
|
; default-fragment-size-msec = 25
|
||||||
|
|
||||||
|
; enable-deferred-volume = yes
|
||||||
|
; deferred-volume-safety-margin-usec = 8000
|
||||||
|
; deferred-volume-extra-delay-usec = 0
|
||||||
|
|
||||||
|
# OpenVoiceOS Audio Settings
|
||||||
|
resample-method = ffmpeg
|
||||||
|
default-sample-format = s32le
|
||||||
|
default-sample-rate = 48000
|
||||||
|
alternate-sample-rate = 44100
|
||||||
|
default-sample-channels = 2
|
||||||
|
default-channel-map = front-left,front-right
|
||||||
|
avoid-resampling = true
|
||||||
|
flat-volumes = no
|
@@ -0,0 +1,74 @@
|
|||||||
|
#!/usr/bin/pulseaudio -nF
|
||||||
|
#
|
||||||
|
# This file is part of PulseAudio.
|
||||||
|
#
|
||||||
|
# PulseAudio is free software; you can redistribute it and/or modify it
|
||||||
|
# under the terms of the GNU Lesser General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# PulseAudio is distributed in the hope that it will be useful, but
|
||||||
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
# General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
|
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# This startup script is used only if PulseAudio is started in system
|
||||||
|
# mode.
|
||||||
|
|
||||||
|
### Automatically restore the volume of streams and devices
|
||||||
|
load-module module-device-restore
|
||||||
|
load-module module-stream-restore
|
||||||
|
load-module module-card-restore
|
||||||
|
|
||||||
|
### Automatically load driver modules depending on the hardware available
|
||||||
|
.ifexists module-udev-detect.so
|
||||||
|
load-module module-udev-detect tsched=0
|
||||||
|
.else
|
||||||
|
### Use the static hardware detection module (for systems that lack udev/hal support)
|
||||||
|
load-module module-detect
|
||||||
|
.endif
|
||||||
|
|
||||||
|
### Load several protocols
|
||||||
|
.ifexists module-esound-protocol-unix.so
|
||||||
|
load-module module-esound-protocol-unix
|
||||||
|
.endif
|
||||||
|
load-module module-native-protocol-unix auth-anonymous=1
|
||||||
|
|
||||||
|
### Network access (may be configured with paprefs, so leave this commented
|
||||||
|
### here if you plan to use paprefs)
|
||||||
|
#load-module module-esound-protocol-tcp
|
||||||
|
load-module module-native-protocol-tcp auth-ip-acl=127.0.0.1;192.168.0.0/16;172.16.0.0/12;10.0.0.0/8 auth-anonymous=1
|
||||||
|
load-module module-zeroconf-publish
|
||||||
|
|
||||||
|
### Automatically restore the default sink/source when changed by the user
|
||||||
|
### during runtime
|
||||||
|
### NOTE: This should be loaded as early as possible so that subsequent modules
|
||||||
|
### that look up the default sink/source get the right value
|
||||||
|
load-module module-default-device-restore
|
||||||
|
|
||||||
|
### Automatically move streams to the default sink if the sink they are
|
||||||
|
### connected to dies, similar for sources
|
||||||
|
load-module module-rescue-streams
|
||||||
|
|
||||||
|
### Make sure we always have a sink around, even if it is a null sink.
|
||||||
|
load-module module-always-sink
|
||||||
|
|
||||||
|
### Automatically suspend sinks/sources that become idle for too long
|
||||||
|
load-module module-suspend-on-idle
|
||||||
|
|
||||||
|
### Enable positioned event sounds
|
||||||
|
load-module module-position-event-sounds
|
||||||
|
|
||||||
|
### OpenVoiceOS Audio Settings
|
||||||
|
unload-module module-suspend-on-idle
|
||||||
|
load-module module-role-ducking
|
||||||
|
load-module module-combine-sink sink_name=OpenVoiceOS
|
||||||
|
set-default-sink OpenVoiceOS
|
||||||
|
|
||||||
|
### Enable Echo/Noise-Cancellation
|
||||||
|
#load-module module-echo-cancel aec_method=webrtc source_name=echoCancel_source sink_name=echoCancel_sink
|
||||||
|
#set-default-source echoCancel_source
|
||||||
|
#set-default-sink echoCancel_sink
|
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# ovos-i2csound
|
# ovos-i2csound
|
||||||
#
|
#
|
||||||
@@ -15,12 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
set -e
|
|
||||||
exec 1>/var/log/$(basename $0).log 2>&1
|
|
||||||
|
|
||||||
# Set default configurations
|
# Set default configurations
|
||||||
OVERLAYS=/boot/overlays
|
|
||||||
OVERLAY=""
|
|
||||||
ASOUND_STATE=/var/lib/alsa/default-asound.state
|
ASOUND_STATE=/var/lib/alsa/default-asound.state
|
||||||
PULSE_SYSTEM=/etc/pulse/pulseaudio-system.pa
|
PULSE_SYSTEM=/etc/pulse/pulseaudio-system.pa
|
||||||
PULSE_DAEMON=/etc/pulse/pulseaudio-daemon.conf
|
PULSE_DAEMON=/etc/pulse/pulseaudio-daemon.conf
|
||||||
@@ -30,56 +25,58 @@ RPI_HATS="seeed-2mic-voicecard seeed-4mic-voicecard seeed-8mic-voicecard"
|
|||||||
|
|
||||||
# Scanning the I2C bus for know addresses
|
# Scanning the I2C bus for know addresses
|
||||||
is_1a=$(i2cdetect -y 1 0x1a 0x1a | egrep "(1a|UU)" | awk '{print $2}') # ReSpeaker 2-mic / WM8960
|
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
|
if [ $is_1a == "1a" ] || [ $is_1a == "UU" ] ; then
|
||||||
0x1a="found"
|
RESPEAKER2=found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_35=$(i2cdetect -y 1 0x35 0x35 | egrep "(35|UU)" | awk '{print $2}') # ReSpeaker 4-mic squared
|
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
|
if [ $is_35 == "35" ] || [ $is_35 == "UU" ] ; then
|
||||||
0x35="found"
|
RESPEAKER4=found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_3b=$(i2cdetect -y 1 0x3b 0x3b | egrep "(3b|UU)" | awk '{print $2}') # ReSpeaker 4-mic lineair / 6-mic
|
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
|
if [ $is_3b == "3b" ] || [ $is_3b == "UU" ] ; then
|
||||||
0x3b="found"
|
RESPEAKER6=found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_4b=$(i2cdetect -y -a 1 0x4b 0x4b | egrep "(4b|UU)" | awk '{print $2}') # Adafruit
|
is_4b=$(i2cdetect -y 1 0x4b 0x4b | egrep "(4b|UU)" | awk '{print $2}') # Adafruit
|
||||||
if [ is_4b == "4b" ] || [ is_4b == "UU" ] ; then
|
if [ $is_4b == "4b" ] || [ $is_4b == "UU" ] ; then
|
||||||
0x4b="found"
|
ADAFRUIT=found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_2c=$(i2cdetect -y 1 0x2c 0x2c | egrep "(2c|UU)" | awk '{print $2}') # XMOS XVF3510
|
is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5806
|
||||||
if [ is_2c == "2c" ] || [ is_2c == "UU" ] ; then
|
if [ $is_2f == "2f" ] || [ $is_2f == "UU" ] ; then
|
||||||
0x2c="found"
|
TAS5806=found
|
||||||
fi
|
fi
|
||||||
|
|
||||||
is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5860
|
is_04=$(i2cdetect -y -a 1 0x04 0x04 | egrep "(04|UU)" | awk '{print $2}') # SJ201 Led Ring
|
||||||
if [ is_2f == "2f" ] || [ is_2f == "UU" ] ; then
|
if [ $is_04 == "04" ] || [ $is_04 == "UU" ] ; then
|
||||||
0x2f="found"
|
SJ201LED=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"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Remove old configurations
|
# Remove old configurations
|
||||||
rm /var/lib/alsa/asound.state
|
if [ -f /var/lib/alsa/asound.state ] ; then
|
||||||
rm /etc/ovos_asound.state
|
rm /var/lib/alsa/asound.state
|
||||||
rm /etc/pulse/system.pa
|
fi
|
||||||
rm /etc/pulse/daemon.conf
|
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 [ $RESPEAKER2 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
|
||||||
if [ 0x1a == "found" ] && [ 0x35 != "found" ] ; then
|
|
||||||
echo "Installing and configuring ReSpeaker 2-mic"
|
echo "Installing and configuring ReSpeaker 2-mic"
|
||||||
modprobe snd-soc-wm8960
|
modprobe snd-soc-wm8960
|
||||||
OVERLAY=seeed-2mic-voicecard
|
OVERLAY=seeed-2mic-voicecard
|
||||||
ASOUND_STATE=/etc/voicecard/wm8960_asound.state
|
ASOUND_STATE=/etc/voicecard/wm8960_asound.state
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ 0x3b == "found" ] && [ 0x35 != "found" ] ; then
|
if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
|
||||||
echo "Installing and configuring ReSpeaker 4-mic"
|
echo "Installing and configuring ReSpeaker 4-mic"
|
||||||
modprobe snd-soc-seeed-voicecard
|
modprobe snd-soc-seeed-voicecard
|
||||||
modprobe snd-soc-ac108
|
modprobe snd-soc-ac108
|
||||||
@@ -89,8 +86,8 @@ if [ 0x3b == "found" ] && [ 0x35 != "found" ] ; then
|
|||||||
PULSE_DAEMON=/etc/pulse/seeed-voicecard-4mic-daemon.conf
|
PULSE_DAEMON=/etc/pulse/seeed-voicecard-4mic-daemon.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ 0x3b == "found" ] && [ 0x35 == "found" ] ; then
|
if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 == "found" ] ; then
|
||||||
echo "Installing and configuring 6mic"
|
echo "Installing and configuring ReSpeaker 6mic"
|
||||||
modprobe snd-soc-seeed-voicecard
|
modprobe snd-soc-seeed-voicecard
|
||||||
modprobe snd-soc-ac108
|
modprobe snd-soc-ac108
|
||||||
OVERLAY=seeed-8mic-voicecard
|
OVERLAY=seeed-8mic-voicecard
|
||||||
@@ -99,16 +96,16 @@ if [ 0x3b == "found" ] && [ 0x35 == "found" ] ; then
|
|||||||
PULSE_DAEMON=/etc/pulse/seeed-voicecard-8mic-daemon.conf
|
PULSE_DAEMON=/etc/pulse/seeed-voicecard-8mic-daemon.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ 0x4b == "found" ] ; then
|
if [ $ADAFRUIT == "found" ] ; then
|
||||||
echo "Installing and configuring Adafruit"
|
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
|
fi
|
||||||
|
|
||||||
if [ 0x2c == "found" ] && [ 0x2f == "found" ] && [ 0x04 == "found" ]; then
|
if [ $TAS5860 == "found" ] && [ $SJ201LED == "found" ]; then
|
||||||
echo "Installing and configuring SJ201"
|
echo "Installing and configuring SJ201"
|
||||||
# Initializing XMOS xvf3510
|
# Initializing XMOS xvf3510
|
||||||
/usr/sbin/xvf3510-start
|
/usr/sbin/xvf3510-start
|
||||||
# Initializing Texas Instruments 5860 DAC
|
# Initializing Texas Instruments 5806 Amplifier
|
||||||
/usr/bin/tas5806-init
|
/usr/bin/tas5806-init
|
||||||
# Initializing and resetting LED ring
|
# Initializing and resetting LED ring
|
||||||
/usr/bin/sj201-reset-led
|
/usr/bin/sj201-reset-led
|
||||||
@@ -121,18 +118,18 @@ if [ "$OVERLAY" ]; then
|
|||||||
echo Loading $OVERLAY ...
|
echo Loading $OVERLAY ...
|
||||||
|
|
||||||
# Make sure the driver loads correctly
|
# Make sure the driver loads correctly
|
||||||
dtoverlay -d $OVERLAYS $overlay || true
|
dtoverlay $OVERLAY || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install soundstate
|
# Install soundstate
|
||||||
echo "create $overlay asound status file"
|
echo "create asound status file"
|
||||||
ln -s $asound_state /etc/ovos_asound.state
|
ln -s $ASOUND_STATE /etc/ovos_asound.state
|
||||||
|
|
||||||
# Install pulseaudio files
|
# Install pulseaudio files
|
||||||
echo "create $overlay pulse system file"
|
echo "create pulse system file"
|
||||||
ln -s $pulse_default /etc/pulse/system.pa
|
ln -s $PULSE_SYSTEM /etc/pulse/system.pa
|
||||||
echo "create $overlay pulse daemon file"
|
echo "create pulse daemon file"
|
||||||
ln -s $pulse_daemon /etc/pulse/daemon.conf
|
ln -s $PULSE_DAEMON /etc/pulse/daemon.conf
|
||||||
|
|
||||||
# Restore sound levels
|
# Restore sound levels
|
||||||
alsactl -E HOME=/run/alsa -f /etc/ovos_asound.state restore
|
alsactl -E HOME=/run/alsa -f /etc/ovos_asound.state restore
|
||||||
|
Reference in New Issue
Block a user