Our Plucky Little Hometown AM Station

Remember when I used to post about my random little projects on here? Seeing as the Scratchpad hasn’t been shuttered yet, I’m thinking I’ll do that again.

So I’m aiming to have this year return to a largely simpler approach on the web front (fewer blogs, more static HTML), but that doesn’t mean we’re done playing with older technology–hell no! The Gopher’s been stable for over a year now, but a Gopher server is incredibly lightweight, certainly no sweat for the Pi 4 I’ve got it on, and I always ponder what else I can throw at it.

I used to (and still occasionally do) stream on YouTube, but I really rather hate the setup I have to use to make it work. I have to make a thumbnail, I have to have something visual for folks to watch, even when I just want to talk, I can’t play music, and I have to have chat through Discord because somehow it’s faster than YouTube’s own live chat, even on ultra-low latency. That means locking total strangers out of the discussion, unfortunately. As a result, I’ve fallen out of it again.

It’s been a perennial idea for me and Caby for a while now for me to just do some kind of audio-only show, but the concept of internet radio finally got me curious enough to cobble together a setup for it. Internet radio is the perfect example of perfectly good, well-supported technology that’s simply been deemed unnecessary. Dead simple to set up, streams well, streams simply, and anything from VLC to Winamp to web browsers can listen in.

Well, it’s kinda spiraled into three, soon to be four, separate 24/7 genre stations you can listen to right now, with us. Let’s talk about Somnolescent Radio.

So one of the big players in internet radio servers is a project called Icecast. It’s by the same folks who brought you Vorbis, Theora, FLAC, and Opus audio like Discord uses. Icecast is a highly customizable HTTP audio server that can dish out Vorbis, Opus, MP3, and WebM streams, as many as you can encode. Somnolescent aiming to support old machines, we of course went with MP3-only streams.

Icecast's initial setup

It starts with a relatively straightforward setup process, but even with Icecast running (and I indeed could access the status page at my IP address on port 8000), that’s only half the battle. You’ll need a program that can broadcast to it. Given that I was aiming to produce an automated, 24/7 stream of music, I went with Music Player Daemon, a similarly highly configurable tool that can read and beam out anything that ffmpeg can play over defined audio outputs, like a SHOUTcast (which Icecast is an open-source clone of) server, and the mpc command-line audio player to control it.

Here’s the basic signal flow:

  1. Icecast has three different user logins, one of which is for audio sources. On its own, it broadcasts nothing.
  2. Your app of choice (or source) logs into Icecast using your login information and establishes a mountpoint. The mountpoint is also the end URL the user will go to to listen to the station. Mountpoints are assigned on a first-come, first-served basis (meaning if you have more sources broadcasting to Icecast than you do allowed sources, you’ll get a login failed error–as I did).
  3. Your source also provides the mountpoint metadata–things like stream name, stream description, genre, URL, bitrate, audio format, and content type.
  4. Icecast takes in the data from the source, packages it up nicely into an HTTP stream, and sends it to whoever wants to listen to it, depending the max listeners you have set in your Icecast config.

All well and good, and after about an hour of trying various apps for sources (which either needed to be built or didn’t run at all), MPD was set up successfully, and Somnolescent Radio was inaugurated with a broadcast of The Slip’s “Airplane/Primitive”. (This isn’t why I picked it, but fittingly, the song namedrops Dylan Thomas, Welsh poet and radio presenter. Whom I just learned apparently was not exactly fond of Wales. Ah well. He was a drunk anyway.)

Encouraged, I decided to try a live broadcast. Taking that same /test mountpoint, I tried broadcasting something over the network instead of on the local machine–me talking and playing music for the group, all of whom were very into it. I even took guests! borb was on with me to talk about disgusting pizzas, and much merriment was had.

But that was back in December, and though we’ve wanted to put together playlists and 24/7 radio since then, it’s only been in the last few days I’ve really gotten back to trying to set things up. I was daunted. Linux is a right pain in my left nut to set shit up on, and here, I was asking for not just one copy of MPD, but three somehow, running at once. So, I avoided it.

Thankfully, this was a lot easier than I anticipated. Essentially, you can run MPD with a configuration file as a command-line option, and it’ll be able to run on a different directory to read files from, different music library to store song choices in, and separate mountpoint options. So you simply run the mpd command three times, each with a different config:

sudo mpd /etc/mpd2.conf ; sudo mpd /etc/mpd3.conf

(This is only two because it already runs one at launch. I can make it more graceful and run all three at launch, but eh, not right now.)

I thought I’d somehow need three versions of mpc to control them, but you can simply use the --host and --port options to control specific running copies of MPD. There’s even support for ReplayGain, which has mostly worked for keeping song-to-song volume about equal. (I run everyone’s songs through R128GAIN before they go to air.)

mpc toggle ; mpc --host localhost -p 6601 toggle ; mpc --host localhost -p 6602 toggle

This isn’t a hypothetical–this is all working right now, and has been running non-stop for a few days now. Three MP3 streams are nothing for the Pi to read and transcode in real time, and everyone’s been digging through their music library to contribute song choices. We’re not done at all–Devon (who’s back in the group, by the way–hi Devon!) gave me a gig and a half’s worth of AAC files this morning, borb has a playlist of 100 songs and counting saved up, and I’m only about half through my CD collection. Still, we have about 800 songs in the rotation at the moment.

Somnol Radio's three current stations

We’re even thinking of expanding out to a fourth station. Currently, we’ve got a pop station on Radio One, an alternative station on Two, and a chillout/folk station on Three. This is proving a little cramped, so the thought is that, when all is said and done, I’ll go back through all probably 1,500 or so songs and resort them into pop, classic rock, alternative/noise rock, and chillout, so One and Two don’t have such gigantic, occasionally disparate playlists.

Impressively, there’s someone listening on Radio Two right now! They’re enjoying Nirvana’s “Dive”, which of course came from my own collection. I was seriously worried that it’d mostly be my own music playing throughout, but with Caby and Devon each having contributed 300 songs to the playlists, and another few hundred coming from dcb and borb when it’s all said and done, it’s thankfully not just Cammy Radio, but indeed, Somnolescent Radio.

The encroaching redesign of somnolescent.net will include a reworking of radio.somnolescent.net as well. Since the status page is actually customizable, we’d like to give it some custom graphics and a new color scheme, possibly tweak the layout some as well. Right now, though, it’s just using the stock Icecast status page, which works well enough, thankfully. I took a break from ripping CDs today, but I’ll be back at it tomorrow, and then I’ll get to my downloaded music (which will include lots of c.layne, yes).

Oh! And as for those live broadcasts? I’m looking to start doing them regularly, on the dot, Mondays and Fridays. I’ll start next week so as to not tax myself while I’m still getting server stuff settled, but if you’d like to hear me ramble and play your tunes, join the Outposts and we can do just that together.

Comments are closed.