Convert your Raspberry Pi into an audiophile music player using volumio
There are many cool uses for the Raspberry Pi. I was on the verge of buying an iPod Nano (to replace my broken ipod) when a friend asked my opinion about the Raspberry Pi – something I had not paid attention to until then. After the usual frenzy of reading reams of online “literature” about the device, I decided to buy one along with my friend and dropped my plan to buy the iPod. My intent was to use the Pi as a music player within my home. We ended up buying the recommended kit- the model B Pi, an Edimax USB Wi-Fi card, a powered USB hub and a case for the Pi. After the customary initial enthusiasm, the device was confined to my cupboard because I found that the plain vanilla Raspbian OS for the Pi was too much of a hassle to use as a media player. I could not install XBMC because it expects you to have a HDMI monitor connected on first boot – something that I do not have.
Things have changed a lot since I discovered volumio. This was what I bought the Pi for! The fantastic folks who built this have documented only one purpose for this device – to play all your music with the highest possible quality. I like the sound of that!
This article describes the process to configure your Raspberry Pi to run volumio. I am assuming that you have a basic knowledge of the capabilities of the device if you are still reading this line. The article does not talk about the use of DACs with the Raspberry Pi since I do not own one. I am quite happy with the quality of the analog output from the Raspberry Pi.
- Step 1. Download Step:
Download and extract Win32DiskImager. This is available from multiple source including sourceforge.net. The tool is required for loading disk images to USB devices.
- Step 2. Download Step:
Download the volumio distro from volumio.org/download. The page lists downloads RaspberryPi, Cubox, Udoo, Beaglebone Black and Compulab Utilite. Make sure you pick the download for the Raspberry Pi. This article is based on the distro released on 24-12-2013. The download is a 376MB zip file. Once downloaded, extract the disk image file from the zip archive. The uncompressed disk image size is 1.75GB.
- Load Image:
Connect an empty (preferably formatted) SD card and launch Win32DiskImager. The tool should recognize the SD card upon launch. If you have more than one card connected ensure that the correct one is selected in the “Device” selection box. Point the “Image File” to the disk image file downloaded in step 2. Click on the ‘Write” button to start the process of loading the VolumIO image onto the SD card. The time taken to copy will depend on the speed of the SD card. It took 4 minutes to load the image onto my 4GB Sandisk Class 4 SD Card connected via a USB 2.0 capable card reader. Congratulations! You have successfully installed VolumIo on your SD Card.
Volumio = Raspbian + Media Player Daemon (MPD) + samba web server + support for a large list of USB digital audio codecs (DACs) + folks obsessed with bit perfect audio reproduction.
The good folks who built Volumio have trimmed out a lot of unnecessary stuff in the OS and tweaked a lot of the good stuff. The image does not have a GUI interface for the OS. Once installed, you will be able to use the Pi using the WebUI configured and ready to run on first boot. I control my Pi mostly from an Android phone using the built in browser. Though there are a couple of apps available for controlling the device, the default WebUI provides a superior experience.
- Connecting to the Pi:
The following steps assume you are not connecting a monitor, keyboard and mouse to your Pi(headless mode). Plug in the SD card to the Pi and power up the device.
If you are using a wired Ethernet connection, you can connect to the device using SSH using the following details for the SSH connection:
Host – volumio
Username – volumio
password – volumio
You can also connect to the WebUI using the URL : http://volumio
If for some reason you are unable to connect using the host name you can try using its IP address instead. On Microsoft Windows the command net view /all will list all computers connected on the LAN. The command nslookup host-name will list the ip address of the host name. If you do not see a computer named \\VOLUMIO, something is wrong with the setup. Check the management interface of your router to see if it has detected the device.
Configuring the Pi to use a wireless network adapter is a little more tricky. You need to connect it at least once over the wired connection to configure the wireless network properties. Launch the WebUI of the Pi using its host-nmae or IP address as the URL from your browser. Click on the Menu link on the right side and navigate to Network and enter the properties of your wireless network. If you are the prefer the command line, edit /etc/network/interafces to have the following entries (for a wireless network using WPA security. If you are using WEP, switch to WPA. Its better!):
iface lo inet loopback
iface eth0 inet dhcp
iface wlan0 inet dhcp
Replace your-wireless-network-ssid with the SSID of your network and wireless-network-password with the password. You can edit the file using the nano editor. (sudo nano /etc/network/interfaces).
Unplug the Ethernet cable from the Pi and restart the device. You should now be able to connect to it via your wireless network.
- Configuring Samba:
You have multiple options to host your music library. If your collection is relatively small ( a few GBs) you can transfer them directly to the SD card on which the volumio image is running. You can also transfer your music to an USB drive and attach it to the Pi. This option will lead to additional power being drawn from the device and hence you may need a powered USB hub to connect the USB devices instead of using the on-board USB ports. You can also attach a NAS disk to your network and stream your music from that disk. For all of these options, you need to configure the samba file server. Edit the samba.conf file located at /etc/samba to enable or disable the kind of shares you would like to use. If you plan to use the SD card to hold your music collection, add the following entry to the smb.conf file:
comment = Musis stored on SD card
path = /var/lib/mpd/music/sdcard
read only = no
public = yes
follow symlinks = yes
wide links = yes
All the paths listed except WEBRADIO in the smb.conf file entries are actually symbolic links to other locations. An ls-l command lists the target of these links:
ls -l /var/lib/mpd/music
lrwxrwxrwx 1 root root 9 Jul 13 2013 NAS -> /mnt/NAS/
lrwxrwxrwx 1 root root 8 Apr 8 20:58 RAMPLAY -> /run/shm
lrwxrwxrwx 1 root root 20 Jun 29 07:52 sdcard -> /home/volumio/sdcard
lrwxrwxrwx 1 root root 9 Apr 22 00:46 UPNP -> /mnt/UPNP
lrwxrwxrwx 1 pi pi 8 Jul 30 2013 USB -> /mnt/USB
drwxrwxrwx 2 pi pi 4096 Jun 27 09:47 WEBRADIO
You can see that I have created a folder called sdcard in my home folder and created a softlink to it within /var/lib/mpd/music using the ln command:
sudo mkdir /home/volumio/sdcard
ln -s /home/volumio/sdcard /var/lib/mpd/music/sdcard
- Transfer music:
You can now access your shares from any computer on the network using the IP address of the Pi. For example, if your IP address is 192.168.0.7, navigate to \\192.168.0.7 in Microsoft Windows and you see all the shares listed. You can now transfer the music files from your computer onto the device.
You will need to update the MPD database every time you add new files to your collection. You can do this from the WebUI interface. Click on the Menu link at the right side and navigate to Library -> Update MPD database.
- Adding an internet radio station:
The WebUI does not have an option to add a new internet radio station. Download the .pls file of the radio station and copy it to /var/lib/mpd/music/WEBRADIO. You need to do this via an SSH collection. Update the MPD database and you should now see the new station under the WebRadio section of your library.
Thats it! You now have a working streaming audio player that you can control from any device connected to the same network. Once configured, this is the beautiful interface that you interact with:
- System Administration
You can accomplish many of the system management tasks (including restarting most of the services) using the WebUI. For more complex tasks, you always have access to the system via SSH. The Raspbian OS provides a nifty tool called raspi-config for making certain types of configuration changes. Launch it using sudo raspi-config and you see this nostalgic 80’s style GUI:
It is a good idea to run upgrade your system after initial setup using the following commands:
sudo apt-get update
sudo apt-get -y upgrade
This will update components of the Rasbian OS even if you have picked up the latest release of volumio. The upgrade process can take a while to complete (it took 30 minutes on my 4 MBps broadband connection). If there is a question regarding the missing configuration file ‘/etc/php5/fpm/pool.d/www.conf’, choose the default option of retaining the current settings.
- Expanding the default partition on your SD card to use up the full capacity of the SD card:
By default, the volumio image creates a 1.55GB EXT3 partition on your SD card for the OS. The rest of the space on your SD card is unallocated and is unusable. If you plan to use the SD card to store your music library, you need to jump through hoops to get the rest of the space usable. Using the “Expand Filesystem” option in raspi-config will not work for this image. You will get an error stating “your partition layout is not currently supported by this tool”.
I have found that using the GParted utility is the easiest way to do this. If you are using Microsoft Windows, download the GParted Live CD and burn the image to a CD. There is also an option to create a bootable USB stick. You can find the downloads and instructions at http://gparted.org. I tried the recommended method of using TuxBoot. It did not work for me. TuxBoot failed to load the image. I manually downloaded the 180MB image and created a bootable CD using the iso file using CDBurnerXP. If you are planning on using a USB stick, you can follow the instructions posted at the gparted web site for a manual install.
Remove the SD Card from the Pi and connect it to your computer and reboot your computer to boot into either the Gparted bootable CD or the bootable USB stick. Once loaded, it will launch the partition utility automatically. By default, the utility will list the hard drive on your system. Remember to pick the SD card from the drop down on the right hand corner as shown in the screen grab below:
In the example above, I have used a 4GB SD card to load the volumio image. You can see that only 1.55GB has been allocated. Select the allocated 1.55 GB partition and use the resize button to resize the partition to fill up the available disk space. You can ignore the 75MB FAT32 partition created on the SD card. This is created by SD card manufacturers.
Click on the apply button to commit the changes. The resize operation can take a few seconds to a few minutes to complete depending on the size and speed of your card:
Shutdown the computer once the operation completes and re-insert your card into the Pi and fire it up. You can now transfer your music collection to the SD card from your PC. On Microsoft Windows click on Start and type \\volumio in the search box. An explorer window should open showing all your samba shares. You should see SDCARD listed among the shares. Any files you transfer into this will go into the target of the symbolic link you created for /var/lib/mpd/music/sdcard.
- Backup your image
Once you have configured your Pi to, it is advisable to create a backup of your image. This will save you a lot of time if your image gets corrupt (happens with the Pi). Remove the SD card from the device and connect it to your PC. Use the Win32DiskImager tool to create a backup. Use the read option to create an image from the SD card.