Friday, August 30, 2013

Raspberry Pi Streaming Music Server

The obvious thing about this post is that is has been a very long time since I last posted.  (Typical of casual bloggers).  I will spare the promises of posting more frequently as to not break promises.  I started a new job a couple of months ago.  Still in the enterprise environment I am working for a Hospital taking care of the networking and radiology systems.  So look for posts of a different flavor from me as I am finally getting into the physical networking of IT and lots of Cisco!

But now for a fun post!  Lots of geeks have been finding uses for the Raspberry Pi's.  You can do pretty much anything you want with these little things!  For me, I wanted to get my feet wet by creating my own music server.  The reason was two fold.  1: I finally have an excuse to play with a Raspberry Pi.  2: Our bandwith at my new place of work is choppy.  All 20mb of our pipe is pretty much maximized all day long.  It makes streaming from my google play library tough.  Also, I have a 256mb solid state drive in my laptop and I run VMware workstation with VM's because I am an IT professional so space is at a premium.  Enter the Pi!

If you have not heard of the raspberry pi click here:  RaspberryPi  If your ready to take the plunge and buy one go here: BuyPi  (The price just jumped from $34.95 to $39.95 this week for some reason.).

For my Pi I bought the model B (512mb ram), a clear case, the power adapter and a 32gb SD card (from Amazon).  The entire package was just under $70.

To install the OS you need to install it on an SD card.  Thankfully my laptop (Dell Latitude) has a SD card slot in it.  I downloaded the OS named "raspian wheezy" here.  Its important to note that the RaspberryPi cannot boot without a SD card in the slot.  There is no flash memory on the Pi.

I downloaded Win32DiskImager here.  This is not a progam that needs to be installed.  Just save the folder somewhere and run the .exe to launch the app.  Point it to your .img file of Wheezy and tell it to write to your sd card.  Once that is done insert the sd card into your Pi.

Like me if you dont have a HDMI monitor to plug into the Pi, you will need to figure out what DHCP address its getting from your network.  You can either look at your DHCP server to find it out (the host name will be "raspberrypi") or use a tool like angryip to scan your network subnet and find it.

I use a combination of winscp and putty to manage linux systems using ssh.  I get teased a lot from friends for using winscp to edit files instead of doing it from the command line with vi or nano... but at the end of the day it gets the job done... usually faster and easier!

The default password for the raspberry pi is: pi and the password is: raspberry  I logged into the console with ssh and putty after finding the IP and enabled the root account as its disabled by default.  (Wheezy is a flavor of Debian linux).  After doing this I loogged into the Pi with root and was presented with a nice screen with some options.  Things like change the password for the Pi user account (I did), do you want it to boot with a GUI desktop (since im not using it with a monitor I chose no), change hostname (which I did), and an important one which is the first option is to expand the disk space.  By default Wheezy only formats your SD card for the space it needs.  By doing this it will open up the remaining space on your SD card.  (In my case 32gb card).  Wheezy uses approximately 2gb.

Once this is done go out and download Subsonic here.  Then place it somewhere on your Pi.  (I used winscp to copy it to the pi).  The instructions to install Subsonic are very straight forward and their website walks you through it nicely here.

I choose subsonic for its ability to use almost every file format.  It also will download your podcasts, and you can store videos on it as well.  Also, you can create different users to access the web portal to stream their music through it.  Since I am using this at work, I setup a few colleagues to use it so they can stream the music I put on it.  You can get very granular with the user accounts.  You can limit the bit rate at which they can stream, you can lock them down so they can't download your music and much, much more!  To access the web portal go to the IP of your Pi.  Http://xxx.xxx.xxx.xxx:4040  The default id and password are admin/admin.

After installing it I really did not change much except for I did create a new user on the Wheezy OS to be used for the system account for the Subsonic service.  The instructions on what config file for subsonic needs to be manipulated for this is well explained in the instructions.  I did create a new folder on the root of the Wheezy OS named "Music" and "media" and told the Subsonic to look there for the music as well.






Take your time and learn the interface for the Subsonic.  It is really not that hard.  You can also play it in "Jukebox" mode which will use the Pi's local audio jack (1/4 inch) for playing audio through.  This can come in handy if you want to get real geeky and make your own retro juke box or retro fit a retro radio or juke box and control it through an iPad or PC browser.



I started uploading MP3's to my music folder I created on the Pi that the Subsonic is looking at for its media.  (Again using winscp).  I did it in the form of a folder named for the artist or band and then inside that folder a folder name for the album and then in that folder is the actual mp3 files.  The following will show the browsing of the Music Folder to the band U2 with the album Achtung Baby:



That's it!  Here are a couple screen shots of the project:






For final notes and thoughts:

- I absolutely love this setup!  I can see offering this to a few customers offices I support for in house music over their office speakers.
- I can see myself retrofitting my retro console stereo at home with another Pi just like this and it can double as a server for streaming to our iPads and computers in the house.
- I love having this as my streaming music server at my office.  No longer am I stuck with the maxed out pipe to my cloud services for streaming music and the quality is at 320kbps so the quality is much better.
- I have had myself and two others at my office streaming at the same time without any hiccups.
- I would recommend not limiting your users streams to a lower bit rate than 320.  Most of my mp3's are 320kbps and they would not stream if the user account accessing them is set to a lesser bit rate.
- I paid $12 for the premium subsonic which is a year subscription.  This strips ads from the browser window as well as lets you add podcasts to it.  The free version has ads in the browser window but other than that it is not "limiting" to the amount of music or quality or anything with the content you add to it.

Cheers!

No comments:

Post a Comment