Until recently, I only used my RaspberryPi 3 as Bluetooth Speaker with the HifiBerry AMP2 and two old B&W DM601. This setup only consumes about 3 Watts idling, so its running 24h. I used the VLC Android App on my smartphone to access my music on my NAS and streamed it via Bluetooth to the Pi.
But I wanted to control the music on different devices (like Tablet, HTPC, Desktop) and was annoyed, having to reconnect my smartphone Bluetooth connection all the time when coming home. Also there is still a loss of quality with Bluetooth and i have many FLAC files now. That’s why I gave Music Player Daemon (MPD) a try. A daemon which runs on the Pi and can be controlled from different clients. It accesses my music library via Wifi directly on the NAS.
These are the steps I had to make on my Raspberry Pi:
Firmware update
Set up the the Hifiberry AMP2 (if not yet done)
Mount NFS share with your music
Install MPD and the clients MPC and ncmpcpp
Edit MPD config file
Run MPC update to fill library
Configure NCMPCPP
MPDroid as smartphone client
1. Firmware update
I had some audio cracking when switching a song or just pressing play and pause. Following this blog, they released a fix with in a newer firmware version, unfortunately after a while they broke it again with a later firmware version…. nevertheless I made the update and somehow I get less cracking, even if it doesn’t disappear completely.
sudo apt install autofs
sudo nano /etc/auto.nfs
sudo nano /etc/auto.master
sudo service autofs restart
mount
ls /mnt/nfs/music/
sudo reboot
#check again after reboot
ls /mnt/nfs/music/
auto.nfs
music -fstype=nfs,rw,retry=0 192.168.178.100:/data/music
auto.master
/mnt/nfs /etc/auto.nfs
4. Install MPD and the clients MPC and ncmpcpp
sudo apt update
sudo apt install mpd mpc ncmpcpp
5. Edit MPD config file and restart service
Open the mpd.conf file in your favorite editor and after editing, restart the service.
The Music Player Client (MPC) acts as client (as well as ncmpcpp) to MPD. MPD itself is just the daemon and has no music controlling capabilities.
#check if the output(s) is enabled
mpc outputs
#update the database (will take while)
mpc update
#look up the commands to adjust volume and play a file as test
mpc help
7. Configure ncmpcpp
When using ncmpcpp as client, you have to do a small configuration to tell the client to which server it should talk to. So open the config:
sudo nano ~/.ncmpcpp/config
and insert the following lines. When using ncmpcpp directly one the raspberry, set 127.0.0.1 as mpd_host. When using it on another machine (like your desktop), insert the IP of the raspberry pi.
For music playback at home I have built my own Bluetooth Speaker. It’s a RaspberryPi 3, on top a HifiBerry AMP2, and they are powering two B&W DM601. I have used this script to setup bluetooth and configure the audio settings. Because bluetooth is the only way to pass audio to the raspberry (besides running music on the raspberry itself, e.g. via MPD/MPC), I was thinking of a way passing audio via chinch cable. I grabbed an old USB Soundcard I had laying around and connected it to the raspberry. Now I had to forward the USB Soundcard Audio Input to the HifiBerry AMP2. I found a way using PulseAudio for this. Got it from here.
#find input device (my USB Soundcard)
pactl list sources
#find output device (my HifiBerry AMP2)
pactl list sinks
#set loopback
pactl load-module module-loopback source=src_name sink=sink_name
But most USB Soundcards only have Mono-Audio-In and often there a annoying noises through the input… So this was really no joy and I will continue using bluetooth.