I have a RPi 3 B+ with the Respeaker 2-mic and basic Logitech speakers plugged into the audio jack and USB (for power). I have Raspbian Buster Lite installed.
Followed the standard install of the Respeaker device. It seems to work. aplay -l lists the device as noted on the install guide / page.
Specify the symbolic name of the sink to play this file on.
so try paplay -d or paplay --device with the correct device name from paplay -L
Why Mycroft has various audio conf files I will let you ask someone else.
You can set it in several place but which is ‘correct’ or why multiple places you can set conf is curious.
To /etc/pulse/default.pa just sudo nano /etc/pulse/default.pa
Its X,Y,Z in meters from center of device.
Unfortunately that is getting dropped from pulseaudio as upstream in webrtc it already has.
So use the Respeaker guide as it is webrtc but the repo’s hopefully will remain.
Someone should be sending @gez-mycroft pressies of
2 Mic Array for Pi
4 Mic Array for Pi
Linear 4 Mic Array for Pi
USB 4 Mic Array
As a Howto Mic setup for Dummies, step by step guide would be of much use to many.
As its pretty simple but also quite confusing.
But if you check the 4 Mic Array for Pi / Linear 4 Mic Array for Pi info you can use the other great libs they provide but change the channels to 2 where it says.
The Respeaker has it’s own 3.5mm audio jack, which the speakers were plugged into. This had worked on initial install / run.
I switched the speakers to the Pi’s own audio jack and both aplay filename.wav and paplay filename.wav produces output, and the mic’s are still recording too.
(note, for paplay, this didn’t require the “-d” switch)
Pulseaudio should start or do you have to enable it? My memory but hey. systemctl --user enable pulseaudio.service
It will now start on each boot.
https://www.alsa-project.org/wiki/Asoundrc
But basically create a $HOME/.asoundrc conf file and we will shift to the better DAC presuming so as the Pi is adequate but not the best.
Which because its the same for sink/source (speaker/mic) then this will prob do it.
pcm.!default {
type hw
card 1
}
ctl.!default {
type hw
card 1
}
Swap your jack and give it a reboot and check service has started and sound is now from the respeaker.
There is no source on card 0 (armsoc) hence why it picked up the mic on the respeaker.
I am thinking if ALSA is set then with current settings pulseaudio will follow suit.
Also if you tack this to the end of /etc/pulse/default.pa you will also have AEC and Autogain with a singular mic stream for mycroft processing.
PS I always forget if its the conf or cli that needs \ delimiters after for each parameter that has a following one.
If the above doesn’t seem to do anything pacmd list will give a fairly exhaustive list and you should have echoCancel_source/echoCancel_sink in there pacmd list-sinks for outputs pacmd list-sources for inputs
Its one of the 2
The 0.03 measurement should be what ever the distance is from the center of the respeaker card to mic in meter.
So its 2 mics 6cm apart 3cm from center in the above hence +/- values
That codec doesn’t look that bad. https://www.cirrus.com/products/wm8960/
Oh sod it We will just turn soc audio off.
/boot/config.txt dtparam=audio=off
My bad I guess as its card 1 for output and card 0 for input.
Should of prob had playback and capture defined so it gets the card difference as even though same card the index is different due to the internal sound card but no internal input.
playback.pcm "hw:0,0"
capture.pcm "hw:1,0"
Delete that .rcsoundrc turn off built in audio and you should be good to go, but prob should of been above.
Problem is the Myford setup scripts for me make things more confusing as it should be fairly easy to use standard amixer tools to set the sound setup.
There is /home/pi/audio_setup.sh that contains
#!/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
So even if I did get a asoundrc right its prob going to be overwritten on login, but wow make something confusing as which runs first bashrc or asoundrc?
Why does that exist as that is what asoundrc is for or standard tools like alsactl store?
then we also have the helper scripts mycroft-config set listener.device_name
To what and why is a complete confusion to me as you can set once with amixer and then sudo alsactl store
Which will save current settings to /var/lib/alsa/asound.state
Its sudo /etc/init.d/alsa-utils reset to reset
So even though could do the following
amixer show basic info amixer controls show the basic controls amixer cget numid=3 get info for control 3
# 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)
I have never used sound headless before on linux so alsa and pulseaudio is all new to me as it was just there on the desktop and worked.
The above bemused me as thought that would just set the master volume but seems if in quotes its sets the hardware ID, but really not sure why so many different places and settings and why not standard Alsa utils.
So why not sudo alsactl store and default alsa controls and
sudo /etc/init.d/alsa-utils reset
To reset back?
Scripts that don’t add functionality but are purely a different method to standard function are not a good idea, but hey.
Prob easiest way if just to disable builtin audio in this case and delete my bad attempt at a asoundrc.
As its still likely for what ever reason there is a conf galore of options of extra scripts to what asla-utils does natively.
I really don’t get why and will leave you to decide but now you should be a Mycroft audio setup expert and one of those configs should work or like me you may get so confused and totally make a hash of things.
Just delete what you did and reset and start from scratch again but why things are in this way to supposedly make things easier is just a bemusing reality to me.
Things often are, we have Trump and things called Brexit and obviously I am just not in the loop.
So I am assuming ~/.asoundrc should be applied LAST?
I had expected the standard installation to include the onboard device as well as detecting an additional sound card or the ability to add it in(?). I can disable the onboard sound card but it doesn’t seem “right” to me.
Following your logic, I expected ALSA to recognise this “hw” card as 1, from the aplay -l command:
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.
#!/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]
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
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 spectrum
noise_suppression=1 - Noise suppression. Noise suppression can clean but seems to do little to improve recognition
voice_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.
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.
It seems I broke the Pi, unplugging the HDMI cable while powered on. Now the unit will not boot, no ACT light.
Awaiting a new unit being delivered, if the company still are with covid-19 pandemic…
But then I can retry all this. Best way to learn…
Only looking at other Alsa files to get an understanding. I need to ensure the hardware is functioning properly - mic and speakers - before moving onto Mycroft stuff I think.
Now when you play with Alsa it will not be just overwritten so it will use defaults set.
I was the same getting confused with Alsa but for some reason its hardcoded with specific hardware requirements.
Not sure why they are included or the audio setup as Mycroft itself is a specific device, whilst a limited shortlist of hardware in Picroft just seems to make things more confusing for little benefit?
But hey its fairly simple once you do the above and think it would just be better without, from the start.