I have no idea if .asoundrc should be applied last as Myford calls an amixer cset in /home/pi/audio_setup.sh
that script runs on login so anything you do will be overwritten.
Its not Alsa config its Mycroft config you need to set and why it exists as all you need to do is use the Alsa_utils in that script once and then run sudo alsactl store
to save the state of the settings you have just made.
But also /etc/mycroft/mycroft.conf contains devices specified by hardware index so messing with alsa is going to do nothing.
{
"play_wav_cmdline": "aplay -Dhw:0,0 %1",
"play_mp3_cmdline": "mpg123 -a hw:0,0 %1",
"enclosure": {
"platform": "picroft"
},
"tts": {
"mimic": {
"path": "/home/pi/mycroft-core/mimic/bin/mimic"
}
},
"ipc_path": "/ramdisk/mycroft/ipc/"
}
#!/bin/bash
# Use this script to execute audio setup actions
sudo amixer cset numid=3 "1" > /dev/null 2>&1
amixer set PCM 79% > /dev/null 2>&1
amixer set Master 79% > /dev/null 2>&1
I have absolutely no idea which runs first and I was only doing a simple copy and paste !default asoundrc.
Do not bother with .asoundrc and definately stay away /usr/share/alsa/alsa.conf why are you going there?
Alsa is quite simple to set the current control device you set it to “1” as in.
sudo amixer cset numid=3 "1"
To set any volume you reference the volume name and set as a % as in amixer set Master 79%
Then you run sudo alsactl store
Thats it done you just reboot to see if that state is correct as its the simplest way.
Its very similar with system services as do you start hacking the conf files of systemd or do you just systemctl enable service
?
The problem isn’t with Alsa its the Myford scripts that have been chosen as they run on logon and will change the initial conf or any saved state.
You have to use and modify /home/pi/audio_setup.sh
because it exists.
Also you have to modify /etc/mycroft/mycroft.conf
because the hardware indexs exist.
You are a relative expert about Alsa as you already know far more than you should.
pi@picroft:~ $ amixer
Simple mixer control 'Master',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined
Playback channels: Mono
Limits: Playback 0 - 65536
Mono: Playback 51774 [79%] [on]
Simple mixer control 'Capture',0
Capabilities: cvolume cswitch cswitch-joined
Capture channels: Front Left - Front Right - Rear Left - Rear Right
Limits: Capture 0 - 65536
Front Left: Capture 65536 [100%] [on]
Front Right: Capture 65536 [100%] [on]
Rear Left: Capture 65536 [100%] [on]
Rear Right: Capture 65536 [100%] [on]
amixer controls
numid=4,iface=MIXER,name='Master Playback Switch'
numid=3,iface=MIXER,name='Master Playback Volume'
numid=2,iface=MIXER,name='Capture Switch'
numid=1,iface=MIXER,name='Capture Volume'
So from that I should be able to do
sudo amixer cset numid=4 "1"
sudo amixer cset numid=2 "1"
sudo alsactl store
sudo reboot
Also turn off any you don’t want.
Its the myford scripts that run on boot on logon which happens late in boot order that will confuse and change settings.
You could create a ${HOME}/.asoundrc but likely it will not be used unless you edit the Mycroft scripts & conf.
As an example
pcm.array {
type hw
card 0
}
pcm.array_gain {
type softvol
slave {
pcm "array"
}
control {
name "Mic Gain"
count 2
card 0
}
min_dB -40.0
max_dB 10.0
resolution 80
}
pcm.cap {
type plug
slave {
pcm "array_gain"
channels 4
}
route_policy sum
}
Which will just sum that array and create a cap pcm stream.
Mycroft uses pulseaudio which is just a server daemon ontop of Alsa which has the webrtc Echo Cancellation routines and also a beamforming routine that will sum the channels and correct the latency of those channels so it should be a cleaner sum.
So leave .asoundrc as a multi channel array (no config just default) and feed into pulseaudio.
Adopt what I wrote in
PS3 Eye Best Settings - #6 by StuartIanNaylor for 2 channels
Which basically is just tacking on the end of /etc/pulse/default.pa
### Enable Echo/Noise-Cancellation
load-module module-echo-cancel use_master_format=1 aec_method=webrtc aec_args="analog_gain_control=0\ digital_gain_control=1\ agc_start_volume=85\ beamforming=1\ mic_geometry=-0.03,0,0,0.03,0,0\ target_direction=1.571,0,0" source_name=echoCancel_source sink_name=echoCancel_sink
set-default-source echoCancel_source
set-default-sink echoCancel_sink
The Auto gain control is preference as it can make recognition worse or better due to scenario.
“1” = on & “0” = Off.
I never played with these
high_pass_filter=1
May help as much is outside voice spectrumnoise_suppression=1
- Noise suppression. Noise suppression can clean but seems to do little to improve recognitionvoice_detection=1
- VAD - Voice activity detection which wasn’t sure its a RMS value of average voice spectrum but never worked out if it mutes if not of a level.
The target direction has no update but the above should create a beam perpendicular to your 2 mic array.
The beamforming sadly has been dropped from webrtc as its becoming part of devices rather than needing software so on the next release of pulseaudio it works for now.
Otherwise take a look at the respeaker wiki for the 4 mic array as the EC & DOA could equally be used for 2 mic as 4 mic, but still waiting for my 4 mic and havent really played with them yet.
You are quite an Alsa expert already as said it pretty simple stuff the confusion is why and what Mycroft sets up in scripts and conf.
Generally its a WTF is that Mycroft setup stuff because I am confused at rationale and implementation, to something that has simple default setup tools built in aka alsa_utils.
amixer --help
alsactl --help
May give your more info but its likely you will find its the Mycroft script and conf that are doing the setting and making this far more confusing than it should.
There is also /home/pi/.setup_choices
{
"audio": "analog_audio",
"mic": "ps_eye"
}
Which I am totally clueless about.
# While the Raspberry Pi is a standard board, these have been known to vary by
# system; you can always use `aplay -L` to check
# sudo amixer cset numid=3 "0" # audio out to the USB soundcard
# sudo amixer cset numid=3 "1" # audio out the analog speaker/headphone jack
# sudo amixer cset numid=3 "2" # audio out the HDMI port (e.g. TV speakers)
Was just copied from a Mycroft script and my advice is to ignore as it make literally no sense.
amixer controls
will prove that as controls are switches, volumes and more, not card devices.
pi@picroft:~ $ amixer controls
numid=4,iface=MIXER,name='Master Playback Switch'
numid=3,iface=MIXER,name='Master Playback Volume'
numid=2,iface=MIXER,name='Capture Switch'
numid=1,iface=MIXER,name='Capture Volume'
Hence why I am guestimating editing /boot/config.txt
dtparam=audio=off
sudo reboot
Is likely a fix as fiddling with alsa will likely do nothing due to the strange audio setup of Mycroft.
Dunno as its the Mycroft config and rationale that confuses me but you have that info and you can test as don’t have a 2 mic and still waiting for my 4 mic.