Extending the Raspberry Pi to a miniature music center

Lead Image © ladyann, 123RF.com

Compact Jukebox

MPD, the Music Player Daemon, converts the Raspberry Pi into a small jukebox. However, configuration is not always easy. We show you what to look out for.

Sometimes a full-fledged media center with a full HD display and Dolby surround sound is too much of a good thing. In contrast, the Raspberry Pi offers a modern replacement for the transistor radio: It retrieves radio stations from the Internet, streams digital music from your LAN or an external hard disk, can be controlled remotely via your smartphone, and costs far less than a WiFi radio. With a little manual work, the Music Player Daemon, MPD [1], converts your Rasp Pi into a network-enabled music player that compares well with any wireless portable radio. Thanks to an app on your smartphone, it can be also far more convenient to use than the fiddly controls that simple standalone devices provide.

Unlike a WiFi radio, you first need to teach your Rasp Pi how to play music. Here, I assume you have a Rasp Pi with an image of the Debian 7 "Wheezy" Raspbian [2] [3] in place. To set up the required components, you will be using command-line tools. SSH access, required for a configuration via another computer, should also already be in place on the Rasp Pi (see the HowTo Corner on the Raspberry Pi Geek website [4]).

The Hardware

The Rasp Pi has analog sound output. Although its sound quality is not exactly exciting, a small speaker with limited frequency range will swallow up most of the annoying white noise. The results can definitely keep up with a simple portable radio.

The basic version of the low-fi system presented in this article comprises the Rasp Pi with a network connection and a speaker by Raikko [5], which can generate a volume of more than 80dB in spite of its low weight of only 100 grams (Figure 1). Your music collection can be stored on an external hard drive, on a shared drive on your LAN, or in the cloud. You control the music output via the local network with a client on your smartphone or PC. Clients are available for Linux, Android, Windows, and Macs.

Figure 1: The Raspberry Pi using a speaker by Raikko as a mini jukebox.

The poor sound quality of the Rasp Pi's analog sound output is hardly noticeable if you go for small speakers. With larger speakers, it might be advisable to switch to a good USB sound card. The use of PulseAudio as a sound system, instead of ALSA, does give you some optimization options, which I will explain how to set up in more detail later.

As for the hardware, the system now is almost complete. However, it still lacks a way to let you integrate your own music collection, which is typically stored on a hard drive somewhere; as such, you can connect it to the Rasp Pi via USB. The easiest way for the Rasp Pi to mount a network drive is to use a Samba share (see instructions at the HowTo Corner [4]). You now have all the components in place for a Rasp Pi Radio.

The Software

The core software element for a Rasp Pi radio is the Music Player Daemon, MPD, which you need to install via a terminal along with the mpc command-line client. While you are at the command line, you will also want to set up the PulseAudio sound system with:

$ sudo apt-get install mpd mpc pulseaudio pulseaudio-module-zeroconf
$ sudo apt-get install mpg321 lame

Installing mpg321 and lame ensures that the MP3 codecs are set up, and you can test the sound output at the command line. With this basic equipment, the Rasp Pi has everything you need for playing MP3 files and corresponding streams.

Clients for controlling MPD are available for all major operating systems. The MPD community wiki [6] has a list of clients for Linux, Windows, Mac OS, and smartphones. I'll go into more detail later about the Linux and Windows smartphone clients later. As an alternative to a local application, you can also set up a web client; the wiki lists some examples. Logically, the use of the web browser running client side means installing a web server on the MPD system, which is why I will be steering clear of that option.

Buy this article as PDF

Express-Checkout as PDF

Pages: 6

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content