brainbaking/content/post/2022/03/how-to-stream-your-own-musi...

106 lines
9.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: "How To Stream Your Own Music: Reprise"
date: 2022-03-05T14:30:00+01:00
categories:
- retro
- software
tags:
- music
- audio codecs
- navidrome
- self-hosted
---
This is a follow-up to my own February blog post, [How To Enjoy Your Own Digital Music](/post/2022/02/how-to-enjoy-your-own-digital-music/). After thinking this through, buying a NAS, [and playing with it](/post/2022/02/thoughts-on-home-nas-systems/), now is the time to answer my own question: how to enjoy your own digital music collection nowadays?
Pinky swear it'll be my last post on self-hosting. For a while.
## The Why
The local record store owner told me I was the exception when I bought GZA's _Liquid Swords_ on CD. Almost all rap enthusiasts swear by LPs/vinyl---it's going through a real renaissance period. Most new LPs are priced at `€30` or more, and some older more obscure underground stuff is really hard to get. You guessed it: yet another hobby to sink too much money into. On the other hand, (digital) CDs are dirt-cheap. _Liquid Swords_ cost me `€6.90`. Ridiculously cheap---but that's a 1995 album. Most others are priced at around `€17`. Since I mostly listen to music while working (behind a PC) or on the road (in the car), I prefer digital audio.
While just relying on ripped `.mp3` files on your local HDD suffices, it's nice to have the ability to stream those. For me, the main advantage is having the collection available on-the-go, provided a music client has offline play capabilities. My smartphone's disk space is small, and I don't like having to re-copy/upload albums every so often. Yes, I've been spoiled with Spotify-like streaming services. It's damn handy, I'll give them that! A second advantage is easy sharing with family members.
## The How
Enter [Navidrome](https://www.navidrome.org/), a blazing fast "personal streaming service" that acts as your local Spotify server. It has been running in try-out mode for a few weeks here, and so far, I'm pretty impressed. It's simple, small, consumes little resources, can handle huge libraries, and immediately detects file changes. Do not expect the polish present in the current Spotify client though: the HTML5 client still has missing features (no universal search, no decent gapless playback, ...)---but still. You don't _have_ to rely on their default client.
To install Navidrome using docker, simply [use the offical Docker image](https://www.navidrome.org/docs/installation/docker/). If you have a Synology NAS, it's very easy: install the "Docker" application from the Package Center, click "Registry", find Navidrome, double-click to download. The only thing to configure is the volume; create a new shared folder called `music` and mount it at path `/music`. Done! Now the app should be available at your server IP:your local port (see screenshot below, mine's not set to "auto" but hard-coded at `9977`):
![](../navidrome-docker.jpg)
If you want to create a clean URL as an alias, set up the reverse proxy: go to Control Panel, click on Login Portal, tab Advanced, click on Reverse Proxy. Fill in the source (`HTTP`, hostname `cd.yourhost`, port `80`) and destination (`HTTP`, hostname `localhost`, port the local one set up in the Docker settings, mine's set at `9977`). This will not suffice, you also need a DNS server that tells you `yourhost` is actually your local server IP. Synology has a built-in DNS server (search for "DNS Server" in the Package Center), or you can rely on something like a Pi-Hole.
Great, now it's time to start populating that music folder! The location _does not matter_---Navidrome will auto-scan that path. After a while you can enjoy the music through a browser by simply surfing to `http://cd.yourhost/`:
![](../navidrome.jpg)
If you don't like the fact that it's a web app, no worries. Navidrome implements the Subsonic API, meaning all other music streaming clients that are compatible with Subsonic[^subs] are also compatible with Navidrome. [Here's a list of apps](https://www.navidrome.org/docs/overview/#apps) currently compatible with the Navidrome server. So far, I've tried:
[^subs]: The Subsonic development was stopped, hence Navidrome as the spiritual "successor".
- Subtracks for Android---a great looking app but no download play;
- Sonixd---a desktop client based on Electron that is slow, has issues with text rendering and doesn't listen to dedicated next/previous key buttons;
- Substreamer for Android and iOS---a mature smartphone app that fulfills all my wishes.
Linux users could also check out [Sublime Music](https://sublimemusic.app/) built on GTK. I haven't found a decent dedicated client for MacOS yet besides [SoundWaves](https://www.tellini.org/products/mac/soundwaves/) that I have yet to try. A [great overview of selfhosted music clients](https://github.com/basings/selfhosted-music-overview) can be found on GitHub. Some have true gapless playback, some feature download play. I really like Substreamer:
![](../substreamer.jpg)
It worked perfectly with Bluetooth in the car, it has light/dark modes, it can download albums if you want to keep your server local without having to open up a VPN tunnel, and it is very responsive. The iOS client is also good.
## The What
What to take into consideration when converting your CDs into `.mp3` files? Navidrome and its clients heavily rely on M3U meta tags. A music tagger such as [MusicBrainz Picard](https://picard.musicbrainz.org/), MP3Tag, or [Beets](https://beets.io/) is essential if you want to keep your library nice and clean. Picard and Beets rely on the online MusicBrainz database to auto-collect and upload metadata, which is a nice bonus in case you don't like typing it all out for yourself. That database is amazing, it even contains information about obscure Flemish compilations!
A few random tagging tips for Navidrome:
- If your CD is a compilation, set the `compilation` tag to `1`. Add `albumartist` as `Various Artists` if needed. For now, under the "Artist" tab, Navidrome can only search for `albumartist` tags. Search by song if you're looking for an artist on another compilation CD.
- If your album contains multiple CDs, set each `discnumber` accordingly, and if needed, add a `disctitle`. This will automatically show up in the Navidrome web app, but as far as I've tried, not be picked up by Substreamer.
- Think twice about the `genre` contents. It's a great way to quickly filter your collection.
- Dig up a `cover.jpg` file for each album, there's no need to embed it into the file itself, although it's possible.
- The `comment` tag is displayed below the album art. Go nuts!
As for the ripping itself, well... I still rely on my trusty [WinXP machine](/post/2020/10/building-a-core2duo-winxp-retro-pc/) and yes, still use [Audiograbber](https://www.audiograbber.org/) with `lame.exe`. Instant retro vibes! Remember to enable the `SMB1` (Samba v1) sharing protocol on your NAS if you require file access from a retro computer---version 2 and 3 are the standard nowadays. The LAME encoder comes with a few presets, of which probably only two are of use in 2022:
- The `--preset insane` option: a constant bit rate of `320 kbps`. The absolute highest quality but largest files. Average album sizes: `140 MB`.
- The `--preset extreme` option: a variable bit rate of around `260 kbps`. Still very high quality, I can't hear the difference and usually settle with this. Average album size: `105 MB`.
The jump in quality from `128 kbps` to 192 (and especially higher) is huge. It's up to you whether or not to exaggerate: if you have the space, why not. The Bandcamp albums are still downloaded as `.ogg` (+/- `190 kbps`), but the option to download larger files is there.
One last thing: invest in a good **headset** and **speaker**! The speakers of a MacBook or your average smartphone are laughably bad when trying to enjoy something with a deep bass or subtle tone differences. Over-ear Bose headphones are good enough for me, and the noise cancellation works wonders when my wife insists on watching TV. I realize better (and more expensive) options are available. I've enjoyed Sony in-ear buds too---while they lasted, before breaking down completely. Navidrome supports Sonos speakers through another daemon service, but I haven't tried that yet. Most of the heavy lifting is still done by the Pioneer box as seen in [my office setup](/post/2021/02/my-retro-desktop-setup/).
And that's how you stream your own music. Don't forget from time to time to dig through your CD collection and effectively use the CD itself on your retro Hi-Fi installation to sit down, relax, and do nothing but enjoy the music.
---
**Addendum** 8th March: I am officially an idiot. Who still manually tags their music files? Compared to other CD rip software, Audiograbber is extremely limited, yet I didn't know better. After reading Williams' [enjoying music curation again](https://blog.yossarian.net/2022/02/21/Enjoying-music-curation-again) post, I tried the Linux command-line tool [abcde](https://linux.die.net/man/1/abcde)---yes, the Retroxp machine is dual-booted----which can be configured to automatically download (and embed) album art, fill in M3U data, rip simultaneously in multiple formats, etc.
And it worked like a charm! Details on how to use it can be found in William's post. Here's my `.abcde.conf` file:
```
ACTIONS="cddb,read,getalbumart,encode,tag,move,clean"
OUTPUTTYPE="mp3"
LAMEOPTS="--preset extreme"
WAVOUTPUTDIR=/tmp
OUTPUTDIR="$HOME/Music/"
OUTPUTFORMAT='${ARTISTFILE}/${ALBUMFILE}/${ARTISTFILE} - ${TRACKNUM} - ${TRACKFILE}'
PADTRACKS=y
EJECTCD=y
MAXPROCS=2
CDDBMETHOD="musicbrainz"
# see http://frozen.ca/automatic-cd-ripping-with-abcde/
mungefilename ()
{
echo "$@" | sed s,:,\ -,g | tr / _ | tr -d \\"\?\[:cntrl:\]
}
```
Happy (semi-)automated ripping!