Raspberry Pi Home Network Music System

What is this?

In this project I’m going to show you how to turn a inexpensive Raspberry Pi computer into a home for your MP3 music collection that you can browse and control from your phone or computer. This same setup can weave together online music services like Spotify and Google Music, as well as internet radio, and also act as an Airplay or DLNA receiver for streaming music from other devices.

This project was created with the help of WD Labs, a division of Western Digital that sells Raspberry Pi kits, products, and accessories. They provided me with the PiDrive Node Zero product used here, and compensated me for putting this whole thing together. They’re a cool company and I’m happy to have them as a sponsor.

But for those of you wondering if it’s possible to do this project with just a USB hard drive and any flavor of Raspberry Pi — yes you can. That said, I honestly believe the PiDrive Node Zero’s combo of Pi and drive is an unbeatable value.

Why should I make this?

Did you buy or rip or otherwise come to posses a ton of MP3s in the pre-Spotify heyday of digital music? If so, you probably have it all backed up on hard drives or sitting on an old computer somewhere you never use. Sure, most of it is probably stuff you could just as easily stream these days, but a lot of us have files that don’t have a streaming equivalent.

And yes, there are cloud services like iTune Match, Google Music and Amazon Music, that will store your collection for a price and stream it back down to you — but you shouldn’t have to pay rent on music you already bought. And who knows when those companies will pull the plug. How about you roll your own home music server instead?

Step 2.

