Repository navigation
management
The Management/showInstallation.bash script displays which pieces of the system described here have been installed
and how the audio flows within the Raspberry Pi (RPi).
A reference RPi image can be placed on all RPi's in the system. Yet from one room amplifier to another, some changes may have to be done.
As different amps may have different configurations, such as the amplifiers,
the files in RPi-multiroom-audio/LocalSettings are ignored on a master git push.
Backup the files before a new git pull and restore them afterwards:
source ~/.bash_aliases cd $AUDIO_BASE_DIR Management/localSettings.bash backup git pull -v Management/localSettings.bash restore
The local files list is coded inside localSettings.bash and changes will also remain on a git pull.
Calling the scripts bases on the environment variable AUDIO_BASE_DIR.
This variable is set when sourcing RPi-multiroom-audio/configuration.bash.
This should be done by calling RPi-multiroom-audio/configuration.bash in ~/.bash_aliases
with the proper path.
Test it (adapt path):
source ~/.bash_aliases echo $AUDIO_BASE_DIR
Obviously, every RPi on the same network want a different hostname.
Changing the hostname can be done using the RPi configuration editor:
sudo raspi-config
1 System Options
S4 Hostname
Another option is to use the hostname command.
newName=amp-lounge hostnamectl set-hostname $newName
Check the result:
hostname -f cat /etc/hosts cat /etc/hostname
Bizarrely, both methods don't update 127.0.1.1 in /etc/hosts.
Yet this is mandatory for changing to a fixed IP address.
Changing the hostname can be done by (adapt the name and the path):
NEW_NAME='amp-lounge' sudo $AUDIO_BASE_DIR//Management/setHostname.bash $NEW_NAME
The text-based user interface nmtui allows to edit the machine's connections.
If it isn't automatically mounted, mount the /boot/firmware partition:
mount | grep firmware sudo mount /boot/firmware/
Disable Wi-Fi by editing the configuration file:
sudo nano /boot/firmware/config.txtand add:
# Disable wi-fi dtoverlay=disable-wifi
Reboot to apply the change.
If moving from one place to the other, manage the Wi-Fi connections with:
sudo nmtui
From Raspberry Pi OS Bookworm, networking is controlled by NetworkManager
and its command-line tool nmcli.
nmcli -p connection show | cat nmcli device show eth0
Change to a fixed IP address (adapt the addresses):
FIXED_IP_ADDRESS='192.168.1.50' CONNECTION='Wired connection 1' sudo nmcli con mod "$CONNECTION" ipv4.addresses $FIXED_IP_ADDRESS/24 sudo nmcli con mod "$CONNECTION" ipv4.method manual sudo nmcli con mod "$CONNECTION" ipv4.gateway 192.168.1.1 sudo nmcli con mod "$CONNECTION" ipv4.dns 192.168.1.1
This can be done by (adapt the address and the path):
FIXED_IP_ADDRESS='192.168.1.50' sudo $AUDIO_BASE_DIR/Management/setIpAddress.bash $FIXED_IP_ADDRESS
Reboot to apply the settings. Alternatley, if working directly on the machine:
sudo nmcli c down "Wired connection 1" && sudo nmcli c up "Wired connection 1" sudo nmcli connection show "Wired connection 1" | grep -v '\-\-'
Change back to an automatic IP address:
sudo nmcli con mod "Wired connection 1" ipv4.method auto ipv4.addresses "" ipv4.gateway ""and reboot.
Some cards, such as the HiFiBerry DACs and amps require an overlay to be recognized.
Check the kernel version:
uname -srm
For HiFiBerry] DACs and amps, check their documentation
and update config.txt.
If one doesn't automatically mount the firmware boot partition:
mount | grep firmware sudo mount /boot/firmware/
Edit the configuration file:
sudo nano /boot/firmware/config.txt sudo reboot
Not all RPi's necessarily have the same amplifier hat.
Being at the end of the audio chain, the soundcard is driven by either mopidy, snapclient or CamillDSP.
Check the soundcard's name:
aplay -l | grep ^card
Check which application drives the soundcard (adapt the path):
$AUDIO_BASE_DIR/Management/showInstallation.bash
Update AMPLIFIER_SOUNDCARD in ~/Documents/RPi-multiroom-audio/configuration.bash
and update the environment variable:
source $AUDIO_BASE_DIR/configuration.bash
Change the application's service configuration file.
In the case of snapclient:
sudo sed -i -E "s/^(SNAPCLIENT_OPTS=.*--soundcard\s+)[a-zA-Z]*/\1$AMPLIFIER_SOUNDCARD/" /etc/default/snapclient
Restart the service (adapt):
SERVICE=snapclient sudo service $SERVICE restart
Check who is using what audio device:
grep -RH owner_pid /proc/asound/ | sed '/^\/proc\/asound\/card/d' sudo lsof | grep /dev/snd/pcm | grep ' CHR ' | grep -v ' mem '
Check the soundcard hardware parameters:
AMPLIFIER_CAPACITIES=`aplay -v -D dmix:$AMPLIFIER_SOUNDCARD --dump-hw-params /dev/zero 2>&1 | grep -iE '^format|^rate|^channels'` echo -e "$AMPLIFIER_CAPACITIES" cat /proc/asound/$AMPLIFIER_SOUNDCARD/pcm0p/sub0/hw_params
View Mopidy's configuration:
sudo mopidyctl config
View Mopidy's output:
$AUDIO_BASE_DIR/Mopidy/mopidySink.bash
Change Mopidy's output (select which and adapt):
$AUDIO_BASE_DIR/Mopidy/mopidySink.bash -v /tmp/snapfifo $AUDIO_BASE_DIR/Mopidy/mopidySink.bash -v $ALSA_LOOPBACK_CAPTURE_DEVICE,$SNAPSERVER_LOOPBACK_SUBDEVICE cat /etc/mopidy/mopidy.conf
Test Mopidy's output to the ALSA loopback:
sudo service snapserver stop alsaloop -C hw:$ALSA_LOOPBACK_PLAYBACK_DEVICE,$SNAPSERVER_LOOPBACK_SUBDEVICE -P hw:$AMPLIFIER_SOUNDCARD 2>/dev/null & # listen to the audio output pkill alsaloop sudo service snapserver restart
View Snapclient's input sources list:
snapclient -l
View Snapclient's input host:
cat /etc/default/snapclient | grep ^SNAPCLIENT_OPTS= cat /etc/default/snapclient | grep ^SNAPCLIENT_OPTS= | sed s/.*--host/host/ | cut -d ' ' -f 1-2 $AUDIO_BASE_DIR/Snapcast/clientSource.bash
Change Snapclient's input (adapt hostname):
$AUDIO_BASE_DIR/Snapcast/changeServer.bash -v audioamp.local
View Snapclient's output:
$AUDIO_BASE_DIR/Snapcast/clientSink.bash
List Snapserver's possible outputs:
snapclient -l | grep CARD=
Change Snapserver's output (adapt soundcard name):
$AUDIO_BASE_DIR/Snapcast/clientSink.bash -v sndrpijustboomd cat /etc/default/snapclient
View CamillaDSP's output:
cat $CAMILLA_CONFIGURATION_FILE | grep -A 4 playback
View the services and their place in the audio path:
$AUDIO_BASE_DIR/Management/showInstallation.bash
Note that the configuration file for CamillaDSP doesn't allow to refer to environment variables.
If changing the soundcard, edit it accordingly:
aplay -l | grep ^card nano $CAMILLA_CONFIGURATION_FILE
The volume is given by a series of volume controls along the audio chain. Yet it is good practice to reduce the volume as late as possible in the chain.
The web user interface allows to set the music volume.
Also the mopidy API allows to remotely control it.
Finally, a script allows to get or change the volume:
$AUDIO_BASE_DIR/Mopidy/volume.bash -v $AUDIO_BASE_DIR/Mopidy/volume.bash -v 10 $AUDIO_BASE_DIR/Mopidy/volume.bash -v mute $AUDIO_BASE_DIR/Mopidy/volume.bash -v unmute
One can add the following lines in ~/.bash_aliases:
alias volume-mopidy='$AUDIO_BASE_DIR/Mopidy/volume.bash -v' alias volume-m='$AUDIO_BASE_DIR/Mopidy/volume.bash'
The volume of the snapcast clients can be controlled on the snapcast server.
It can be changed by a JSON-RPC request (adapt):
VOLUME=20
SNAPCAST_SERVER='localhost'
SNAPCAST_CLIENT='00:00:00:00:00:00'
curl -sw "\n" -d "{\"jsonrpc\":\"2.0\", \"id\":1, \"method\":\"Client.SetVolume\", \"params\":{\"id\":\"$SNAPCAST_CLIENT\", \"volume\":{\"percent\":$VOLUME}}}" -H 'Content-Type: application/json' http://$SNAPCAST_SERVER:1780/jsonrpc
One can also use the control script:
$AUDIO_BASE_DIR/Snapcast/setVolume.py -v 20
One can add the following lines in ~/.bash_aliases:
alias volume-snapcast='$AUDIO_BASE_DIR/Snapcast/setVolume.py -v' alias volume-s='$AUDIO_BASE_DIR/Snapcast/setVolume.py'
Volumes can be checked by:
$AUDIO_BASE_DIR/Snapcast/getStatus.py
If using CamillaDSP,
the volume can be statically set in a mixer.
It can also be modified on the fly using the web interface.
One can also use the control script:
VOLUME=20 $AUDIO_BASE_DIR/CamillaDSP/Scripts/setVolume.py $VOLUME
At the end of the audio chain, the output volume is eventually controlled by ALSA.
Change the volume:
alsamixer -D hw:$AMPLIFIER_SOUNDCARD amixer -D hw:$AMPLIFIER_SOUNDCARD scontrols amixer -D hw:$AMPLIFIER_SOUNDCARD get Digital amixer -D hw:$AMPLIFIER_SOUNDCARD -q sset Digital 60%
Check the whole volume chain:
$AUDIO_BASE_DIR/Management/showVolume.bash
The sampling rate and the sample bit number is defined as follows:
- for
mopidyin/etc/mopidy/mopidy.conf - for
snapserverin/etc/snapserver.conf(line withsampleformat)
AMPLIFIER_DEVICE=`aplay -l | grep ^card | grep -v Headphones | grep -v vc4hdmi | grep -v Loopback` AMPLIFIER_SOUNDCARD_ID=`echo $AMPLIFIER_DEVICE | cut -d ' ' -f 2 | tr -d :` AMPLIFIER_SOUNDCARD=`echo $AMPLIFIER_DEVICE | cut -d ' ' -f 3` echo "amplifier soundcard is card $AMPLIFIER_SOUNDCARD_ID, $AMPLIFIER_SOUNDCARD" AMPLIFIER_CAPACITIES=`aplay -v -D dmix:$AMPLIFIER_SOUNDCARD --dump-hw-params /dev/zero 2>&1 | grep -iE '^format|^rate|^channels'` echo -e "$AMPLIFIER_CAPACITIES"
View service definitions:
cat /lib/systemd/system/mopidy.service cat /lib/systemd/system/snapserver.service cat /lib/systemd/system/snapclient.service cat /lib/systemd/system/camilladsp.service
This presents the startup dependencies.
It also shows that the executables are located in /usr/bin.
View runnning services:
systemctl list-units --type=service --state=running | cat systemctl list-units --type=service --state=failed
Try to restart failed services:
sudo systemctl reset-failed
Disable a service:
SERVICE='snapclient' sudo systemctl stop $SERVICE sudo systemctl disable $SERVICE
Check the RPi model:
cat /sys/firmware/devicetree/base/model
The CPU load of the different applications can be seen with the command:
top -o %CPU -d 0.5 -n 10
On a RPi 3, with 48 kHz sampling rate and 16 bit samples (192 kHz sampling rate and 32 bit samples), the average load is:
- mopidy : 6-7 % (18-20 %)
- snapserver : 6-7 % (15-17 %)
- snapclient : 2-3 % (5-8 %)
camilladsp running a simple mixer and camillagui serving a web page,
the CPU load is:
- mopidy : 16-22 %
- snapserver : 14-20 %
- snapclient : 10-13 %
- camilladsp : 8-13 %
- camillagui : 9-10 %
The memory usage is shown by:
cat /proc/meminfo
On a RPi 3 with 1 GB RAM, it is of 32 MB.
The swap usage is shown by:
swapon -s
On the RPi 3, it is zero.
The sockets usage is shown by:
ss -tra4
If the Mopidy user interface is running on the default port,
you should see lines with the local port 6680.
If CamillaDSP is running, you should see a line with the local port 5005.
If the CamillaDSP GUI is running, you should see lines with the local port 5006.
Test write speed:
dd if=/dev/zero of=~/test.tmp bs=500K count=1024
After having written the file, test read speed:
sync; echo 3 | sudo tee /proc/sys/vm/drop_caches dd if=~/test.tmp of=/dev/null bs=500K count=1024 rm ~/test.tmp
Order of magnitudes for the speeds are found in the SD card performance table.
Check CPU temperature:
vcgencmd measure_temp
Instead of also having the /boot/firmware mounted read-only, on can define it as not automatically mounted in /etc/fstab with the attribute noauto.
Yet with this, one has to remember to mount the boot partition before upgrading the system.
A read-only root file system resists much better to power drop without a proper shutdown. For this, Raspberry Pi OS provides the option of having an overlay file system.
Enable (or disable) it:
sudo mount /boot/firmware sudo apt update sudo apt upgrade -y sudo raspi-config
and navigate to
-
4 Performance OptionsP2 Overlay File System Enable/disable read-only file system
sudo mount /boot/firmware sudo raspi-config nonint enable_overlayfs sudo reboot
or :
sudo mount /boot/firmware sudo raspi-config nonint disable_overlayfs sudo reboot
To check if the overlay filesystem is active, look a the disk usage:
df -h | grep /$
If there is an overlayroot mounted on /, this means that the overlay is enabled.