Rotation Science: How LOKLOK Compares to a Traditional Radio Station Pipeline
This page is a guided, scientific tour of radio rotation — the logic that decides what plays next — and a rigorous comparison between how a conventional broadcast station pipelines its music and how LOKLOK does it. It is written for radio engineers who want to map LOKLOK onto the mental model they already have, and for software engineers who want to understand why "radio" has its particular constraints.
It is a companion to Broadcast Audio Science (the audio physics) and Equations & Math Reference (the closed forms). Full APA references: References.
1. What a "rotation" is, scientifically
1.1 The formal problem
A rotation is a constrained ordering problem: place a finite library of tracks into a sequence such that (a) no track repeats too soon, (b) the mood, energy, and genre distribution track a target profile, (c) branding elements (jingles, sweepers, ads, news) recur at predictable intervals, and (d) the listener never experiences a jarring transition or dead air. This is a constrained optimization over a rolling window, not a simple shuffle.
Formally, at each slot the scheduler chooses a track from a deck subject to a repeat-suppression constraint and a target distribution:
where is time since last played and is the target genre weight. Section 5 of this page shows the LOKLOK closed form (Equations §4, §7).
The key word in the formulation is constrained. Unconstrained optimization of "what the listener most wants to hear right now" produces a Spotify-style playlist; constrained optimization of "a broadcast hour that is balanced, varied, on-brand, and safe" produces radio. The difference is not in the scoring function — it is in the constraints that the score must respect. Every design decision on this page is a decision about which constraints to encode and how hard to enforce them.
1.2 Why radio can't be a simple shuffle
A pure random shuffle of a large library gives excellent diversity but terrible memorability — listeners cannot anticipate the station's identity, and two songs by the same artist can land back to back. Randomness alone also produces clumping: any truly random process will, by the nature of distributions, occasionally produce bursts of the same category (five rap songs in a row, three ballads, a repeat within minutes). Statistically these bursts are expected in an unconstrained shuffle, and perceptually they are exactly the artifact listeners describe as "the station keeps repeating" (Keith, 2010).
The radio industry's answer, developed over ~60 years, is structured rotation: a small set of high-rotation "power" tracks + medium-rotation "hot" tracks + a deep library of recurrents and gold, with category-based clocks (the hour template that decides how many of each category play per hour) (Keith, 2010; Norberg, 1996). The rotation is the product — the familiar mix that lets a listener predict the station's character — and the clock is the mechanism that keeps the rotation balanced over time.
LOKLOK generalizes this: instead of hard categories (P1/P2/Hot/Recurrent/Gold), it uses weighted genre decks with cooldowns, and instead of a fixed clock template it uses sampled proportions — so the hour structure is preserved statistically but never literally repeated (see Equations §2). The power/hot/gold hierarchy is replaced by a uniform "every song equal after its cooldown" policy, which trades the radio staple of "hear the big hit four times a day" for a wider, less predictable library. That is a product choice, not a technical limitation; LOKLOK could implement a power-rotation class simply by lowering a cooldown for a flagged subset.
2. The traditional radio station pipeline
2.1 The players and their roles
A conventional music radio station is a set of specialized functions, each with a mature commercial tool. Understanding the traditional division of labor makes the LOKLOK mapping immediate:
| Function | Tool (typical) | LOKLOK equivalent |
|---|---|---|
| Music library & metadata | MusicMaster, GSelector, MediaMonkey | content-pipeline.js + meta_registry.json |
| Rotation / clock building | RCS GSelector, MusicMaster, WideOrbit Automation | smart-scheduler.js |
| Category scheduling (adherence to clock) | RCS Selector / GSelector | updateM3U cadence slots (AD_EVERY, NEWS_EVERY, MASHUP_EVERY) |
| Playout / automation | WideOrbit, ENCO, RCS Zetta | Liquidsoap (radio_worker.liq) |
| Delivery | Transmitter / satellite / codec | Icecast OGG + MediaMTX HLS |
| Monitoring | EAS, silence detection, remote logging | server.js health probes, watchdog, verifyRemoteRotation |
(Keith, 2010; Norberg, 1996)
The crucial observation: a commercial station buys five separate products (library manager, scheduler, automation, delivery, monitoring) and wires them together with export formats, file shares, and logs. LOKLOK is one codebase implementing all five. The cost is that LOKLOK's components must each be as robust as a mature commercial product; the benefit is that they share state, speak the same formats natively, and — most importantly — can be changed together. In a traditional pipeline, adding a new rule to the scheduler does not automatically teach the library manager what to fetch; in LOKLOK it can.
2.2 The classic clock
A "clock" in radio is a one-hour template of what plays when. A typical modern music clock might be: 6 songs, 2 imaging elements, 2 ads, 1 news break, rotated so ad positions are fixed and songs fill the gaps. The scheduler's job is to fill each song slot from the correct category rotation without violating the no-repeat rule (Norberg, 1996).
The clock is the spine of traditional scheduling. It exists because:
- Advertisers buy positions — an ad at a fixed minute has a contractual value that a shuffled position does not.
- Pacing is a perceptual phenomenon — a listener subconsciously expects breaks at roughly predictable intervals; a clock delivers that.
- Energy flow is engineered — the clock positions sweeps (music run-ups to a break) and stop-sets (the ad break) so the music always returns on a high note (Keith, 2010).
The strict version of this is a hard clock: category counts per hour are mandatory. The problem with hard clocks is that they are deterministic — the same category sequence repeats hour after hour, which listeners can perceive as repetitive (Keith, 2010). The industry's own answer is a varied clock: the category counts stay fixed, but the rotation lists feeding each category slot are shuffled and the category order is jittered so no two hours are identical. Even so, the fundamental structure — this exact number of songs, this exact number of stopsets, in this exact order — repeats every hour.
LOKLOK's answer is a soft clock: AD_EVERY, NEWS_EVERY, MASHUP_EVERY,
and the signature-jingle cadence reserve slots, but the music in between is
chosen by a stochastic, distribution-matched sampler. Ad placement stays
"radio-predictable" (roughly every 8th slot), but the hour never literally
repeats. The fixed structure that advertisers value is preserved (there is an
ad every ~8 slots), while the content between anchors is free to vary in a way
a hard clock never allows.
2.3 The repeat rule: "don't repeat within the hour" and the gold mine
The oldest rule in radio music scheduling is the hour rule: never repeat a song within one hour. Gold/recurrent scheduling extends this: a song in heavy rotation might play 2–4 times per day, at least 2 hours apart; library tracks may play once a day or less (Norberg, 1996). The rule is a recency-based mechanism: the goal is not to minimize repetition absolutely, but to guarantee a minimum separation between plays so that no listener who listens for an hour ever hears the same song twice, and the perceived variety stays high.
LOKLOK implements the rule as a time-based cooldown rather than a position-based one. The two are subtly different in behavior: a position-based rule ("not in the same hour template") can still allow a 55-minute gap between consecutive plays if the track straddles a boundary; a time-based rule ("90 minutes since last play") guarantees a true 90-minute gap regardless of where the hour boundaries fall.
| Traditional rule | LOKLOK implementation |
|---|---|
| No repeat within the hour | COOLDOWN_PERIOD 90 min (songs) |
| Power tracks get 2–4 plays/day | Cooldown is uniform — no "power" class; every song is equal after 90 min |
| Imaging can recycle freely | ELEMENT_COOLDOWN 10 min (jingles/sweepers/ads/sfx/news) |
| Rotation rebuild must not replay the just-played head | MUSIC_FRESH_MS 3 h + markOnAirTrack / lastTrackPlayed guard |
The LOKLOK cooldown is also persisted to disk (scheduler_antirepeat.json),
which is a qualitative improvement over a traditional station's in-memory
recent-history table: a traditional station that reboots its scheduler
immediately forgets what it just played and can legally repeat the last song; a
LOKLOK reboot loads the persisted history and cannot. (see
Smart Scheduler).
2.4 Dayparting
Traditional radio dayparts the playlist by hour blocks: morning drive is upbeat, daytime is mainstream, evenings are niche, overnights are lighter on talk-heavy songs (Keith, 2010). The daypart is a business decision as much as a musical one — advertisers buy specific dayparts, and the morning drive audience is different from the late-night audience. The musical consequence is that each daypart has its own clock and its own rotation lists, loaded at the boundary.
LOKLOK dayparts by weight multipliers and — for deep night — a hard English-only gate (see Equations §3).
| Traditional dayparting | LOKLOK dayparting |
|---|---|
| Fixed clock per daypart | Per-category weight multipliers per window |
| Hard change at daypart boundary | Daypart-stamped rotation + 60 s watchdog rebuild |
| Morning = "power songs" | Morning boost to arabic_hits ×2.2 and english ×2.0 |
| Deep night = "gold, no current hits" | Deep night = English ×8.0 hard gate |
The critical operational difference is the daypart boundary trigger. A traditional station switches its clock at a set time; if the music log was generated before the boundary, the on-air rotation keeps playing the old daypart's mix until the log catches up. LOKLOK stamps every rotation with the daypart profile that built it and force-rebuilds the moment the profile changes — the deep-night "Arabic leaks" bug was exactly a stale rotation built under an earlier daypart (see Smart Scheduler).
The boundary trigger deserves emphasis because it is the difference between a schedule and a rule. A traditional station schedules the daypart change at a clock time and hopes the log rotation aligns. LOKLOK treats "the daypart profile that would be used right now" as an invariant and rebuilds the moment it is violated — the rotation can never be more than 60 seconds out of daypart.
2.5 Imaging, sweepers, and the "sound of the station"
A traditional station's imaging (IDs, jingles, sweepers, stingers, promos) is produced by a jingle house or in-house production, delivered as finished audio, and loaded into the automation system as another asset type with its own clock positions (Keith, 2010). LOKLOK does not buy imaging — it synthesizes it. The imaging engines (see Imaging Engine, Fun Jingles, Bulletin Engine) generate voice-over-music sweepers, layered stingers, karaoke-style jingles, and spoken news bulletins, all loudness-mastered to the same broadcast target. The scientific implications are covered on the Broadcast Audio Science page; the comparative implication is that LOKLOK's imaging is regenerable — a traditional station cannot re-sing a sweeper on demand, LOKLOK can regenerate any of its imaging assets in seconds.
3. The modern algorithms LOKLOK adds
A traditional station pipeline is largely rule-based: clocks + category + recent-history tables. LOKLOK layers three classes of algorithm on top that a conventional station does not have:
3.1 Stochastic, distribution-matched category selection
Instead of a deterministic clock, the category is drawn from a Dirichlet
distribution. The Dirichlet is the natural prior for "a distribution of
distributions" — it is the conjugate prior for the multinomial, and drawing from
it gives proportions that wobble around the mean without collapsing to a single
category (Blei, Ng, & Jordan, 2003). With concentrations ,
each draw is
(Equations §2). Over an hour the realized mix stays near the
configured GENRE_SPLIT, but no two hours are identical.
Why does the wobble matter? Because the perceived variety of a station is a function of the sequence of categories, not the average proportions. A hard clock plays the categories in a fixed proportion but with a fixed pattern; a Dirichlet sampler plays them in the same long-run proportion but with a different path every hour. Two listeners who each hear one hour get the same composition but different experiences. That is the entire point of the design: constraint-compliant variety.
3.2 Anti-fatigue proportional control
The scheduler tracks the observed category frequency over the last 12 plays and nudges the weight toward the gap — a proportional controller on "we played this category too much vs. target":
This is textbook negative feedback (Åström & Murray, 2021): the error signal is , the controller gain is 0.5, and the clamp at 0.02 prevents any category from being starved to zero. Traditional clocks have no equivalent — they rely on the fixed hour template to maintain balance.
The feedback loop is what makes the sampler stable rather than merely stochastic. Without the correction, a random run of too many rap tracks would simply ride out until the distribution "self-corrected" statistically — which can take hours. With the proportional term, the controller actively counteracts the deviation within the next few draws. The gain 0.5 is deliberately less than 1 (a full correction each step would overcorrect into oscillation); the 0.02 floor guarantees even a heavily-overplayed category remains available, so the rotation can never hard-stall for lack of an eligible category.
3.3 Reinforcement learning over mood arms
LOKLOK's scheduler ships a Thompson-sampling bandit over three mood arms (CHILL / BALANCED / PARTY). Thompson sampling chooses an action with probability equal to the posterior probability that it is optimal — it balances exploration and exploitation automatically and is well-studied in the bandit literature (Thompson, 1933; Russo et al., 2018). The reward signal is listener behavior: growing listener count or a hype vote counts as success. This is the one place LOKLOK genuinely departs from any traditional pipeline — the station learns which mixes keep listeners rather than assuming them (Russo et al., 2018; see Equations §9).
The intellectual history is worth naming. Thompson sampling dates to 1933 (Thompson, 1933), was formalized as a bandit strategy in the multi-armed bandit literature, and enjoyed a revival in the 2010s as a scalable exploration strategy for recommender systems (Russo et al., 2018). What is novel here is not the algorithm but its application domain: a broadcast music scheduler where the "actions" are whole-program mood policies and the "reward" is a living audience metric. Traditional radio tunes by committee and research panels — slow, sampled, human. LOKLOK tunes continuously, in production, from the actual listener telemetry. The three arms are the station's personality range; the sampler decides, hour by hour, which personality the audience is currently rewarding.
4. Sequencing rules compared, side by side
| Concern | Traditional radio | LOKLOK |
|---|---|---|
| What order | Fixed clock + category rotation | Sampled category + scored candidate pool |
| Repeat control | Hour rule + rotation lists | Time cooldown (90 m) + song-key dedup + persisted history |
| Artist spacing | Manual "no two same-artist" lists | ARTIST_GAP 12 slots (~40 min) |
| Genre balance | Per-hour category counts | Dirichlet weights + anti-fatigue controller |
| Imaging recurrence | Fixed clock positions | Cadence slots (AD_EVERY/NEWS_EVERY/MASHUP_EVERY) + stochastic sig cadence |
| Daypart change | Scheduled clock switch | Daypart-stamped rebuild + 60 s watchdog |
| Listener adaptivity | None (assumed mix) | RL mood arms (Thompson sampling) |
| Log granularity | 1-hour logs | 120-track rolling rotation, refresh at 85% consumed |
| Persistence across restart | Full library scan | Anti-repeat state persisted to JSON |
| Imaging source | Purchased jingle packages | Synthesized, regenerable on demand |
The net effect: LOKLOK preserves every constraint a traditional station engineer cares about (no repeats, artist spacing, imaging cadence, dayparting, dead-air safety) while adding statistical variety and listener-driven adaptation that fixed clocks cannot provide. The comparison is not "better vs. worse" — a commercial station's strength is predictability and brand control, which a human-programmed clock delivers perfectly. LOKLOK's strength is adaptivity and scale: it runs 24/7 with no programmer on shift, heals its own rotation, regenerates its own imaging, and learns from its audience.
5. The rotation lifecycle, end to end
- Decks — each category (arabic_hits, egyptian_trends, arab_techno, english, ads, news, jingles, sweepers, sfx, mashups) is a directory of loudness-normalized, tagged, deduped audio files. Decks are the LOKLOK equivalent of a traditional station's category libraries (power/hot/gold), but they map to genres and content roles rather than rotation classes.
- Refresh — the content pipeline tops decks to their caps and the pool health monitor restores any deck below 50% of cap (see Content Pipeline). This is the LOKLOK analogue of a music director loading new music into the library — automated.
- Build —
updateM3U(force)rebuilds the rotation from shuffled snapshots of each deck;popFrompicks the least-recently-aired eligible track; cadence slots inject imaging; the M3U is padded to a fixed 32768 bytes. This is the LOKLOK analogue of "building the log" — automated and constraint-checked. - Push —
radio-engine.jspushes the rotation to the remote via HTTP pull, one inode-preservingddwrite so Liquidsoap reloads exactly once. - Play — Liquidsoap watches the file, crossfades music, hard-cuts imaging,
and POSTs
/metadatafor each on-air track. - Observe —
markOnAirTrackrecords the just-played track (authoritative), advancingrotationConsumed; the 85% consumption or daypart change triggers the next rebuild; the 60 s watchdog covers boundary crossings.
The full operational guide — how to force a rebuild, why the rotation is kept stable, the inode-freeze trap — is in Operations guide.
6. Frequently asked questions
Q: Why is the on-air rotation only 120 tracks? Isn't that too small? A: 120 tracks ≈ ~5–6 hours at ~3.5 min each. It is a rolling window, not the library. It is deliberately kept small so the anti-repeat state can see the whole window; the library is thousands of tracks. Rebuilding at 85% consumed keeps the head fresh and the tail filled. (see Equations §11)
Q: Why does the rotation rewrite so rarely? A: Liquidsoap reloads the M3U on every in-place write and restarts from the head. Rewriting often replayed tracks listeners had just heard — the original "repeating songs" complaint. The rotation is therefore rewritten only on real consumption or daypart change (see Smart Scheduler).
Q: Does "sampled category" mean the mix is random? A: No. It means the mix is drawn from the configured distribution, then anti-fatigue, cooldowns, artist spacing, cadence slots, and candidate scoring are all applied on top. The randomness is in which distribution-respecting path is taken, not in whether the target distribution is respected.
Q: How is this different from a "smart shuffle" like Spotify's? A: Spotify-style recommendations optimize for listener satisfaction per track using collaborative filtering (Ricci et al., 2011). LOKLOK optimizes for broadcast constraints first: no repeats, artist spacing, imaging cadence, dayparting, dead-air safety. Satisfaction is folded in only through the RL mood arms. The constraints are the product; the recommendations are the seasoning.
Q: What does a traditional radio station do that LOKLOK can't? A: Human judgment. A live programmer can react to breaking news, read the room, ad-lib a liner, or spike a song that suddenly feels wrong. LOKLOK's rule system can encode "ban these songs," "boost this genre now," and "skip to the next track," but it cannot understand a moment. The practical mitigation is the control plane: an operator with a phone can force-skip, force-play, rebuild, or take the channel fully live in seconds (see Station Control).
Q: How many distinct songs does a listener actually hear? A: The steady-state distinct count per 6-hour block lands in the 50–70 range: a 6-hour window fits ~100 song slots, but the 90-minute cooldown means each song can only return after 90 minutes, so the working set is roughly ≈ 100 × 1.5 / 6 ≈ 25 songs in the repeating tier, plus the never-repeating remainder from the deep library. See Equations §10 for the derivation.
Related
- Equations & Math Reference — the closed-form mathematics.
- Smart Scheduler — the implementation.
- Rotation Operations Guide — the operational manual.
- Broadcast Audio Science — psychoacoustics & standards.
- References — APA reference list.