A tick goes in. A song comes out, the same for everyone, on every device.
Radio Engine has no music files and no stream. Every song is composed in the listener's browser from three numbers: the Qubic tick, a station and a seed. This page shows the whole formula, step by step, and how to put the stations in your own apps, games and websites for free.
The formula
The clock: Qubic ticks
The Qubic network moves forward in ticks, roughly one a second. Radio Engine reads the current tick from the public RPC (rpc.qubic.org/v1/tick-info) and cuts time into song windows of 300 ticks, so a new song starts on every station about every five minutes.
window = Math.floor(tick / 300)
Reading the live tick…
The seeds: three numbers become a few more
Each station has a fixed salt (a small number of its own) and the site has one world seed. Mixed with the window they give four seeds, each driving a different part of the song, so changing one part never shifts the others.
SEED = 0x2922A723 // the site's world seed salt = SALT[station] // see the station table below songDice = (SEED ^ salt ^ Math.imul(window + 1, 0x9E3779B1)) >>> 0 // the composer's choices playing = (SEED ^ 0x5EC7 ^ window ^ salt) >>> 0 // bar-by-bar playing stems = (SEED ^ 0x5EC7 ^ window ^ Math.imul(salt, 0x9E37)) >>> 0 // each stem's own stream, analog drift arrange = (SEED ^ 0xA77 ^ salt ^ Math.imul(window + 7, 0x85EBCA6B)) >>> 0 // which parts play in which section
0x9E3779B1 is the golden ratio as a 32-bit number. Multiplying the window by it scatters neighbouring windows far apart, so song 1,000 and song 1,001 have nothing in common.
The dice: mulberry32
A seed feeds a tiny, fast random number generator. Same seed, same sequence, on any computer, in any browser. That is the whole reason everyone hears the same song.
function mulberry32(a){
return () => {
a |= 0; a = (a + 0x6D2B79F5) | 0;
let t = Math.imul(a ^ (a >>> 15), 1 | a);
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
return ((t ^ (t >>> 14)) >>> 0) / 4294967296; // 0 ≤ x < 1
};
}
The composer: rolls, in a fixed order
The song dice are rolled in the same order every time. Each roll picks from a list written for that style, so every choice is one a real arranger of that genre might make.
- Style. Each station has a weighted list of styles (Bunker 138 plays minimal, acid, peak-time techno and more). A roll picks one by weight.
- Tempo and swing. From the style's range, e.g. 172–176 BPM for dark-step drum & bass, or 84–104 for bossa. Swing is how late the off-beats land.
- Key and mode. A key, and a mode from the style's list (ionian, lydian, dorian, mixolydian, aeolian, phrygian). Only modes that suit the style are allowed, so nothing clashes.
- Chords. A progression from the style's own pool, or, 55% of the time outside jazz and opera, a fresh one generated by walking a map of chords that naturally follow each other. A further roll decides whether chords change every bar or every two.
- The band / The producer. A lead instrument and a second one for answers and solos, a chord instrument and a bass sound, all from the style's lists, plus a drum kit and a groove.
- The melody. Four two-bar phrases. Strong steps land on chord tones, weak steps move by scale steps between them, and rests are rolled in, so the tune always sits on the harmony.
- The name. A title and an artist are built from word lists, in several languages, for the style. Every name is 100% fictional: no real artist, band or song is used or meant. The word lists may contain real places and things (a space probe, a city), but the artists and songs are invented, and any resemblance to a real artist or song is a coincidence.
The arrangement: sections and stems
A song is a run of sections, each 8 bars long (4 bars below 60 BPM), enough of them to fill about five minutes. The arrangement seed decides which of nine stems play in each section:
- Intro (section 1): the bed, light percussion 60% of the time, a lead 30%, effects.
- Breakdown (every fourth section): the bed, light percussion, the second lead, effects. No drums.
- Everything else: the bed, drums and effects, the lead 85% of the time (Jungle Pressure FM keeps it to 30%: drums and bass first), light percussion 25%.
- Each stem has an A and a B version. B reworks the melody a little, so repeated sections never sound copied.
Same for everyone
Every note, every drum hit, every effect and every small "analogue" wobble comes from those seeds. The only true randomness is the grain of the noise used for hi-hats, wind and static, which is texture, not music. Open the same station on a phone in Sheffield and a laptop in Tokyo in the same window and they play the same song, note for note.
Try it: run the formula
Pick a station and a tick (or use the live one) to see every decision the composer makes.
The band / The producer: synthesis and mixing
There are no samples. Every sound is built from oscillators and noise with the Web Audio API: around 220 named sounds, from flutes, Rhodes and timpani to 808s, Reese basses, supersaws and breakbeats chopped from synthesised kits. The Sound Lab lets you play each one.
- Rendering. Each stem is rendered ahead of time in an offline audio context, at 44.1 kHz on computers and 32 kHz on phones, a section at a time. The next song renders while this one plays.
- Each stem's channel strip. A low cut set by its job (so only the bass and kick own the low end), a dip at 320 Hz where mud piles up, a presence lift, gentle tape-style warmth, light glue compression and a little air. Pads share a bus that clears 300–600 Hz.
- Space. A stereo hall reverb generated from a seed, a ping-pong echo on the dotted eighth, and for dub and its cousins, a tape delay with wow and flutter.
- The master. A 40 Hz low cut, the bass tamed (−4 dB shelf at 180 Hz, −2.5 dB at 110 Hz), +1.5 dB presence at 3 kHz, +2 dB air at 9 kHz, soft saturation, 3:1 glue compression and a limiter, so it's loud without clipping.
Station tables
Each station's salt, and the styles it plays with their odds. These tables are read straight from the engine.
| Station | id | Salt | Styles (chance) |
|---|
Player SDK: the stations in your own page or game
Free, no sign-up needed to play the stations. One import, and the songs are composed on your visitors' devices, so it costs you nothing in bandwidth. Add an API key to tweak stations, instruments and play your own Sound Lab sounds.
<button id="play">Play</button>
<script type="module">
import { createRadio } from 'https://radio-engine.com/sdk/v1/radio-engine.js';
const radio = await createRadio({ station: 'house', key: 're_your_key_here' }); // key is optional
radio.on('song', s => console.log(`Now playing "${s.title}" by ${s.artist}`));
document.querySelector('#play').onclick = () => radio.play(); // needs a tap or click
</script>
Options
| Option | What it does | Default |
|---|---|---|
station | Which station: | 'ambient' |
key | Your API key. Loads your saved Sound Lab set (new sounds and knob settings). | none: the stations as they come |
sounds | A sound set object (e.g. an exported sounds.json) instead of a key. | none |
window | A fixed song window. The same song every time: handy for a game level or a menu theme. | live: follows the Qubic tick |
volume | 0 to 1. | 0.8 |
context | Your own AudioContext, to share one with your game. | its own |
destination | An AudioNode to send the music into (your music bus, a ducker…). | context.destination |
quality | 'high' (44.1 kHz), 'low' (32 kHz) or 'auto'. | 'auto' (low on phones) |
The player
| Method or event | What it does |
|---|---|
play() / stop() | Start (call it from a tap or click) and stop, with a short fade. |
tune(station, window?) | Change station, live or to a given window. |
next() | Skip to the next song window. |
setVolume(v) | 0 to 1, smoothed. |
nowPlaying() | Title, artist, style, BPM, key, mode, window and length of the current song. |
on('song' | 'section' | 'state' | 'error', fn) | Events. state is loading, playing or stopped. Returns a function that removes the listener. |
output | The player's output GainNode. |
destroy() | Stop and free everything. |
Without a player you can also ask what's on: songAt(station, window) and await nowPlaying(station) return the title, artist and style straight from the formula, and STATIONS lists every station.
Embed: a player in one line
For any site where you can paste HTML (WordPress, Wix, Squarespace, Webflow, a blog, a forum signature) you don't need any code of your own. Paste this where you want the player:
<iframe src="https://radio-engine.com/embed.html?s=jazz"
width="420" height="80" style="border:0;border-radius:14px"
title="Radio Engine"></iframe>
That's a dark player tuned to Space Jazz. Your visitors press play, and can switch station and change the volume in the player.
Settings in the address
Everything after the ? in the address sets the player up. Join several settings with &; leave out any you don't need.
| Setting | What it does | Example |
|---|---|---|
s | The station it starts on. Without it: Space Ambient. | s=dnb |
key | Your API key from the account page: the player uses your Sound Lab sounds. Without it: the stations as they come. | key=re_AbC… |
theme | light for a light player (for white or pale pages). Without it: dark. | theme=light |
w | A fixed song number (a window). The player always plays that one song instead of the live radio. Find a song's number with the calculator above, or under "Recently played" on the radio. | w=5988622 |
Examples
A light player on Radio Caliente, for a pale web page:
<iframe src="https://radio-engine.com/embed.html?s=latin&theme=light"
width="420" height="80" style="border:0;border-radius:14px" title="Radio Engine"></iframe>
Thrash Forge 666 with your own sounds (your key limited to your website, so nobody can copy it elsewhere):
<iframe src="https://radio-engine.com/embed.html?s=metal&key=re_PASTE_YOUR_KEY_HERE"
width="420" height="80" style="border:0;border-radius:14px" title="Radio Engine"></iframe>
One song that never changes, e.g. as the theme for a portfolio or a game's website:
<iframe src="https://radio-engine.com/embed.html?s=trance&w=5988622"
width="420" height="80" style="border:0;border-radius:14px" title="Radio Engine"></iframe>
Build your player
Choose the settings and copy the code. The preview is the real player.
Sound set API
Your saved Sound Lab set, as JSON, for your own players or tools. Make a key on your account page (it's free; confirm your email first).
GET https://radio-engine.com/api/v1/sounds.php
X-Api-Key: re_your_key_here
200 OK
ETag: "4f0c…"
{ "v": 1,
"tweaks": { "lead:sax": { "vol": -3, "echo": 0.2 } },
"patches": [ { "id": "p1a2b3c4d5", "name": "Acid bass", "role": "bass", "stations": ["techno"], "often": 0.5, … } ],
"updated": 1765050000 }
- Keys are read-only: they can only read your sound set, so they're safe in a web page. Limit a key to your websites (e.g.
https://mygame.com) on the account page; calls from any other site are refused. - Caching: send
If-None-Matchwith the last ETag and you get304 Not Modifiedwhen nothing changed. - Limits: 1,000 requests an hour per key and 300 an hour per IP address. The SDK asks once per page load.
- Errors:
401unknown or revoked key,403not allowed on this website,429slow down (seeRetry-After). Bodies are{ "error": "…" }.
In games and apps
- Share your AudioContext (
context) and send the music into your own bus (destination) to duck it under dialogue or fade it between scenes. - One song per level: pass
window: 1000 + level. It will always be the same song for every player. - Live radio in a hub: leave
windowout and the station follows the Qubic tick, so every player online hears the same song. - Native apps (iOS, Android, desktop): load your page or the embed in a web view. The music is made by the web view's audio engine.
- Start on a tap: browsers only allow sound after the user interacts, so call
play()from a click, tap or key press.
Examples you can copy
Each one works as it is: paste it into a page (or your game's code) and change the station to taste. Station ids are listed in the station table.
A "play the radio" button on your page
The smallest useful page: a button that starts a station, and the song name shown when it starts.
<button id="play">▶ Play the radio</button>
<p id="now"></p>
<script type="module">
import { createRadio } from 'https://radio-engine.com/sdk/v1/radio-engine.js';
const radio = await createRadio({ station: 'house' });
radio.on('song', s => {
document.getElementById('now').textContent = `"${s.title}" by ${s.artist}`;
});
document.getElementById('play').onclick = () =>
radio.playing ? radio.stop() : radio.play();
</script>A station picker
A drop-down of every station. Changing it retunes straight away.
<select id="station"></select> <button id="play">Play</button>
<script type="module">
import { createRadio, STATIONS } from 'https://radio-engine.com/sdk/v1/radio-engine.js';
const pick = document.getElementById('station');
for (const s of STATIONS) pick.add(new Option(`${s.name} · ${s.freq} FM`, s.id));
const radio = await createRadio({ station: pick.value });
document.getElementById('play').onclick = () => radio.play();
pick.onchange = () => radio.tune(pick.value);
</script>"Now playing" text, no audio
Show what a station is playing (for a sidebar, a stream overlay or a status page) without playing anything. It refreshes every 30 seconds.
<p id="np">…</p>
<script type="module">
import { nowPlaying } from 'https://radio-engine.com/sdk/v1/radio-engine.js';
async function show() {
const s = await nowPlaying('dnb');
document.getElementById('np').textContent =
`${s.stationName}: "${s.title}" by ${s.artist} (${s.style}, ${s.bpm} BPM)`;
}
show(); setInterval(show, 30000);
</script>A game: one song per level, quieter under dialogue
The music runs through your own audio graph. Each level gets its own song, the same for every player, and you can turn it down while characters talk.
import { createRadio } from 'https://radio-engine.com/sdk/v1/radio-engine.js';
const ctx = new AudioContext(); // your game's audio context
const music = ctx.createGain(); // a music bus you control
music.connect(ctx.destination);
let radio = null;
export async function startLevel(level) {
if (radio) radio.destroy();
radio = await createRadio({ station: 'trance', window: 1000 + level, context: ctx, destination: music });
await radio.play(); // call startLevel from a click or key press the first time
}
export function duck(on) { // duck(true) while dialogue plays
music.gain.setTargetAtTime(on ? 0.25 : 1, ctx.currentTime, 0.3);
}A game hub where everyone hears the same radio
Leave out window and the station follows the Qubic tick, so every player in the lobby hears the same song. Add a skip button with next().
const radio = await createRadio({ station: 'rave', volume: 0.6 });
lobbyMusicButton.onclick = () => radio.play();
skipButton.onclick = () => radio.next(); // skips for this player only
radio.on('section', s => console.log('now in the', s.name)); // intro, verse, breakdown, outroYour own sounds without a key
Exported a sounds.json from the Sound Lab? Host it next to your page and pass it in. No account needed.
const sounds = await (await fetch('/sounds.json')).json();
const radio = await createRadio({ station: 'dub', sounds });React
Load the SDK inside a component and clean it up when the component goes. The comment stops Vite or webpack trying to bundle a web address.
import { useEffect, useRef, useState } from 'react';
export function RadioButton({ station = 'house' }) {
const radio = useRef(null);
const [song, setSong] = useState(null);
useEffect(() => {
let alive = true;
import(/* @vite-ignore */ /* webpackIgnore: true */ 'https://radio-engine.com/sdk/v1/radio-engine.js')
.then(async ({ createRadio }) => {
const r = await createRadio({ station });
if (!alive) return r.destroy();
r.on('song', setSong);
radio.current = r;
});
return () => { alive = false; radio.current?.destroy(); };
}, [station]);
return (
<button onClick={() => radio.current?.play()}>
{song ? `${song.title} · ${song.artist}` : 'Play'}
</button>
);
}Your sound set from a server or script
Calls from a server have no website address, so they work even with a key limited to your websites.
curl -H "X-Api-Key: re_PASTE_YOUR_KEY_HERE" https://radio-engine.com/api/v1/sounds.php
# Node 18+
const r = await fetch('https://radio-engine.com/api/v1/sounds.php', { headers: { 'X-Api-Key': process.env.RADIO_ENGINE_KEY } });
const set = await r.json(); // { v, tweaks, patches, updated }iOS and Android apps
Show the embed player in a web view. Inside an app there is no website address to check, so use a key without website limits here (make a separate one just for the app).
// iOS (Swift, WKWebView)
let config = WKWebViewConfiguration()
config.allowsInlineMediaPlayback = true
let web = WKWebView(frame: view.bounds, configuration: config)
web.load(URLRequest(url: URL(string: "https://radio-engine.com/embed.html?s=house")!))
view.addSubview(web)
// Android (Kotlin, WebView)
webView.settings.javaScriptEnabled = true
webView.loadUrl("https://radio-engine.com/embed.html?s=house")Fair use
The names are fictional. Every song title and artist name is generated by the formula. None of them is a real artist, band or recording, so please don't present them as real ones (for example, don't credit an invented artist as a real person in your game or app).
The SDK, the embed and the API are free for personal and commercial projects. A credit such as "Music: Radio Engine (radio-engine.com)" is appreciated. Please don't hammer the API (cache it, as the SDK does), don't pass off other people's shared sounds as your own, and keep keys limited to your own websites. The service comes as it is; we may change limits to keep it free for everyone.