The serendipitous digital audio player
I like to listen to albums, and I like to listen to them all the way through, from beginning to end.
I own a digital audio player, a kind of modern iPod. I have fitted it with a 256 GB microSDXC card for storage, which is enough for over 500 losslessly-compressed albums.
However, this leaves me with a couple of problems:
- Between ripped CDs I own (which is a lot, because they are very cheap these days) and downloads from Bandcamp, I already have more music than that.
- There’s no good way to navigate that number of albums on a tiny screen.
I could solve the first problem with lossy compression, and at my age, at reasonably high quality levels I probably wouldn’t even notice.
I could solve the second problem if I just listened on shuffle the whole time, but I like to listen to a whole album. I’m not sure if my player has an album shuffle feature, but even then, I still want more control, to be able to pick something appropriate to my mood.
My solution is to put 40 randomly-selected albums on the player each week. This is enough variety for a range of moods, not so many as to to be overwhelming, and few enough that I end up listening to albums I haven’t heard in a while.
Here’s my script. It picks albums and symlinks them into a new timestamped
directory, which is then synced to the player using rsync:
#!/usr/bin/env ruby
DEST = "/media/paul/R1 Music/Albums/"
SUBSET_COUNT = 40
require "fileutils"
include FileUtils
subset_dir = Time.now.strftime("Subset-%Y-%m-%d")
mkdir_p subset_dir
cd subset_dir do
albums = Dir["../Processed/*"]
subset = albums.sample(SUBSET_COUNT)
subset.each do |album|
ln_s album, "./"
end
end
system %{rsync -av --delete --copy-dirlinks "#{subset_dir}/" "#{DEST}"}
The --copy-dirlinks option is needed to turn the symlinks into actual
directories on the destination.
There are a few assumptions in this script that mean it won’t work for anyone else who just copies it:
- The script is being run from the
~/Musicdirectory. - There is a directory full of albums (one directory per album, no artist
hierarchy) in
~/Music/Processed. - It won’t be run more than once per day.
The rsync at the end is potentially dangerous, because --delete means that
it will replace everything in that directory. Be careful. Make sure your
carefully-ripped collection is backed up – but please do that anyway!
I didn’t bother removing old subset directories because it’s interesting to see past selections, and automated deletion is risky (see previous paragraph).