r/webdev • u/Ornery-Carpenter5540 • 3h ago
Showoff Saturday [Showoff Saturday] Live shortwave radio in the browser: a three.js globe of public receivers, a WebSocket relay, and a waterfall you can orbit
I've been building SkyDial (https://www.skydialradio.com), a page for listening to live shortwave through public KiwiSDR receivers. KiwiSDRs are small software-defined radios that volunteers leave open on the internet, and each one streams audio and spectrum data over a WebSocket. A few parts were more interesting to build than I expected:
71-second video: the globe's day/night shader, the 3D waterfall being orbited, and Find a voice landing on a ham chat in real time. Real radio audio, no voiceover.
The globe. three.js, one sphere with a small custom shader. Where the sun is overhead comes from the low-precision almanac formulas (about ten lines of JS), passed in as a uniform, and the fragment shader darkens the night side and adds a faint warm band along the terminator. Hams call that band the grey line, and signals do odd things along it, so it's actually useful and not just decoration. Coastlines are Natural Earth 1:110m baked into the page; the 1:50m set with state lines loads the first time you zoom in.
The waterfall. Each spectrum row (about 10 a second) is written into a DataTexture used as a ring buffer, and a 512x192 vertex plane displaces itself from that texture in the vertex shader, so the last few seconds of spectrum become terrain you can orbit. Rows come through the relay unevenly, anywhere from 60 to 220 ms apart, and moving the terrain one row per arrival looked jerky. Now the drawn terrain glides toward the newest row at the measured arrival rate, kept about 1.5 rows behind to soak up the jitter.
The relay. Most receivers only speak plain ws:// on port 8073, and an https page can't open that. So there's a small Node server (ws is its only dependency) that opens the connection on the browser's behalf. A server that connects to arbitrary hosts for strangers is basically an open proxy, so most of its code is guarding: only hosts that are in the public receiver directory, never private or LAN addresses, socket and bandwidth caps per IP and per network (/24, and /48 for IPv6, since one free IPv6 tunnel is 65,536 /64s), and a daily data budget, because it runs on Render and bandwidth is billed past the free tier. Audio arrives as IMA ADPCM and is decoded in the page.
Find a voice. It scans the ham bands and stops when it hears someone talking. Candidates come from the waterfall (energy in an SSB-width slice above the noise floor, skipping the FT8 and Morse segments). It tunes each one for a few seconds and scores the audio: loudness swinging at syllable rate (2 to 8 Hz), a pitch that keeps moving, and a cepstrum peak at the pitch period for voice harmonics. The thresholds came from recordings of real conversations and real band noise. Before the cepstrum check it was announcing noise about half the time. The FFT is hand-rolled; no audio libraries.
Supabase handles the optional accounts (email link or 6-digit code), the log book, favorites, and the relay's state across restarts, since Render's free disk is wiped every time it sleeps.
The page is one index.html of about 5,100 lines with no framework and no build step; three.js and supabase-js are vendored. Tests are node:test plus Playwright driving the real page against fake KiwiSDR receivers that speak enough of the protocol to play a test tone, send waterfall rows, and act full, silent, dropping or down on cue.
It's free and has no ads, and listening needs no account. The relay is the one part that costs me money (about 45 MB per listener-hour), so relayed listening is capped at 30 minutes a day signed out and 3 hours with a free account. The few receivers that serve wss:// connect straight from the browser and aren't counted at all.
Happy to go into any of it. The single-file part is either a strength or a crime depending on who you ask.