Raspberry Pi Music Box

Submitted by nigel on Wednesday 6th February 2019
Introduction
Complete solution

This bog provides a tutorial for building a Raspberry Pi music box which can be controlled using a hand held device through a web interface. Ideal for a bedroom where there is no desire to have a monitor / keyboard /mouse combination. The cornerstone of the build is the Rune Audio distro which supports FLAC, Vorbis and mp3 amongst other formats. I will be using a Raspberry Pi 3 Model B+ along with an IQAudIO Pi-DAC+ daughter board. 

There is fierce debate between the proponents of Rune Audio, MoOde Audio, and Volumio. I elected for Rune purely because there is a native Android app available, and my smartphone is a Samsung.  

Bill of Materials
Raspberry Pi
DAC
SD Card
Power
Case
Speakers
Raspberry Pi 3BPLUS-R 1.4 GHz 1 GB RAM 64-Bit £34.56
DAC IQAudIO PI-DAC+ £35.00
SD Card LXSINO 32GB Micro SD Class 10 £7.99
Power Official 5V 2.5A Power Adapter for the Raspberry Pi 3 £7.99
Case IQAudIO PI-CASE+ £19.40
Speakers Creative Gigaworks T40 Series II £79.99
  TOTAL £184.93

Of course I can't guarantee you'll get the same deals I got, but the pricing should at least be indicative. I already had the speakers I bought for a different project a few years ago that never saw the light of day, so that reduced my outlay to around £105 for this project. 

Fit and test the DAC.
Piggy Back

Fitting the DAC to the Raspberry Pi is quite easy although there are instructions on the IQaudIO site. The DAC comes with some spacers and screws which align with the Pi's own. Since this is a quick sound test and I will be building the components into a proper case at some point, I only tightened the screws finger tight. 

Once this has been completed, it's time to test it works fine. IQaudIO provide downloadable bootable images that can be written to an SD disk and will automatically play mp3 files. The best file on their downloads page is IQ_0_quicktestDigi*.zip.

Unfortunately the zip file was corrupted when I tried this. I reported this to their webmaster. 

Build the Pi-CASE+
Pi-CASE+

I couldn't find any build instructions for the case, but it is fairly straightforward. The first point to note is there are some standoffs which should be screwed into the four Raspberry Pi screw holes on the corners of the PCB. The case comprises six perspex sides, and they are slotted to ensure there is only one way it can all fit together - so the second point is it is crucial to dry run this first before it is screwed together to ensure there is no attempt to situate any of the panels the wrong way around.

The panels fit together very snuggly without any slack and comes with some small plastic feet to prevent it rubbing and sliding on the chosen surface. 

Flash the Rune Audio distro
Etcher

Time to download our chosen repo. This is a small inconvenience because Rune Audio do not have an official Raspberry Pi 3B+ image. However there is a workaround - a community member has created a rar file download that can be fetched from the Rune Audio forums.  

The file is in rar format so on a Mac you will need to install unrar
$ brew install unrar
==> Pouring unrar-5.7.1.mojave.bottle.tar.gz
/usr/local/Cellar/unrar/5.7.1: 7 files, 520.7KB
Then we can run the unrar command
$ unrar e RuneAudio_0.4_20180629_SC_Pi3B_Plus_v3_tml3nr.rar 
 
UNRAR 5.70 beta 1 freeware      Copyright (c) 1993-2019 Alexander Roshal
 
 
Extracting from RuneAudio_0.4_20180629_SC_Pi3B_Plus_v3_tml3nr.rar
 
Extracting  RuneAudio_0.4_20180629_SC_Pi3B+_v3_tml3nr.img             OK 
All OK

To write the image to the SD card I use Etcher. This is a simple utility app although the command line can be used too with dd - not recommended for those with low experience. Once Etcher has completed it will provide a useful desktop notification. At that point the SD card is ready to be inserted into the Raspberry Pi. 

Booting Rune Audio
Boot

The Pi can be booted once a network cable has been attached. If all goes well, it should be possible to point a web browser at http://runeaudio.local (see screenshot above). We now have the genesis of a music box but it still needs configuring. 

MPD Configuration
MPD

There are a number of config screens to work through to get the system functioning correctly. Some of the changes will be specific to my circumstances so your mileage may vary. The MPD (Music Player Daemon) configuration needed one change - the need to select the IQaudIO audio output interface. 

Settings configuration
Settings

This one in particular may not suit all my readers, but I want to use the Europe/London timezone. 

Network settings
Network
eth0

It makes sense to use a static IP address on your home network - so we can use a proxy in order for all devices to find their way to Rune. More of this later, but for now navigate to Network and you should see a sight similar to the first screenshot above. Click on eth0 and you will see the second screenshot. I have populated this form to use 192.168.0.204. My router has already been configured to assign DHCP addresses between 192.168.0.2->199. Anything 200 and above is reserved for my static IP address home servers. 

Sources configuration
Sources
Mount
Updating

The final configuration activity is to make Rune Audio aware of where the audio files are stored, and in my case they are on an NFS drive on my NAS server. Go to the Sources page as per the first screenshot above and click on Add New Mount. The form to complete for NFS mounts just wouldn't play ball at all, so in desperation I tried SMB/CIFS(OS X Share) and that worked - see the second screenshot. I called my source flac since this share contains all my high fidelity rips. I then repeated the process by creating a mount for mp3 for my low definition audio. The third screenshot shows the two mounts listed, and I have instigated a rebuild of the library, and this is shown by the updating spinner bottom left. 

Playback
Playback

As soon as the library has been underway for a short period of time and has added a few artists / albums, playback can be tested. I picked an album at random for my end to end test, and it played seamlessly. 

Native Android App - Runeaudio Remote Control
Native App

The native app scans the local network and automatically shows all the connected RuneAudio players, allowing you to control them from the same place. It also displays the RuneUI in a true full screen, with no browsers bars and weird scroll behaviours.The app uses the avahi protocol to scan the local network. It detects the connected RuneAudio players which expose the avahi service and lists them, showing also their IP and MAC addresses.

The resulting UI is actually the same as a web browser but I found it immensely frustrating. My habit is to tap the built-in Samsung back key to navigate and that immediately drops me out of the app. Restarting the app requires the initial network discovery to be run again, and mine steadfastly refused to connect initially, but then suddenly appeared to figure out my network and was rock steady afterwards. 

Resolving runeaudio.local - Desktop

Rune Audio uses the Avahi protocol which theoretically means when added to a local network, pointing a browser to http://runeaudio.local should 'just work'. Whilst setting up Rune Audio I noticed this capability was very hit and miss. There are ways of getting a rock solid configuration - for a desktop the simple solution would be to add runeadio.local to the /etc/hosts file. 

/etc/hosts
192.168.0.204 runeaudio.local
Obviously the IP address should be swapped with whichever you have used.
Resolving runeaudio.local - Handheld Device
Since /etc/hosts can't be edited on a handheld device such as a tablet or a smartphone, we need another solution. The workaround for this is to use a proxy server as per my blog where I utilised another Raspberry Pi as a proxy. Firstly log into the proxy server and edit its /etc/hosts like the desktop so you will have an entry
192.168.0.204 runeaudio.local
The Squid proxy will then need a reboot.
$ sudo service squid3 restart
You will then have to ensure your handheld device is using the proxy for internet access. Screenshots for achieving this on an iPad and an Android phone are in my other blog just mentioned and are not duplicated here for brevity. Just click though if you need guidance.
blog terms
Hardware Raspberry Pi