home / blog / podcasts / notes / photos / about / more

Private "Spotify"

on a Raspberry Pi

Posted by Jeena

Because of a couple of political reasons, which I won't discuss here, I am not using Spotify but instead buy most of my music on vinyl, which nowadays almost always comes with either a CD or the ability to download good sounding MP3s.

But I still adore how Spotify solved the problem of not being able to have all your music with you all the time. I wanted to have something like that but self hosted with my own music on it and if possible with open source software.

Hardware

Two weeks ago I found out about the new Raspberry Pi 2 (short RP) which is about three times faster as its predecessor but still consumes just a fraction of power of a full blown PC. It uses a ARM7 4 core processor and has 1 GB RAM. This, so I reasoned, should be enough as a server for my own music.

I bought a 64 GB SD card because it was reasonably priced and doesn't use as much power as a external hard disk but is still big enough to fit all my music I have now and will buy the next couple of years. I even 3D printed a case for it at work, check it out:

Subsonic RP

The weird looking holes right and left are me trying to fit the RP into the not so greatly fitting case and making some room with a hot knife afterwards. Our 3D printer at work is quite old and not really calibrated, but it's still pretty neat.

Software

The software was much more cumbersome. First I was looking if Plex would run on the RP 2, because even though it is not open source it really works well for my home video entertainment, even on the road. There seems to be a Plex server version for ARM processors but it seems very old and not official.

DLNA

My next thought was DLNA, but after some research I found out that this will not work for me if I'm trying to stream from outside of my home network because the clients I found don't let me put in the IP address of my RP, it seems that it is mostly designed to be auto discovered within one network.

Music Player Daemon

Then a coworker mentioned mpd so I installed the server on the RP and a client on my android phone and at first it was cool, I was able to browse my music and stream it. The problem is mpd is designed to play the music on the server hardware and there is only a plugin which lets you stream the music over the network to a different device but it is still played on the server.

This turned out to lag immensely. From me pressing the play button until I was able to hear the music it took over 15 seconds! And it didn't cache the music I already played either. It wouldn't work on the train, for example, where I don't always have steady network. I have 15 GB to use during the month on my mobile internet plan but because I am commuting two hours a day this would be gone quite fast without cache.

Little did I know a comment by Christopher Sikk on my post about mpd would be the key to the solution, he mentioned Subsonic.

Subsonic

Subsonic is "Your complete, personal media streamer.", the very cool thing about it is that it already has many different clients and a nice API. It is also open source (GPL 3). One thing I didn't quite like was its web front end which is very slow. The reason for that I assume is that it is written in Java which is good for portability, so I was able to run it on the ARM7 CPU, but often makes for bloated software by design.

The web front end is slow but I almost never have to use it because I am using the different clients, they have a really nice one for Android which while playing downloads and saves the songs in a directory for all the other music players on the phone to use it. But I don't even need that because the player itself looks and works really great.

Subsonic Android playing song Subsonic Android album list

On Linux I use Clementine which has a plugin to be able to show the music from Subsonic. It is not a very sexy music player and it can't even show the artwork but it plays reliably and honors the media buttons on my keyboard which is more than I could say about most of the other music players.

For OS X I found Submariner and sometimes I even try to use it but it is really weird. I have to admit that as a plain music player I really like iTunes on OS X, therefor I decided to kill two birds with one stone.

Arch Linux ARM

As the OS on the RP I am using Arch Linux ARM which I really like. It is super slim, you only install the things you really need and it uses SystemD which I like and know how to use to start and supervise applications like Subsonic. The only dependency Subsonic had was Java 7 ARM which I was able to install via the normal package manager without problems. I run the system like a real server, which means without X (the graphical interface), everything I do I am doing via ssh.

Syncthing

I needed backup of all my music anyway so I decided to use Syncthing to sync my Music folder from the iMac to the RP. I already lost my whole music library twice because I didn't understand how to use OwnCloud Sync nor Bittorrentsync, I removed the music from the second computer because I needed the space which also deleted the music on my iMac and all the music was gone.

I still have all my download codes and my CDs so it wasn't a problem to get everything back but it took quite some time, and it happened twice, so I was quite reluctant at first. But then I found out that one can make one computer the master for a directory which means that no matter what happens on the other computers, the master directory will never be changed by that.

How does it work?

I have to say that It works really really great! When I buy some music I put it into the ~/Music directory on my iMac, Syncthing automatically synchronises it to the RP where Subsonic first indexes it and then lets me play it on my way to work and at work through the Android client or Clementine. At the same time I can listen to it on iTunes on my iMac and have double backups of my music, the TimeMachine and the Raspberry Pi.

To put the cherry on the cake Subsonic also scrobbles all my plays to my account at Last FM, btw. add me as your friend there if you yourself use it too.

I have the luck to have kind of static IPs for all my devices at home which are public and only changed when I remove the device for a longer period of time from the network. That is why I right now don't need to handle dynamic IP addresses, I just point one of my subdomains to the RP so it is easier to remember.

I am really surprised that in the end everything worked out that great, I have my Spotify replacement with open source software hosted at home on a really low power device with all my own music available everywhere where I can find a internet connection.

9 Replies

,

@iangreenleaf sadly the day only has 24 hours and I already am programming most of them.

,

@jeena Also, are you involved with the #ArkOS community? You should be. Your breadth of skill and speedy implementing are so helpful.

,

@jeena That's fantastic. Streaming my personal media collection is one of my big outstanding home server to-dos, and Subsonic looks great.

,

@jeena Thanks so much for this. I've have been meaning to ask how Subsonic was working on the RP 2. I need to do this & lose the iMac.

,

@iangreenleaf I've been using Subsonic for over a year. Setup took very little time & effort. And, I'm not as savvy as yourself & @jeena.

,

@jeena yeah, I understand. You gotta pick and choose. Still, if you're looking to do more with your rPi, keep it in mind...

,

@jeena How have you been liking Subsonic so far? It's strange to me that there is a "premium" version. If it works well it's probably worth the $12/year to me, but I don't quite understand why they charge for it.

2 Mentions

@jeena Still using jeena.net/private-music-… Subsonic? To you have a Premium license for usage of Apps?

Niklas Droplit Droplit

2 Reposts

Niklas Volker Mische

Have you written a response? Let me know the URL:

There's also indie comments (webmentions) support.