YOU CAN TAKE IT WITH YOU
How to Bring Your Home Music Collection Along Anywhere The Internet's Available
Tired of having to haul a portable HDD or stack of SD cards and a laptop with you if you want to listen to your music collection away from home, or doing without when you're in the car or out walking or jogging? Sure there are streaming services, but I haven't found one yet that has the music in my home collection conveniently organized in resolutions up to 24/192 or even DSD. Here's an inexpensive DIY method that will allow you to listen to a good chunk of your home collection wherever you are, including outdoors or in the car, anywhere there's reasonable internet (including cell) service, using little more than your phone.
What you'll need:
- A home computer that can access the Internet, with your music collection available directly or via network.
- Ownership of a web domain name (I do this through iwantmyname.com for $15 a year).
- (Optional but highly recommended) A smartphone. Virtually nothing else quite so conveniently pulls your music from the web, is able via apps to present it to you in such a convenient format, or is quite so portable as a smartphone.
- (Optional) A way to get digital audio from your smartphone, for example Apple's Camera Connection Kit (CCK), a/k/a the Lightning to USB 3 Camera Adapter. The CCK is $39, not a lot of money if you've gone to a little trouble to make your home audio collection available to your phone.
- (Optional) If you like, a portable DAC plus headphones and/or a way to connect the DAC to your car audio.
I'll walk you through installation of the following software:
And there will be a couple of bits of advice about configuring the AVSub iPhone app.
There are other ways to do all of this, and other software in particular. Subsonic costs $12 a year (or $99 lifetime); there's a free alternative called Airsonic. You can use a different web server than Caddy. There are apps for Android phones, and alternative apps for iPhones. You can go whole hog and get yourself a web site through a hosting service instead of hosting it from your own computer with a purchased domain name. Or you can use Plex or JRiver instead of these programs and apps. This is just the way I happened to wind up preferring, and I'll discuss why as we go along.
1. Make a Name for Yourself
There are many domain name providers. I started with iwantmyname.com because it was recommended by my email provider, who I like a lot, and I haven't had any reason to regret that decision since. Prices for top level domains (.com, .net, .org, etc.) vary widely, see https://iwantmyname.com/domains . Create a domain name for yourself under one of these top level domains, and then a subdomain for Subsonic to use, for example subsonic.yourdomainname.org. OK, we're done.
Why do I prefer this to a full on web hosting service? It's a lot cheaper, for one thing. It's also a simpler one-and-done transaction, with none of the ongoing maintenance obligations on the hosting service or usage rules/restrictions for the user. And full on web hosting simply isn't necessary to get your music collection on the web.
2. Prepare to Communicate with the Outside World (Securely)
In your router configuration, forward the following ports: 80 and 443. These ports are used by the Caddy web server to do its magic, as you'll see below, that automatically allows you to serve your music securely and password-protected, *if* you take reasonable precautions. What do I mean by reasonable precautions? I mean that the passwords you use for the administrator and the other user you'll create in Subsonic (section 4 below) should be very secure. My recommendation is to use a good password manager that will work on both your PC and your phone. (I use LastPass, which works as both a browser extension and a phone app.) The password manager creates long complex passwords for you that are very difficult for hackers to crack, and stores them so you don't have to remember them. Since the password manager has all your passwords, you'll want to protect it really well. I do this in 2 ways:
- Come up with a long sentence that has significance for you so you'll remember it, that has punctuation and one or more dates. Then take the first letter of each word of the sentence, plus all the punctuation and dates (numbers) as the password for the password manager. You can then recall this password any time you need it, but for anyone else it's a long string of gibberish.
- I have set up Last Pass to use 2-factor authentication with my phone (Google Authenticator and Authy are two authentication apps for phones, and LastPass also offers one of its own). These apps provide a string of digits (usually 6) that changes once every minute or so, and LastPass requires me to enter the string after I've entered the main password, before I can access my stored passwords. So even if a hacker's computer would manage the unlikely feat of cracking my long gibberish main password, the hacker would need my phone plus my face or phone unlocking code to access my stored passwords.
OK, that's the security lecture. It may sound like a PITA, but if you do this you'll be able not only to protect the computer you're serving music from, but using the same practices you can keep passwords secure for your and your family's credit cards, banking and financial information, etc.
3. Install Subsonic
For Windows and Mac, download and run the installer from http://www.subsonic.org/pages/download.jsp . For Debian/Ubuntu-based Linux distros, follow the simple instructions at http://www.subsonic.org/pages/installation.jsp#debian . For most Arch-based distros, you will want to install yay first from the terminal:
sudo pacman -Syyu
sudo pacman -S yay
Once yay is installed, the following should work
yay -S subsonic
OK, we're done.
Why Subsonic? I found the Airsonic documentation lacking in comparison. Plex didn't like AIFF format, which is how all my music files are stored. And though other folks love it, I've found the JRiver and JRemote user interfaces aren't to my personal taste. Subsonic is reasonably simple to install and configure, and quite inexpensive.
4. Configure Subsonic
You should have a running Subsonic web page on http://localhost:4040/ , username and password both 'admin' (no quotes). (If you don't in Linux, in a terminal type
sudo systemctl start subsonic
sudo systemctl enable subsonic
to have Subsonic start at boot time). You'll want to go to Settings>Users and change the admin's password immediately; it's also highly recommended to create a new user that will eventually be the one signing on to AVSub (or another app) and playing your music. Make sure any users have the right to browse and view your music files. Under Transcoding, check the box and click Save to delete the on-the-fly transcoding that plays all your files as mp3, unless you actually want that.
Under Windows and I assume MacOS(which I haven't tried), adding your music folder(s) should be trivial. Just go to Settings>Media Folders and add it/them.
In Linux, it can be a little more involved. First you want to be sure your music drive(s) is/are auto-mounted at boot time, and the traditional way to do that is to edit the /etc/fstab file. If your drive is already set to auto-mount, or you feel reasonably comfortable doing this, or reasonably comfortable you'll be able to after a quick search to learn or remind yourself how, have at it (be sure to run mount -a before rebooting so you know if you've messed up that file and can walk back your changes - otherwise, you could render your Linux installation unbootable). But if you're unsure, my recommendation is to stick to Windows or Mac.
After your music drive is mounted in Linux, Subsonic may refuse when you try to add it in Settings>Media Folders. No problem. In a terminal, type
ln -s wherever-your-music-directory-lives /var/music
That makes a 'symbolic link' (same idea as a Windows shortcut) from where your files actually are to /var/music, where Subsonic expects to find your music files.
Once you've added your music folder(s), do something else for a while, like go to sleep. It takes Subsonic a long time to index your music files (on my computer with a USB3 connection to the external HDD, 10k tracks take overnight to complete). Subsonic indexes your files alphanumerically by folder name unless you ask it to use metadata.
OK, we're done configuring Subsonic.
5. Install Caddy
For Mac, searching the Web will get you instructions for installation using Homebrew. For Windows download the amd64 zip file from https://github.com/caddyserver/caddy/releases and extract caddy.exe to a folder you've created on your main drive called Caddy. Don't do anything else with it yet. For Debian/Ubuntu-based Linux distributions the instructions at https://caddyserver.com/docs/install will give you the terminal commands. For Arch-based Linux distributions, just type the following in a terminal:
yay -S caddy
6. Configure Caddy (like taking Caddy from a baby)
I started looking at Caddy because (1) I don't like Apache, the most common webserver, very much - it's complicated to configure and way overkill for a simple task like acting as security for serving your music files, which is all we need a webserver for here; and (2) the server I favored instead, nginx ("engine-x"), disdains Windows to such an extent it doesn't even have an official 64-bit Windows release. But as I began to look further, I realized the biggest reason to use Caddy is that it's Easy!, Easy!, Easy! (Did I mention it's easy?)
For example: You want your music to be served securely, and for that you have to obtain and renew a certificate that allows you to serve your Subsonic site as https:// instead of http:// . For Caddy, here is what you have to do to obtain and renew the appropriate certificate and start serving your site securely: Nothing! Caddy obtains the certificate the first time it runs and takes care of timely renewals automatically, behind the scenes. (There is no cost for this.)
A second painful aspect of working with other common servers is the configuration file, which is long and full of obscure terms. Not so for Caddy. In fact for Windows we don't even need a configuration file, just a couple of tweaks to its startup command.
Here's the entire startup command we'll need for Caddy in Windows, which you should create as a text file (in Notepad, not Word!), then rename to Start Caddy.bat and place in the Caddy folder where you put caddy.exe:
cd letterformaindrive:\caddy caddy reverse-proxy --from yoursubsonicsubdomain.yourdomainname.whatever --to localhost:4040
Of course you'll put real entries in place of the letter for your main drive and '...whatever' above, but that is everything you need in terms of configuring Caddy to act as a secure server for your music files that have been indexed by Subsonic.
We should do one last automation step in Windows to have your web server run as a service that automatically starts up when your computer boots into the operating system. For that you want to download, install and run NSSM (Non-Sucking Service Manager - yes, really) according to the short and simple directions at step 6.1 here - LINK (go to section 6.1).
I don't know. Haven't done this on a Mac yet (waiting for the new MacBook Pros to come out). But the configuration file should look like the one in the Linux instructions below. If anyone wants to do this on a Mac and report back in the comments, that would be great.
This is unbelievably dead simple. There is in all likelihood a text file in the /etc/caddy directory (which should already exist as a result of installation) named Caddyfile (with no extension). You want to either add to and comment out what's already there so that only the following remain as valid configuration commands, delete everything and add the following, or if no Caddyfile exists, simply create it:
https://yoursubsonicsubdomain.yourdomainname.whatever reverse_proxy localhost:4040
And that (using your real Subsonic subdomain name, of course) is *it* as far as the configuration that will tell Caddy to securely serve your music files from Subsonic.
One last thing is to make Caddy start when Linux boots:
sudo systemctl restart caddy sudo systemctl enable caddy
It's restart rather than start, because if your Linux distribution automatically started Caddy upon installation, you want a restart to pick up the changes you've just made to the configuration.
And we're done!
7. Testing the Computer Installation
Just type https://yoursubsonicsubdomain.yourdomainname.whatever (using your real subdomain of course) into the address field of a web browser. You should see the Subsonic page to enter your username and password, and when you do so for admin or for the new user you created, this should take you to the pages with the various Subsonic settings.
All right, we're on the web! Now all that remains to be done is to install a phone app that works with Subsonic (my preference, as noted above, is AVSub), and you'll have your music anywhere your phone gets internet service - anything from walks or runs to long drives in the car (many of these apps, including AVSub, are supposed to work with CarPlay), or just sitting outside.
8. AVSub Settings
You probably want as large a cache and preload buffer as possible. This may cause AVSub to take a little longer to start playing a selection, but you won't get as many (or depending on your location and internet service, any) annoying dropouts or halts in the music.
I have all formats set to original, and disallow transcoding. I allow digital output up to 24/192 and have enabled DSD over PCM. To play the highest resolutions like 24/192 and DSD you'll want a fast connection, probably Wi-Fi or 5G. But with a good LTE connection, I've had success playing back 24/96 files.