Last updated

Music Streaming Setup

I love music.

Recently I got into vinyl and I love it. Although it’s not digital 24/96 studio quality, there is something relaxing about picking a record, putting it on my turn table and listening to the small diamond needle scanning the grooves of the record pressed 30 or 40 years ago. This post is not about vinyl, though.

Today I listen mostly to music on Spotify. It’s cheap, offers good quality and is available both at home and at work.

The thing is I have lots of great music lying around on CD from when I was a kid. It’s all sitting in a box in the attic, wasting away.

So, I thought to myself, what does it take to:

  • Archive my music collection in FLAC
  • Catalog my music properly
  • Stream high quality music over the web (to my laptop)
  • Possibly play directly (analog/digital) to my integrated amplifier

Catalog your music

I’ve only ever used iTunes before to manage my music collection (in low quality mp3, back in the day). These days I use a command line utility named beets. Beets is simple yet effective. Let me just copy the best features from their website:

  • Fetch or calculate all the metadata you could possibly need: album art, lyrics, genres, tempos, ReplayGain levels, or acoustic fingerprints.
  • Get metadata from MusicBrainz, Discogs, or Beatport. Or guess metadata using songs’ filenames or their acoustic fingerprints.
  • Transcode audio to any format you like.
  • Check your library for duplicate tracks and albums or for albums that are missing tracks.

It takes a bit of getting used to, but it’s really easy to use and powerful. I’m not moving to anything else anytime soon.

Enter Raspberry Pi

The first and most obvious choice was to purchase a Raspberry Pi (v3 in this case). It’s a cheap device with ethernet and audio playback capabilities. I also know there are expansions boards that offer digital out or analog out using high quality DACs. I had an old 32GB USB Thumbdrive to use for storage (until I need more).

My first install was using Raspbian and Koel. Koel looks a lot like Spotify and I had high hopes for it.

FLAC

I love FLAC for two reasons. It’s open source and it stores lossless compressed audio. The problem, however, is that FLAC is not as widely supported as I’d like. Mac OS X has no native FLAC support (because Apple obviously favours their own ALAC lossless format). Browsers also have limited support (if any) for FLAC.

This means that my web player, in this case Koel, should transcode FLAC files on the fly to a format that is supported, like mp3.

For this purpose I installed ffmpeg on the Pi and it worked. Sort of. There were two problems with my setup of Koel + Transcoding.

The transcoding could keep up with streaming, were it not that Koel first transcodes the entire file and then starts streaming.

Also, Koel, seemed not to deal with album artists vs. performer particularly well. For instance, Fun, by “Coldplay feat. Tove Lo” would show up as a separate album.

mp3fs

I got tipped off by a coworker that I should look into mp3fs. mp3fs is pretty awesome. It allows you to mount a directory/disk with FLAC files and use those files as if they were mp3s. Yes. Awesome.

The only thing is that everytime you access a file it will use ffmpeg to transcode the FLAC to mp3. Not a problem, until you start importing your collection into Koel. Because the Pi has limited memory, this would crash mp3fs with an out-of-memory error.

Meh. This is not the awesome stable solution I’m looking for.

File size

Well, FLAC is a lossless, compressed format. Despite it begin compressed, it’s still fairly large. Especially if you want to keep your files on 32GB USB drive.

At this point I decided to take another route: keep my high quality FLAC collection on my computer (where it’ll get backed up automatically as well), transcode it to high quality mp3 and use rsync to get it the Pi for streaming. Luckily I’m using beets, which has a convert plugin. This plugin makes life easy to keep a copy of my library available as mp3. For now I’m using mp3 V0 (highest quality variable bitrate), which suits me fine.

Sonerezh

I feel Koel is still too early in its development and I didn’t want some bloated music player like Ampache or Subsonic. Then I stumbled up Sonerezh. It has a clean iTunes-esque interface and just works.

Sonerezh playing

Conclusion

I love my current setup. Keep and manage my FLAC collection on my Mac. Use beets to get proper metadata for each song and convert new or changed files to high quality mp3. These in turn are rsync’ed to my Raspberry Pi, where they become available in Sonerezh for a great streaming experience.

Am I cancelling Spotify? Not just yet, there’s too much music out there to be discovered and Spotify is still great for that. Am I going to expand my collection? You bet!