Raspberry Pi as minimalist high quality UPnP audio renderer

marmitesandwich

Novice Member
0. Background
I have tried various turnkey-packaged solutions for using a Pi as a music renderer, but they generally didn't satisfy because they were designed to do more than be a renderer, while the renderer function failed on various counts. First, they seemed to all use an old version of mpd, the music player daemon, and secondly, they didn't support the use of an infra-red remote control. Some didn't support gapless playback. Or they didn't like the internet radio links coming from my main music server (Minimserver).

The reason the mpd version is important is because I sometimes stream Google Play Music(GPM), via BubbleUPnP on android devices, which makes GPM look like a UPnP music server. This only works reliably for me with mpd versions after 0.21, because GPM servers have a tendency, for tracks > c10 mins long, to close the stream if the renderer is demanding data in chunks which it considers too small. After 0.21, mpd downloads to a buffer ("- curl: download to buffer instead of throttling transfer"), and then plays the downloaded data. After experimentation, I found this made all the difference, using tracks which I knew always failed at a certain point. Thanks to the developer at Bubblesoft for pointing me in this direction.

So I tried out standard Raspbian, and after some experimentation, I worked out a solution that met these criteria:-
- no digital processing except decoding mp3/m4a streams/files
- plays long GPM tracks without closing them halfway
- supports gapless playback
- plays all my internet radio streams without issue
- can be operated via a standard USB Infra Red Windows MCE remote control

The setup under which this works is:
- (UPnP Server) Minimserver, Minimstreamer and BubbleUPnP Server running on an Intel 386 device with Turnkey Linux 14. TKL is based on Debian 8, which is closely related to Raspbian, so these server functions could be migrated to the Pi, but I prefer to keep them separate. It's cheap obsolete hardware. All Ethernet.
- (UPnP Control Points) Windows/UPPlay, iOS/Kazoo, Android/BubbleUPnP. Mixed WiFi/Ethernet.
- (UPnP Renderer) Raspberry Pi 3B, Raspbian (2018-11-13-raspbian-stretch-lite). Ethernet.
- (DAC) I have 2 Pis, one which uses a USB port to connect to a Cambridge Audio DACmagic, one uses the HifiBerry add-on card. Both work with the same settings shown below.

So the solution is basically stock Raspbian, followed by installing two programs from the Raspbian repository: mpd and upmpdcli. Some editing of config files is required, and they will both be working together as a UPnP renderer, along with a remote. If you are Windows-familiar and Linux-new, you will be able to access the Pi over your network, using PuTTY or similar for entering Linux commands, and WinSCP or similar for copying/moving/editing files. (NB Linux is case sensitive and Linux comments start with #.) Both of these PC utilities are freely available on the web, and will require you to know the IP address of your Pi, preferably fixed. These notes are written from the perspective of a Windows user who is not familiar with Linux. Experienced Linux users can snigger at my comments and pick out the interesting bits.

1) Create a working Raspbian system, with suitable authorities.
Download the Raspbian image, from here:
https://downloads.raspberrypi.org/raspbian_lite_latest
Flash your microSD card (minimum 4GB), using balenaEtcher or Win32DiskImager, both available for free on the web. When it is finished, eject the card and re-insert it, and identify the smaller "boot" partition, which will look like one of 2 separate drives (e.g. D and E). Place a file called ssh in this. An empty text file is OK, but it should have no extension. Eject the card, insert into Pi and boot up. You should now be able to "ssh" in to the Pi by running PuTTY, connecting to your Pi's IP address and sign on with the standard Pi user ID/pwd, which is pi/raspberry. Obey the instructions to change this password (enter the command passwd), and don't forget it. You are going to need root privileges, (like administrator in Windows), so create a password for this by entering
sudo passwd root, and entering your new password twice, also not forgetting it. You will also need to give permission for WinSCP to login and modify files, so do this:
sudo nano /etc/ssh/sshd_config
You are now using a utility called nano to edit a config file called sshd_config. Using your best investigative skills, locate a line which starts with
#PermitRootLogin without-password
or similar. Modify the line so that it says
PermitRootLogin yes
and save and exit. Nano is not exactly Microsoft Word, so it might take a few minutes to get the hang of it. Type
sudo reboot
Now check that you can login with WinSCP, using the new root password. You should be able to move around directories like with Windows File Explorer, and use the inbuilt editor to modify text files, such as sshd_config above.
Ssh in with PuTTY as pi, and do
sudo raspi-config
select 8 Update first then
4 Localisation to set local timezone, keyboard etc.
3 Boot options>B1 Desktop>B2 Console Autologin
This last is to ensure that your remote control will be able to talk to the console as if it was a keyboard. If you haven't been prompted to reboot, do so:
sudo reboot
You can now ssh in with the root password (ID is root).
Now test the audio. Connect the analogue headphone jack or the HDMI port to a suitable device and type
aplay /usr/share/sounds/alsa/Front_Center.wav
You should hear a nice lady's voice.

2. Install upmpdcli.
The player, mpd, responds to commands from a suitable client, which tells it what to play and how. The link between our upnp control point and the mpd player is upmpdcli (UPnP mpd client?). More information (including donation option) at:
Upmpdcli downloads
It comes via the repository, a kind of Play Store for your distro of Linux (except everything is free and safe). Type
apt install dirmngr
then
apt-key adv --keyserver pool.sks-keyservers.net --recv-keys F8E3347256922A8AE767605B7808CE96D38B9201
Now using WinSCP, create this file /etc/apt/sources.list.d/upmpdcli.list and edit it to contain these lines:
deb Index of /upmpdcli/downloads/raspbian stretch main
deb-src Index of /upmpdcli/downloads/raspbian stretch main