Boot up the Node Zero with the Raspbian card installed, along with a Wi-Fi adapter, keyboard, and a USB mouse connected. You’ll need to use a USB hub to get everything connected. I found this 4-port hub worked great (http://amzn.to/2nurLBU).

Once you’re in the desktop you’ll need to configure Wi-Fi up here in the top right corner and connect to your network.

Then in the top left main dropdown menu (the one with the Raspberry) go to Preferences and then select Add/Remove software. You’re going to install a new program called GParted. The quickest way to do that is to search for it, check the box next to its name, and hit apply. It’ll ask for your password, which by default is the word “raspberry” in all lowercase letters.

Now if you’re a hotshot Linux user you’re probably shouting at your screen right now wondering why I didn’t have you do this over command line. I figured this is the least intimidating way for most people to install software. In fact, I deliberately went out of my way to make this entire guide Terminal-free. I’m a monster, I know. If you really want to sudo apt-get install gparted, you don’t need my permission.

Once the software is installed, hit okay, and then go to the Preferences submenu again to find and open Gparted. When you open it up, it will ask for your password again.

Gparted is a tool for formatting and partitioning any storage you have connected to the Pi. With the Node Zero, you have a 300 gig hard drive connected to your Pi, but you can’t do anything with it until it’s formatted.

To do that, click the drop down in the top right corner of the window and select the drive with 292 gigs of space (I know there’s a good reason why this 314gb drive only has 292gb of usable space, but it still makes me a little crazy).

Next, you’ll create a new partition table for this drive by going to the Device menu and selecting Create Partition Table.

Then you’ll right-click on the partition and format it as Fat32. Partition type is msdos (selected by default). I also recommend adding a label here for “music” which will make it obvious where to transfer your music in the next step.

When it’s all done, you’ll need to reboot the Pi in order to see and use the drive you just formatted.

After rebooting, open up the file browser from the top menu bar (the Folder icon), then navigate to /media/pi/music (assuming you made that “music” label when you formatted the drive. You’ll know if you’re in the right place when you see the folder size calculated in the bottom right corner has 292 gigs of space. This is where you want to move your music to.

Step 3.

Connect up whatever USB hard drive has your music collection on it to the other USB port on the PiDrive Node Zero.

The Pi will automatically prompt you to open a file view for the drive that you can browse through for your music collection.

Now, a quick word on music file formats before you transfer over your music. A few minutes spent here could save you some headaches later. First, take a look at how much music you have to transfer and make sure it will fit. If not, consider just moving over a portion of your collection. For example, if this project is going in your bedroom, maybe take the Barry White but leave the Megadeth behind, y’know? You could always make another one of these for different room that ONLY plays Megadeth.

Also, Raspbian has some powerful system search tools that can help you root out and exclude incompatible formats like .m4p (iTunes protected) .AIF .WAV. The Pi MusicBox software works with MP3, FLAC, and maybe AAC (not sure, I don’t make the rules). Any format outside of those is only going to take up more space and time. So, I recommend doing a little cleanup before moving it over.

With that said, when you feel like you’re ready, drag your music collection over to the the empty folder on the PiDrive, and wait for it to copy over. If it’s a big collection, it may take hours. Go take a nap.

Once the music is transferred, you can shutdown the Pi, pull out the Raspbian microSD card, and disconnect the external drive and everything else except the Wi-Fi adapter. It’s time to switch gears and talk about the MusicBox software.

Step 4.

This project takes advantage of the Pi MusicBox v0.7 which you can download here.

The software will turn the Pi into a networked music server and AirPlay/DLNA receiver, that you can manage right from your phone or computer. You can learn more at PiMusicBox.com.

With Pi Music Box v0.7 downloaded, you’re going to repeat the process of writing it to a blank SD card. I wouldn’t write over Raspbian card you made just in case you want to move more music over later or go in and clean out other files. If you want, you could write over the NOOBS card WD Labs provides with the Node Zero or find any card with at least 4GB of storage.

After you’ve imaged the card, open it up on your computer, open the config folder, and then open the settings.ini file as a text document.

Under the section labeled Network Settings, you’re going to plug in your WiFi network ID and password. This will allow the system to jump on your network without you ever needing to touch the code from here on out. Save it, close it, and if it warns you that you can’t undo this change, that’s fine.

Step 5.

We’re going to pop the Pi Music Box card in the PiDrive Node Zero, along with a WiFi dongle and a USB audio adapter.

It’s possible that future versions of the Node Zero will ship with the Pi Zero W board, which would eliminate the need for the Wi-Fi adapter. It’s also possible to just swap out the board on your own if you really want, though I’m not certain the code supports the Zero W yet.

Now, you could run this without a monitor if you’re feeling lucky, but for the initial setup I recommend keeping a monitor connected so you can see what’s going on and troubleshoot any problems.

Common things that could go wrong

-There’s a typo in your network ID and password preventing the MusicBox from connecting. You can fix this by putting the MusicBox microSD card back in your computer and editing that settings.ini file we talked about in step 4.

-It’s rejecting a lot of your music files and showing error messages for each one. It’s to be expected and it should still work fine for the files that are compatible. I would make a note of the formats it’s having trouble with. Then you can boot up later with the Raspbian card installed and search for and delete anything with that extension.

-It’s taking a long, long time. Be patient. After it creates a library of your music on this initial boot, you can flip a switch in the software settings I’ll show you later so that it stops scanning on boot. Just remember to flip this switch back if you ever want to add more music.

Once the boot sequence is all finished, it will prompt you to visit either musicbox.local, or an optional IP address that is specific to that device (ie. 192.166.x.xxx). Write that address down and/or bookmark it in your browser. I found it handy to have as an alternative to the musicbox.local address.

Now here’s the fun part. From any web browser or a tablet or a smartphone, I can go to musicbox.local and the front-end interface for Pi MusicBox should pop right up. This is the musicbox software that the Pi is hosting on your network. If it doesn’t come right up, try the unique IP address instead and see if that works.

From here you can navigate to your local files, find something to play, and it will play off the Pi. You can test this by plugging some headphones into the USB audio adapter.

There’s also a whole lot more you can do here to setup other services, and that’s all covered at pimusicbox.com. I do suggest going into Settings, selecting Music Files, and switching off the Scan Music Files setting to save significant time on your next boot.

Scroll to the end of the Settings menu to save your settings, which will prompt a reboot.

Step 6.

This one’s really up to you to figure out how you want to the Pi MusicBox to fit in your home and what kind of speaker (or stereo pair of speakers) you want to match it up with.

For what it’s worth, here’s what I did to quickly get it up and running with a salvaged Hi-Fi speaker I bought at a yard sale. Here’s the speaker I’m using, though there’s no reason you couldn’t use this with a nice, new, pair of inexpensive bookshelf speakers like these (http://amzn.to/2mSep2r).

There’s nothing more you need to do with the Pi, however, I dropped mine in an inexpensive case from WD labs to dress it up a little. If you live with a partner or roommate that you just know dislikes the site of technology, it’s good gadget camouflage.

I used a $30 amplifier from Amazon and some speaker wire to connect from the amp to the speakers. You’ll need some wire strippers or some careful scissor skills to strip away some of the wire insulation and cut the wire to the length you need.

Now, because I’m only using one speaker, notice how I wired the speaker outputs so that the negative of one channel and the positive of another run to the respective negative and positive inputs of the speaker.

This is called a bridged connection, and it’s a way sum stereo to mono as well as combine the total wattage of both amplifier channels. I’m sure audio purists will take issue with this and tell me I’m mismatching Ohms or something, but it sounds good to my ears.

Finally I have a minijack to RCA cable to get me from the Pi’s USB audio adapter to the stereo input on the amp.

Once you’re wired up, switch everything on and see if it all works. You shouldn’t need a monitor connected at this point because any setting you may want to change is available through the musicbox.local web interface.

Where do you go from here?

There’s a lot more to Pi MusicBox’s features than I’ve covered here, including integration with Spotify, Google Music, SoundCloud, AudioAddict, Podcasts, TuneIn, and more. All of that is stuff you can explore through the web interface.

Personally, there are three ideas I’m thinking of doing soon. The first is to setup an Autoplay URL in under MusicBox settings so that NPR (or whatever your favorite streaming radio station is) turns on as soon as the system boots up. Could be a fun way to get my news in the morning.

Second idea I have is to give the MusicBox a personalized name that conveys its location (ie. kitchen). This would also automatically change the name of its address to kitchen.local. Then I could make whole separate, second system for my bedroom and name it so that it comes up under bedroom.local. Now for under $200 I have a multi-room audio system.

Third, I think it would be great to upgrade the audio card of the Pi Zero with a higher quality solution. There are a bunch out there on the market, and from what I can tell in the MusicBox forums, most seem to be supported by the software. My eyes are currently on the $17 DAC+ Zero from HiFi Berry.