Raspberrypi as UPNP renderer
Stream music to Raspberrypi using DLNA and a UPNP control point such as Bubbleupnp.
UPnP Renderer
Setup UPNP Renderer
According to wikipedia, "Universal Plug and Play (UPnP) is a set of networking protocols that permits networked devices, such as personal computers, printers, Internet gateways, Wi-Fi access points and mobile devices to seamlessly discover each other's presence on the network and establish functional network services."
We will be setting up Raspberrpi such that other devices on the same network can find it as a UPNP renderer(Something which can play music). How will it play music you may ask. We will use the Music Player Daemon (MPD) for that. MPD runs as a daemon that actually supports music control over the network using MPD Client, but it need access to music files locally so that it can index them. That was the main reason to move away from Volumio. We want to play music which is already indexed and available on local network in form of DLNA media server.
To overcome this, we will use a library, upmpdcli, which runs UPnP media renderer daemon on top of MPD.
To get started, let's first install MPD itself. Run below code to achieve that. Lets install MPC as well to test if our MPD is working. It wont be used when we introduce upnpdcli.
sudo apt-get install mpd mpc
Let's now configure MPD to use the correct PCM device setup by us in Setup Pi with I2S DAC. We actually need all default setting for MPD apart from Audio output section. Hence lets delete the oringinal config file and create our owm. Or you can save the original config file as backup with .bk extension in last. To do that, run below command.
sudo mv /etc/mpd.conf /etc/mpd.conf.bk sudo nano /etc/mpd.conf
Paste the following content in order to set our PCM device as audio output. Click Ctrl+x
then y and enter
to save it.
audio_output { type "alsa" name "IQAudio DAC Plus HW" device "hw:0,0" # optional mixer_type "hardware" # optional mixer_device "hw" # optional mixer_control "Digital" # optional }
To test if MPD is working, reboot the pi and check the MPD service status using below command. It should show active (running). Exception about wildmidi is fine.
systemctl status mpd.service
Now we will use MPC to test if our MPD is running. Remember pink panther? Use below code to add the track to playlist and start playing.
mpc add https://www2.cs.uic.edu/~i101/SoundFiles/PinkPanther30.wav mpc play
You should hear Pink Panther. If that is the case, the MPD is working. Yay!. You should try setting the volume using below command and cross verify it with alsamixer "Digital" control if that is getting updated as well.
mpc volume 50 alsamixer
If that is the case, our MPD is working as expected. Now we can move forward to install upmpdcli. Detailed step to install are mentioned on lesbonscomptes website which you can refer. I am using Debian Bullseye, hence will be using that as example. You are free to follow steps specific to your release.
We need to add repository key to download the package from lesbonscomptes website. To do that, execute below.
wget https://www.lesbonscomptes.com/pages/lesbonscomptes.gpg sudo mv lesbonscomptes.gpg /usr/share/keyrings/
Once this is done, we need to download the apt source list and place it so that apt-install can get the file based on name. To do that, execute below code.
wget https://www.lesbonscomptes.com/upmpdcli/pages/upmpdcli-rbullseye.list sudo mv upmpdcli-rbullseye.list /etc/apt/sources.list.d/
Now we can install required packages using apt-get.To do that, we need to update the source list.
sudo apt-get update sudo apt-get install upmpdcli
Once that is installed, lets updated the upmpdcli config using below command.
sudo nano /etc/upmpdcli.conf
Uncomment the below line to set a friendly name to your streamer.
# "Friendly Name" for the Media Renderer (Open Home).
friendlyname = Living Room Speakers OH
# Specific friendly name for the UPnP/AV Media Renderer.
avfriendlyname = Living Room Speakers AV
Uncomment below lines to enable Open home as well as A/V Renderer
# Enable UPnP AV services (0/1).
upnpav = 1
# Enable OpenHome services (0/1).
openhome = 1
Save and restart your pi. Check the service status of upmpdcli with below command. You should see active (running) status.
systemctl status upmpdcli.service
Open any UPnP app and check if it shows up in media renderer. I tried with Hi-Fi Cast and BubbleUpnP and it works with both. Enjoy streaming your Hi-Res music collection to your favourite speakers.