Welcome

Personal blog and comfy corner of Lyra Rhodes: musician, cake aficionado, whinger...maybe just a place where I can stuff things (words!), rather than them falling down the back of the sofa

Pi

Raspberry PI 2 installation of "Volumio" software - turn it into a mini HiFi
August 2015

Equipment assumed
Raspberry Pi 2
HiFiBerry Digi+ (HAT board - connects directly to GPIO  on top of Pi)
Power - Pi charger or (even better) linear power supply
Network connection - ethernet ideally, and a Cat6 cable
A NAS on your local network hosting your music files (Flac, surely!)
A separate DAC - either dedicated or a digital input on AV amp
A optical or digital Coax cable (to connect to the Pi output)
This guide will use the “Volumio” software, a Raspbian variant.
Version 2 is currently being developed (using node), and promises good things, so the current version has become a little stale over the last few months (as at time of writing - August 2015).
I’d like to use MoOde (
http://moodeaudio.org) but haven’t been particularly successful with it sound or config wise, albeit it promises a smaller cpu/mem footprint, and the promise of proper use of embedded album art (currently with volumio/MPD the client redownloads artwork itself, to avoid stressing the Pi-server connection). So this is something I’ll come back to when version 2.2 is released soon I think. The problem might’ve been me trying too hard to use NFS….
STEP BY STEP INSTRUCTIONS
      you will need to install on a Windows PC, or their equivalent on a Mac, Linux etc (but I will mention MS-Windows hereonin) :-
SD Formatter (official tool)
https://www.sdcard.org/downloads/formatter_4/
Win32 Disk Imager
http://sourceforge.net/projects/win32diskimager/
PuTTY
http://www.chiark.greenend.org.uk/~sgtatham/putty/
FileZilla (FTP client)
https://filezilla-project.org/
      Format a MicroSD with SDFormatter
note: if it is preused in any way, make sure to select Format Type: Full (Overwrite) and Format Size Adjustment: ON
(as the Raspberry PI has a habit of corrupting cards and leaving them partitioned....)

      write the initial volumio 1.55 O/S code with https://volumio.org/ to MicroSD with Win32DiskImager tool

      ensure PI unplugged, unplug/replug ethernet, insert SD and power up, and it will load up the Volumio image/OS (it's basically Raspian + MPD + Samba + tweaks), and now you're going to get into some major configuring of it

      From another computer browser on your local network go to http://volumio.local and in the Volumio menu (top right) change (Network section) to a static IP.... you've got a spare one in mind yes?) and then wait maybe up to FIVE minutes for your browser tab to reload (it will! be patient)
(Some folks like to do this in their Router config instead YMMV, but given that I could conceively change the Pi O/S frequently, I prefer to do it here)

      in -> System amend I2S DAC to "Hifiberry Digi", click Apply and Reboot as requested (using the Volumio menu to do this, and then just wait, the browser will eventually refresh)
      PuTTY into <IP address> and update to latest MPD using instructions
username: root
password: volumio
(accept any "do you wish to continue" messages)
https://volumio.org/forum/mpd-update-available-t3200.html
      Reboot (using Volumio menu option), and wait for browser to reload

      In the Volumio "Library" menu add the SMB mount to NAS as follows:
- ADD NEW MOUNT
use the same share name you've defined in Windows (use correct case!)
IP address of your NAS, username/password etc etc, you will then get a Volumio message in the top corner and if you got the Share wrong a "red cross" next to it
you don't really need to change the Advanced Options, certainly not for my Synology NAS (I've tried NFS here in the past, but doesn't seem worth the effort, Samba is plenty fast enough)
and then it will run the MPD scan to index your music files, so best not to do much at all whilst it is doing this and DO NOT try to play any music or change any settings!!!

      PuTTY to <IP address> as root/volumio and
cd /var/log/mpd
grep added mpd.log | wc -l
(you can rerun and watch this until it gets to your number of music files if you like!)
SO BE PATIENT AND WAIT, this will take a couple of HOURS
- 3 1/2 hours on my system indexing my Synology NAS with 10500 FLAC files

      Give it a few minutes to compose itself and catchup then....
You can then check the library has been built by going to
http://volumio.local and clicking "Browse" in the bottom left of the Volumio web page, your Nas/share should appear there. Until the full MPD scan from above has completed, you'll basically see nothing here in the Volumio library

      DO A BACKUP NOW! as follows:
shutdown the PI, remove the power, remove the MicroSD and in your windows machine use Win32DiskImager to take an image of what you've done so far (don't want to lose it!!) to your PC (use the "read" option) - this isn't hugely quick, but worth it (takes about 10mins or so)
then re-insert into Pi and turn back on
(Note that eventually you'll want to clone a MicroSD image to another spare card, for quick recovery, but let's leave that right to the very very end)

      Browser into http://volumio.local or Volumio <IP address> -> System "Services management" and disable Airplay, DLNA Library Server then give it a few mins and then Reboot (yet again) as requested

      Test your playback and check summink comes out of your speakers, you can use the Browse/Playback tab for this…

      Setup what apps you require, as it all works much better when controlled from your smartphone or Windows PC etc
The best ones I'd say are:
Android: MPDroid
https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid&hl=en_GB
RasPi Check (useful to check on and reboot)
https://play.google.com/store/apps/details?id=de.eidottermihi.raspicheck&hl=en_GB
Windows: GMPC
http://gmpclient.org/
      OPTIONAL step
Do you want to enable REPLAYGAIN? have you tagged all your files with this?
Do you want all your Playlists to play at the same volume?
If so, it has to be done manually at the command prompt, but will (might) break the Web playback interface (but you don't need that, right? you've got the apps above)
As you can see from the below, I'm suggesting a low Preamp value to avoid any possible chance of distortion
in PuTTY :-
echo 'replaygain "track"' >> /etc/mpd.conf
#echo 'replaygain_preamp "-8"' >> /etc/mpd.conf
#echo 'replaygain_limit "yes"' >> /etc/mpd.conf

Then restart the MPD daemon with
/etc/init.d/mpd restart

      OPTIONAL step
Perhaps a better way of implementing volume levelling/normalisation in a playlist is using the normalisation feature built directly into MPD. Personally, I’ve used ReplayGain on other devices quite successfully, but none of these offer “bitperfect” playback, ie without modifying the file (even digitally) before playback
So, yes, I think the ReplayGain implementation here degrades the sound slightly, so thus I prefer the MPD implementation.
You can enable that in the Volumio menu -> Playback -> Volume normalization

      OPTIONAL step
You can tweak the Linux kernel to improve sound quality (allegedly), and I think it's worth a go, In Volumio -> System, change Kernel tweaks to "Orion" (my choice)
a lot of the info on these seems to throw back to when Volumio was spawned from the "RaspyFi" team's code, so Google away if you wish…

      On the important subject of PLAYLISTS....
If you've got any M3U playlists already pointing to the tracks on your NAS, then it's not too tricky to get them onto the Pi, so that MPD can play them, and you can see them on your smartphone app (and GMPC)
Basically you need to edit them so example lines in a simple M3U text file looks like (don't use M3U8)

NAS/music/John Mayer/Battle Studies/03 Half of My Heart.flac
NAS/music/John Mayer/Continuum/07 Stop This Train.flac

So you can see that of course it's Linux and you've had to replace \ with /
and in my case I called the SMB Share in Volumio "music", which is the same as the name of the windows share...make sense?

Then you can use eg. windows FileZilla (using root/volumio) to copy these M3U files into
/var/lib/mpd/playlists
connect using <IP address>
username: root
password: volumio
Port: 22

      Now DO A BACKUP!
As per instructions previously.
You don't want to lose especially all of that Indexing (that took hours), as it and the O/S and your playlists etc etc etc are now all saved to the MicroSD card in the Pi......
You might also want to write your backup image to a spare MicroSD as mentioned previously (formatted/reformatted as described), that way you've got a very quick restore option when (not "if", it's a "when") your Pi SD card gets corrupted

      NOTE that any new Playlists you create using your MPD clients (GMPC, Android etc) will end up in /var/lib/mpd/playlists, so it's a good idea to back them up regularly somewhere using FileZilla (FTP) or create another backup image

      One last note on Playlists and controlling the music, a great feature of Volumio - but rather MPD - is the ability for several folks to operate the music on the same network, just install an app (or browser to volumio.local) on each phone and you're BOTH good to go, and create playlists, start/stop, add to the Play Queue etc etc etc

      And LASTLY, you may have noticed by now that album artwork in your apps doesn't work quite properly even though you've tagged all your music painstakingly.  This is because the client doesn't access the tags at all! This is in order to avoid loading the connection / server. If you have placed (easy to do with "mp3tag") a folder.jpg in each album folder, then you can fix this behaviour with the following on your PI using PuTTY to create a symbolic link to make the Pi webserver find those covers & provide to your client (works with most Android eg MPDroid):

ln -s /var/lib/mpd/music /var/www/music

      And then the following steps in eg MPDroid or similar app client :
      -> Cover art settings -> Path to music = http://[your PI IP]/music (example: http://192.168.178.11/music)
Local Cover Art -> Cover Filename: [Your picture name] (example: folder.jpg)
Then just restart the app completely

And you're done!