Rebirth Radio, a UK internet station, used to reach its listeners through a chain of hardware: iTunes playing out of a headphone jack, a loopback cable, and Winamp sending the result to its SHOUTcast server. Station Server replaced that chain with software, and Rebirth’s stations now go out through it. It plays each week from Station Studio to the clock, straight to the station’s server, with room for shows at set times and presenters going live. Station Player is the listener’s half: radio from all over the world on a globe, a tuner to flick through, what’s on now, and an alarm clock that wakes to any of it. Traditional radio, rebuilt as modern software, through a Claude Code project and the feedback of the people using it.
The problem: a station held together with a cable
A week of music is a file, not a broadcast. Station Studio writes each week of a station as an iTunes-XML file, and something still has to play it out, in real time, all week. For Rebirth that was the hardware chain: a computer kept running iTunes and Winamp, and kept quiet, because a system sound or a video playing on it could end up on air. Even hearing a week before it aired meant importing it into Music first.
Three apps with one job each, not one app doing everything. Studio makes the week. Station Server puts it on air. Station Player is for listening: to the station, to a week before it airs, or to any other radio. Each runs a small web server on the person’s computer and shows its pages in a window of its own, and each is released separately, as a Mac or Windows download or from PyPI.
Station Player: hearing the week
Station Player began as the missing step. It reads Studio’s export directly and plays the week in station order, idents and sweepers included. A track that has moved is found again, by file name in the music folders or through a path rewrite. From there it grew into a player for listeners in its own right, with the tools for station makers behind a switch: a plain radio and music player for most people, and Studio tools (Studio’s weeks, recording and a play log for PRS and PPL returns) for the people who make a station.
A browser can play a stream, not read it. Internet radio sends the name of the song inside the audio: every few thousand bytes, a length byte and a short block of text, known as ICY metadata. A browser plays the audio and never sees those blocks, so radio plays through Station Player’s own server, which relays the stream, lifts the titles out and hands the browser clean audio.
def relay(stream: Stream, on_title: Callable[[str | None], None], chunk: int = 16 * 1024) -> Iterator[bytes]:
"""Yield the stream's audio, with any ICY metadata taken out and
handed to `on_title`. Ends when the station closes the connection."""
body = stream.body
metaint = stream.metaint
if not metaint:
while data := body.read1(chunk):
yield data
return
left = metaint
while True:
data = body.read1(min(chunk, left))
if not data:
return
left -= len(data)
yield data
if left:
continue
length = body.read(1)
if not length:
return
size = length[0] * 16
if size:
block = body.read(size)
if len(block) < size:
return
title = parse_stream_title(block)
if title is not None:
on_title(title or None)
left = metaintThe same relay follows HLS streams, as BBC radio sends them, and records a stream exactly as it arrives, with no re-encoding. Around it sits a player to live with: gapless playback and crossfade, volume levelling, a sleep timer, ambient scenes with sound generated as they play, and a phone remote. A car page puts the stations on a phone as big buttons, played by the phone itself over mobile data; the stations travel in the link after the #, so they never reach a server.
Station Player is for finding radio as well as playing it. Discover opens on a globe of the best-liked stations in Radio Browser, a free community directory of tens of thousands, each dot placed where its station broadcasts from, with Music, News and Sport filters. Search by name, genre or country sits alongside, with SomaFM’s ad-free channels. Listen plays a station at once, through the relay, so its song titles show; Add keeps it, logo and all, ready to record or to wake up to. The map ships with the app, and the app fetches the logos itself, so the page never contacts another site.
It doubles as an alarm clock. Clock & alarms shows a big clock with the next alarm beneath it, and a list of labelled alarms, each repeating on chosen days or going off once on a date, waking to a station or a playlist. Alarms fade in over a minute, with Snooze and Stop on screen and on the phone remote. The Radio page’s schedule is built on the same alarms and switches station at set times, such as the news at five and back again. Night mode dims the screen to a bedside clock.
Stations can be tuned by hand. Across the top of the Radio page sits an old radio’s dial with the stations along it: drag the needle, with a hiss of static between stations, or step from one to the next with the arrow keys. A station that runs Station Server also tells Station Player what’s on now and what’s next.
Station Server: putting the week on air
One encoder for the whole broadcast, not one per song. Station Server decodes each track to raw audio with FFmpeg and joins the tracks before a single MP3 encoder that runs for as long as the station is on air, so there is no gap and no reconnect between songs. A mixer handles crossfades, jingles and levelling. A pacer holds the audio to real time, at most two seconds ahead so listeners connect quickly, and after a stall it catches up rather than bursting. The senders speak SHOUTcast’s and Icecast’s source protocols and send each title when the song is actually heard. With no sound card in the chain, nothing else on the computer reaches the broadcast, and one computer can run several stations. The downloads bring their own FFmpeg, built in CI from FFmpeg’s and LAME’s source, pinned and signature-checked, under the LGPL.
The week runs to the clock, not from the top. A Studio week is an ordered list of tracks with no times on it. Station Server pins the first track to the start of the week, Monday 00:00 unless changed, and lets the tracks’ lengths say when every other one airs. After a restart or a power cut the station joins where the clock says, part way into a track, and the running order shows the time each song goes out. Shows are pinned to wall-clock times (“The News, weekdays 09:00”), and when one ends the music comes back where the clock says, as if it had played all along.
def position(lengths: list[float], since_start: float) -> tuple[int, float]:
"""(track index, seconds into it) for a point `since_start` seconds into
the week, looping a playlist shorter than that."""
total = sum(lengths)
if total <= 0:
return 0, 0.0
t = since_start % total
for i, length in enumerate(lengths):
if t < length:
return i, t
t -= length
return 0, 0.0
def where_now(tracks: list[Track], week: WeekStart, now: datetime) -> tuple[int, float]:
"""Which track should be on air at `now` (local, timezone-aware), and how
far into it. The week starts at the wall-clock time, and the time since
is real elapsed time, so a clock change mid-week doesn't jump an hour."""
anchor = week.latest(now.replace(tzinfo=None)).astimezone()
since = (now - anchor).total_seconds()
return position([step_seconds(t) for t in tracks], since)
“Summer Rendezvous” by Ruby Lane, 0:38 into its 1:50
Song 24 of 24, after the playlist has looped 91 times. Worked out from the clock alone, so a restart at this moment lands in the same place.
Built for a computer nobody is watching, not for a demo. Once the first download was out, a review asked a single question: what could leave a station silent with nobody there to notice? The next four releases answered it.
- Runs by itself (0.7). A station that can’t reach its server, or whose music drive isn’t there yet because the computer booted faster than the router, shows “Trying again…” and retries, after 15 seconds and then less often, up to every two minutes. The computer is kept awake while a station is on air, and a week exported early waits for the start of its week.
- Sounds right (0.8). Every track is measured once in the background (EBU R128 loudness and true peak) and levelled to match. Silence at either end is trimmed, and the clock runs on the trimmed lengths so it never drifts. A fallback folder plays instead of silence when the music can’t be read.
- Keeping an eye on it (0.9). Listen plays the broadcast exactly as it leaves. Listener counts come from the server. An alert goes out by phone notification (ntfy) or email when a station has been off air, unreachable or silent for three minutes, and again when it’s back. Phone access opens the stations to other devices on the network, behind a password with a lockout.
- A switch-over kit (0.10). A test stream to rehearse on while Winamp carries on, then Go live. A Ready check of everything a station needs, in one go. If Winamp is still connected, Station Server says so instead of knocking it off.
Presenters keep the setup they already use. While a station is on air, Station Server also listens as an Icecast server would, and as a SHOUTcast one, so a presenter’s existing encoder settings (BUTT, Mixxx, Winamp’s plugin) work unchanged. When a presenter connects, the song playing fades out under them; their titles go to the play log, the show is recorded exactly as their encoder sent it, and when they disconnect the music comes back where the clock says.
A station doesn’t even need a streaming server. Station Server can be one itself: listeners connect to it directly, and it answers the status pages and playlist links as SHOUTcast and Icecast would. Settings › Internet then measures the connection’s upload and suggests how many listeners it can take, forwards the port on the router where the router allows it, and keeps a free Duck DNS name pointed at the connection.
Joined up: the Studio link and what’s on
A week can also travel over the network. With the link turned on, Station Studio sends a week straight to Station Server over the network, as the same iTunes XML it would export, and asks what each station is playing. Every request carries a link code; after five wrong codes an address is kept out for a few minutes, and making a new code retires the old one. Station Server checks each week and files it, then answers with the tracks it found and missed on its own computer, and when the week goes on: now, next, later, or never, for a week older than the one on air.
What’s on flows back the other way. Station Server publishes each station’s now, next and just played to a GitHub Pages site of the station’s own, with no file paths or addresses in it, for the station’s website and for Station Player. A logo set in Station Server turns up in Station Player. Station Server also reads playlists, tags and loudness with Station Player’s own code, so the two apps never disagree about what a week holds.
Paying down the copies: station-appkit
The shared code was copied first and consolidated later. Each app grew its own update check, self-updater and app window, written for whichever app needed it first and copied when the next one did. By the time they were brought together, the copies were 59 to 88% identical and had drifted apart. Studio’s app window had a fix the other two lacked, Station Server reopened the new version after a Mac update while the others could bring back the old one, and Station Player waited a day to retry an update check that had failed offline. The self-updater, the code that checks a download’s SHA-256, existed three times.
The one copy is now station-appkit. It uses only Python’s standard library; the Mac window also needs PyObjC, which only the downloaded Mac apps carry. Each app describes itself once (its name, release tag, port and Mac helper), and its own modules shrink to thin wrappers holding only what is its own, such as Station Player’s mini player or Station Server’s warning that quitting takes stations off air. Every fix now reaches all three apps, and the shared behaviour is tested once, in 42 tests, with the Mac window’s Python side run against stand-ins for PyObjC.
Sharing a package changed how releases work. PyPI never accepts a second copy of a version, so a release script asks PyPI before anything is published. If PyPI lacks that version of appkit, it goes up with the app; if PyPI holds the same code, it is left out; and if PyPI holds different code under that version, the release stops and says to bump it. A test checks each app’s download names and release tags against its packaging, so Update now finds exactly what the release workflows build.
The same round of work tidied the rest. Python dependencies are locked in one uv.lock, shared by CI, the installers and Docker. The design document was rewritten to describe the system as it is now, and its predecessor, about 16,000 lines of slice-by-slice decisions, is kept unchanged as a design log. The Player and Server guides joined the docs site, and Station Player’s page script, grown to one large file, was split into one file per part of the page.
Private by default
Everything is local by default. Each app listens only on 127.0.0.1. The features that open a door are switches, and each has a lock: Station Player’s phone remote a secret link that can be replaced, Station Server’s phone access a password with a lockout, the Studio link its code. Every API call must carry a header another website can’t send. The update check asks GitHub for release names and nothing else, and the self-updater installs only from the project’s own releases, and only a file whose size and SHA-256 match what GitHub publishes. Copied diagnostics leave passwords and the link code out.
Choices, made in the open
- Free to install, at the cost of one extra click. The downloads aren’t signed with a paid certificate, so the first open asks for Open Anyway on a Mac or Run anyway on Windows. The release notes, the READMEs and the Help pages all say so up front, so it is never a surprise.
- A station on one computer, with an outside check still advised. Station Server watches everything it can see from that computer, but can’t raise an alert from one that is off or offline, so its README recommends checking the stream from outside as well.
- A native window where it counts. The downloaded Mac apps open in a WebKit window of their own, with menus and a Dock icon; installed with pip or pipx, the same apps open in a Chrome, Edge or Brave app window instead, so nothing beyond Python is needed.
- One presenter live at a time. Live shows take one presenter at once. End live show takes them off and keeps their encoder from reconnecting for two minutes, and a show due while someone is live is left out.
How it was built
Directed, not delegated. Each change started as a request in a Claude Code project and came back as a pull request carrying the code, the tests and a written before and after: 127 merged so far. What to build next and when to release stayed human decisions, and so did the constraints the agent worked within, such as nothing reachable from the network unless the person turns it on.
Feedback set the order of work. A first session with the people at Rebirth Radio, the client Station Studio was built for, ran in two strands: ideation, the station’s own ideas for what a player should do, and productisation, what it would take for other people to install it, trust it and use it every day. It shaped the releases that followed, from radio song titles and gapless playback to installers that need no terminal. A second round, from friends trying the player, brought the genres they found missing from Find stations (0.12.0) and a batch of quick wins (0.21.0), and a request for more and better ambient scenes brought four new ones (0.23.0).
Reviewed like a colleague’s work, not trusted like a tool’s. Releases went through independent reviews, often several in parallel with different briefs. For Station Player 0.2.0 there were four, which found 23 issues, each fixed with a regression test that fails on the previous commit. Where the agent couldn’t check something from its sandbox, such as a real SHOUTcast server, the pull request said so in plain words. The installers are built and self-tested on Mac and Windows runners in CI. When station-appkit landed, the suites stood at 370 tests for Station Player, 235 for Station Server, 42 for station-appkit and 1,502 for Studio’s backend.
Across Player, Server and appkit, that comes to about 18,000 lines of Python and 9,600 of JavaScript, with no frontend framework, and 14,000 more lines of tests.
What it adds up to
A station’s week goes from rules to listeners in software, not through a cable. Studio makes the week and sends it over the link. Station Server plays it to the clock, evens out the levels, hands over to presenters and back, and tells the station’s website what’s on. Station Player is there for anyone listening, the station’s own people included. Rebirth Radio’s stations go out through Station Server today. One shared package keeps all three updating, opening and starting the same way, and changes to any of them arrive as pull requests with their tests and a written account of what they do.
The engine that makes each week, and the editing that has grown around it, is the Station Studio case study.