then type
apt update
apt install upmpdcli

Now you can edit /etc/upmpdcli.conf.
You can set the friendly name to something nice which will appear in your control point. Also you can create an icon and place it in the appropriate folder (directory), subject to the constraints detailed in the config file above.
This will help with radio streams (remove the comment #):
set checkcontentformat = 0
Save and:
reboot

3. Install mpd
At the time of writing, the stock version of mpd in the Raspbian repository is old. We can get a new version by using the testing repository.
Using WinSCP, edit /etc/apt/sources.list, changing stretch to testing, then
apt update
apt install mpd

This will take a while. Test the version of mpd you have.
mpd --version
Should be >=21.4.
Edit /etc/apt/sources.list, changing testing back to stretch, then
apt update
Use WinSCP to edit /etc/mpd.conf
Set mixer_type "software" in audio_output type "alsa" for volume control. This potentially introduces digital signal processing, but as long as your volume is set to 100%, my understanding is that there wouldn't be any. Use the volume control on your control point and you introduce compromise!
reboot
You should now have a working UPnP renderer. Test it with your known good control point and server, with the same analogue/HDMI device which you tested above. The sound will probably be gross. In order to make this play through your digital device, edit /usr/share/alsa/alsa.conf and replace
defaults.ctl.card 0
defaults.pcm.card 0

with
defaults.ctl.card 1
defaults.pcm.card 1

save and reboot.
Test as a UPnP renderer via your DAC.

4. Configure the remote control.
This is a bit of a hack, which could undoubtedly be made more elegant and more comprehensive. I am only looking for the possibility to pause/unpause the player; mute and unmute; and skip/backup one track. Any more than that is a job for the control point, in my world. The standard USB Remote for the Media Centre Edition version of Windows, is quite a common device made by many different suppliers and available online for as little as $5. I recommend buying a more expensive model to get reliability and durability, like this:
61a+u742jHL._SL1100_.jpg

You can recognise them by the standard Windows buttons, including Internet Explorer! Well, without any keyboard or HID reconfiguration, I found that about half the buttons created a NULL character, but the up/down/left/right buttons in the middle all generated recognisable codes, which I have introduced into the inputrc config file, so that they bind to a suitable mpc command. Mpc is another client for mpd, which allows a user to issue commands to mpd, like "mpc toggle", which toggles play/pause. So, using WinSCP again, find and edit etc/inputrc, so that it includes the following lines, preferably added at the end of the file:
#StartRemote
"\000": 'mpc toggle\015'
"\033\133\101": 'mpc volume 100\015'
"\033\133\102": 'mpc volume 0\015'
"\033\133\103": 'mpc next\015'
"\033\133\104": 'mpc prev\015'
#EndRemote

Save and reboot.
Plug in the remote and test its functions.
Up/down should produce max volume/mute.
Left/right should produce skip back/forward.
Play (and several other buttons) will toggle between play and pause.

5. Enjoy
I am happy to respond to questions if I can, but the above works for me for the quoted setup, and I don't have experience of other ways of doing it which provide the same functionality. I should mention that there is a slight security risk, in that the pi user is always logged on at the console, which is being accessed by the remote. This could be replaced by a remote IR keyboard being held outside your window and pointed at your IR receiver. If that bothers you, don't use the remote and disable the auto login in raspi-config, or find a more elegant solution to it.
Cheers,
Marmite

 
Last edited:

TheHighFlyingBirds

Well-known Member
Your method sounds complicated. I run picoreplayer on my pi3 (with touch screen). Did you try that? As im sure that allows gapless playback, use of upnp program like bubble and allows for use of IR. Setup was very easy, even i managed it and it didnt require to ssh into it as it has a web based interface.
 

marmitesandwich

Novice Member
I run picoreplayer on my pi3 (with touch screen). Did you try that?
Yes I did try that one. I also tried moode, runeaudio, volumio, pimusicbox and mopidy. The problem I found was with playing long Google play music tracks via bubble , which is a characteristic of older versions of mpd. It seems the only way to get round this is to install the latest version of mpd.

The pi in this case is minimalist in that it has no peripherals like a touch screen. Hence ssh.

Marmite
 

TheHighFlyingBirds

Well-known Member
Wow you tried quite a few. Slightly off topic, were all the players pretty much the same?

Never used google for music, have logitech media server on nas and use pcp as the interface. Would be stuffed if it didnt have the touch or settings vis web browser as im lost when it comes to using ssh.

Will be getting a flirc soon to allow use of a remote, dont suppose you have experience of these with the pi?
 

marmitesandwich

Novice Member
were all the players pretty much the same?
No, the functionality and interface varied, but IIRC, they all provided a upnp renderer feature, which is what I wanted. I didn't want to interact with the device, I just wanted it to sit there obeying upnp renderer rules. But they all failed in some way.

Ssh is not needed to use this device, only to set it up. Then it is controlled by a upnp control like bubbleupnp, or kazoo.

Don't know much about flirc, except it is proprietary and costs money
Marmite
 

The latest video from AVForums

Podcast: Panasonic JZ2000 Final Thoughts - TV Calibration: Should you? And More...
Subscribe to our YouTube channel
Support AVForums with Patreon

Top Bottom