mirror of
https://github.com/OpenVoiceOS/OpenVoiceOS
synced 2025-04-16 19:39:37 +02:00
[WIP] More work on the SJ201 support.
Output all ok now Input still a lot of static noise (trying to figure it out)
This commit is contained in:
parent
c2f4db8199
commit
f1cda8e142
@ -40,6 +40,7 @@ disable_splash=1
|
||||
|
||||
# Enable some optional hardware interfaces
|
||||
dtparam=i2c_arm=on
|
||||
dtparam=i2c_arm_baudrate=100000
|
||||
dtoverlay=i2s-mmap
|
||||
dtparam=i2s=on
|
||||
dtparam=spi=on
|
||||
|
@ -0,0 +1,36 @@
|
||||
From c9e4c64240f9eeeb9a9d0a7ad24949c7d5cc5d78 Mon Sep 17 00:00:00 2001
|
||||
From: j1nx <p.steenbergen@j1nx.nl>
|
||||
Date: Fri, 14 May 2021 16:59:26 +0200
|
||||
Subject: [PATCH 1/1] test fixed variables
|
||||
|
||||
---
|
||||
loader/src/loader.c | 13 ++-----------
|
||||
1 file changed, 2 insertions(+), 11 deletions(-)
|
||||
|
||||
diff --git a/loader/src/loader.c b/loader/src/loader.c
|
||||
index e5d9029..c26b66b 100644
|
||||
--- a/loader/src/loader.c
|
||||
+++ b/loader/src/loader.c
|
||||
@@ -21,17 +21,8 @@ N.B. playback vs capture is determined by the codec choice
|
||||
|
||||
void device_release_callback(struct device *dev) { /* do nothing */ };
|
||||
|
||||
-#ifdef RPI_4B
|
||||
- #define CARD_PLATFORM_STR "fe203000.i2s"
|
||||
-#else
|
||||
- #define CARD_PLATFORM_STR "3f203000.i2s"
|
||||
-#endif
|
||||
-
|
||||
-#ifdef I2S_MASTER
|
||||
- #define SND_SOC_DAIFMT_CBS_FLAG SND_SOC_DAIFMT_CBS_CFS
|
||||
-#else
|
||||
- #define SND_SOC_DAIFMT_CBS_FLAG SND_SOC_DAIFMT_CBM_CFM
|
||||
-#endif
|
||||
+#define CARD_PLATFORM_STR "fe203000.i2s"
|
||||
+#define SND_SOC_DAIFMT_CBS_FLAG SND_SOC_DAIFMT_CBS_CFS
|
||||
|
||||
static struct asoc_simple_card_info snd_rpi_simple_card_info = {
|
||||
.card = "snd_rpi_simple_card", // -> snd_soc_card.name
|
||||
--
|
||||
2.20.1
|
||||
|
@ -17,4 +17,3 @@ gpio -g write $XMOS_RESET 1
|
||||
sleep 1
|
||||
xvf3510-flash --direct "/usr/lib/firmware/xvf3510/app_xvf3510_int_spi_boot_v4_1_0.bin"
|
||||
sleep 1
|
||||
tas5806-init
|
||||
|
@ -66,6 +66,9 @@ load-module module-position-event-sounds
|
||||
unload-module module-suspend-on-idle
|
||||
load-module module-role-ducking
|
||||
load-module module-combine-sink sink_name=OpenVoiceOS
|
||||
load-module module-remap-source source_name=VF_ASR_L source_properties="device.description='VocalFusion ASR recording'" master=alsa_input.platform-asoc-simple-card.0.stereo-fallback remix=no master_channel_map=front-left channel_map=mono
|
||||
load-module module-remap-source source_name=VF_Comms_R source_properties="device.description='VocalFusion Comms recording'" master=alsa_input.platform-asoc-simple-card.0.stereo-fallback remix=no master_channel_map=front-right channel_map=mono
|
||||
set-default-source VF_ASR_L
|
||||
set-default-sink OpenVoiceOS
|
||||
|
||||
### Enable Echo/Noise-Cancellation
|
||||
|
@ -27,6 +27,9 @@ from smbus2 import SMBus
|
||||
import os
|
||||
import time
|
||||
import subprocess
|
||||
from math import log, exp
|
||||
|
||||
MAX_VOL = 84
|
||||
|
||||
class tasTest:
|
||||
devAddr = 0x2f
|
||||
@ -135,12 +138,59 @@ class tasTest:
|
||||
self.writeData(0x03,0x03 , "Play") #Play
|
||||
self.dumpData()
|
||||
|
||||
def setVolume(self, vol):
|
||||
setVolStr = "Set Volume %s" %( str (vol) )
|
||||
self.writeData(0x4c,vol ,setVolStr) #Set volume
|
||||
def calc_log_y(self, x):
|
||||
""" given x produce y. takes in an int
|
||||
0-100 returns a log oriented hardware
|
||||
value with larger steps for low volumes
|
||||
and smaller steps for loud volumes """
|
||||
if x < 0:
|
||||
x = 0
|
||||
|
||||
if x > 100:
|
||||
x = 100
|
||||
|
||||
x0 = 0 # input range low
|
||||
x1 = 100 # input range hi
|
||||
|
||||
y0 = MAX_VOL # max hw vol
|
||||
y1 = 210 # min hw val
|
||||
|
||||
p1 = (x - x0) / (x1 - x0)
|
||||
p2 = log(y0) - log(y1)
|
||||
pval = p1 * p2 + log(y1)
|
||||
|
||||
return round(exp(pval))
|
||||
|
||||
def calc_log_x(self, y):
|
||||
""" given y produce x. takes in an int
|
||||
30-210 returns a value from 0-100 """
|
||||
if y < 0:
|
||||
y = MAX_VOL
|
||||
|
||||
if y > 210:
|
||||
y = 210
|
||||
|
||||
x0 = 0 # input range low
|
||||
x1 = 100 # input range hi
|
||||
|
||||
y0 = MAX_VOL # max hw vol
|
||||
y1 = 210 # min hw val
|
||||
|
||||
x = x1 - x0
|
||||
p1 = (log(y) - log(y0)) / (log(y1) - log(y0))
|
||||
|
||||
return x * p1 + x0
|
||||
|
||||
def setVolume(self, vol=1.0):
|
||||
# vol takes a float from 0.0 - 1.0
|
||||
# default vol 0.5 = 50%
|
||||
hw_vol = self.calc_log_y(vol * 100.0)
|
||||
setVolStr = "Set Volume %s" %( str (hw_vol) )
|
||||
self.writeData(0x4c, hw_vol, setVolStr) #Set volume
|
||||
|
||||
if __name__ == '__main__':
|
||||
tt = tasTest()
|
||||
tt.startSequence()
|
||||
tt.setVolume(50)
|
||||
tt.setVolume()
|
||||
tt.close()
|
||||
|
||||
|
28
buildroot-external/rootfs-overlay/usr/libexec/ovos-i2csound
Normal file → Executable file
28
buildroot-external/rootfs-overlay/usr/libexec/ovos-i2csound
Normal file → Executable file
@ -25,33 +25,39 @@ 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
|
||||
if [ "${is_1a}" == "1a" ] || [ "${is_1a}" == "UU" ] ; then
|
||||
RESPEAKER2=found
|
||||
echo "ReSpeaker 2-mic $RESPEAKER2"
|
||||
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
|
||||
if [ "${is_35}" == "35" ] || [ "${is_35}" == "UU" ] ; then
|
||||
RESPEAKER4=found
|
||||
echo "ReSpeaker 4-mic $RESPEAKER4"
|
||||
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
|
||||
if [ "${is_3b}" == "3b" ] || [ "${is_3b}" == "UU" ] ; then
|
||||
RESPEAKER6=found
|
||||
echo "ReSpeaker 6-mic $RESPEAKER6"
|
||||
fi
|
||||
|
||||
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
|
||||
ADAFRUIT=found
|
||||
echo "Adafruit $ADAFRUIT"
|
||||
fi
|
||||
|
||||
is_2f=$(i2cdetect -y 1 0x2f 0x2f | egrep "(2f|UU)" | awk '{print $2}') # TAS5806
|
||||
if [ $is_2f == "2f" ] || [ $is_2f == "UU" ] ; then
|
||||
if [ "${is_2f}" == "2f" ] || [ "${is_2f}" == "UU" ] ; then
|
||||
TAS5806=found
|
||||
echo "Texas Instruments 5806 $TAS5806"
|
||||
fi
|
||||
|
||||
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
|
||||
if [ "${is_04}" == "04" ] || [ "${is_04}" == "UU" ] ; then
|
||||
SJ201LED=found
|
||||
echo "Mark2 SJ201 Leds $SJ201LED"
|
||||
fi
|
||||
|
||||
|
||||
@ -69,14 +75,14 @@ if [ -f /etc/pulse/daemon.conf ] ; then
|
||||
rm /etc/pulse/daemon.conf
|
||||
fi
|
||||
|
||||
if [ $RESPEAKER2 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
|
||||
if [ "$RESPEAKER2" == "found" ] && [ "$RESPEAKER4" != "found" ] ; then
|
||||
echo "Installing and configuring ReSpeaker 2-mic"
|
||||
modprobe snd-soc-wm8960
|
||||
OVERLAY=seeed-2mic-voicecard
|
||||
ASOUND_STATE=/etc/voicecard/wm8960_asound.state
|
||||
fi
|
||||
|
||||
if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
|
||||
if [ "${RESPEAKER6}" == "found" ] && [ "${RESPEAKER4}" != "found" ] ; then
|
||||
echo "Installing and configuring ReSpeaker 4-mic"
|
||||
modprobe snd-soc-seeed-voicecard
|
||||
modprobe snd-soc-ac108
|
||||
@ -86,7 +92,7 @@ if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 != "found" ] ; then
|
||||
PULSE_DAEMON=/etc/pulse/seeed-voicecard-4mic-daemon.conf
|
||||
fi
|
||||
|
||||
if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 == "found" ] ; then
|
||||
if [ "{$RESPEAKER6}" == "found" ] && [ "${RESPEAKER4}" == "found" ] ; then
|
||||
echo "Installing and configuring ReSpeaker 6mic"
|
||||
modprobe snd-soc-seeed-voicecard
|
||||
modprobe snd-soc-ac108
|
||||
@ -96,12 +102,12 @@ if [ $RESPEAKER6 == "found" ] && [ $RESPEAKER4 == "found" ] ; then
|
||||
PULSE_DAEMON=/etc/pulse/seeed-voicecard-8mic-daemon.conf
|
||||
fi
|
||||
|
||||
if [ $ADAFRUIT == "found" ] ; then
|
||||
if [ "$ADAFRUIT" ] ; then
|
||||
echo "Installing and configuring Adafruit"
|
||||
/usr/sbin/i2cset -y 1 0x4b 30 # Set maximum volume to 30
|
||||
fi
|
||||
|
||||
if [ $TAS5860 == "found" ] && [ $SJ201LED == "found" ]; then
|
||||
if [ "$TAS5806" ] && [ "$SJ201LED" ]; then
|
||||
echo "Installing and configuring SJ201"
|
||||
# Initializing XMOS xvf3510
|
||||
/usr/sbin/xvf3510-start
|
||||
|
Loading…
x
Reference in New Issue
Block a user