I have a not-quite-vintage SA-PM31 radio/CD player/cassette player – it’s a mini HiFi type arrangement, and I bought it in the early 2000’s; my grandparents were visiting, and memory says that Grandad offered to buy me a radio as a present (potentially related to my first paying job after college, but my memory is really hazy about that bit). It’s still working just fine, though if I was to look at the cassette head, I’m sure I’d find one that would disappoint Matthew Taylor of Techmoan fame.
One useful feature is it has aux input. I have a Pi Zero with an iQAudio DACZero. I don’t remember why I bought that DAC, but I suppose I was thinking about hooking this kind of thing up before. So, I need a way to feed the aux input of the stereo with all the music that I have on the NAS in my living room. It turns out that there are a few projects for this, and most of them seem to be based on mpd; I settled on trying out moOde.
Installation is simple
- download the zip file of the release,
- use the Raspi image writer to write out the SD card,
- connect a WiFi dongle to the Zero using an adapter (since the Zero doesn’t have regular sized ports),
- boot the Pi,
- connect to the AP that moOde starts up by default if it has no network connection,
- access the web UI at hxxp://moode/,
- reconfigure the network settings to use my house WiFi,
- access the web UI at hxxp://moode/ again.
At this point it’s a case of setting up the library to read from my NAS; the scan functionality (for shares) didn’t work, but it was easy enough to add the vault manually and set the SMB version to 3. Then sit back for a few hours while mpd indexes 17,000ish songs.
I basically want this setup to behave like a radio feed; a very eclectic radio feed to be sure as it switches from Bob Marley to Dido to J.S. Bach to Yoko Kanno. moOde has built-in support for ashuffle, but I’ve found it to be a little lacking. The default operation is to just execute ashuffle with some arguments, throw the output away, and put it in the background with &. This leads to a frustrating experience when the ashuffle binary has a problem, because the web UI doesn’t monitor it at all, so if ashuffle has stopped running due to a bug in a library you don’t get any new songs in the queue. The web UI also appears to have problems starting ashuffle up after a reboot – some code path or another isn’t being called correctly I suspect – my debug writes to a file in /tmp don’t appear, even though I’m modding the startAutoShuffle() and stopAutoShuffle() methods (and restarting both nginx and php-fpm to be sure).
It so happens that ashuffle has a contrib example of how to set up a systemd-based “daemon” for ashuffle, so I’ve gone that route. Slightly modified to execute “mpc search filename NAS” and pipe that to ashuffle, and then run ashuffle with “-n” to avoid the libmpdclient problem with response sizes.
[Unit] Description=Shuffle service for mpd Requires=mpd.service After=mpd.service [Service] ExecStart=/bin/bash -c "/usr/bin/mpc search filename 'NAS' | /usr/local/bin/ashuffle -n --queue-buffer 2 --file -" [Install] WantedBy=default.target
With this arrangement, moOde does not have to be configured to use ashuffle; it just works when you set playback to Consume (tells mpd to remove the played item from the queue after playing).
Now all I need is a workshop to put the radio and the Pi in, a case for the Pi, and perhaps some GPIO-hooked buttons for play/pause/next. The radio itself will provide volume control.