Lyrion Playground

Genres

How a library of thousands of albums gets a clean, browsable set of genres, from raw database labels to three tiers, and how Lyrion reads the result.

Genre is the single biggest idea in the Music Manager, because it is how a listener actually moves around a large library. A messy genre list is the first thing that makes browsing painful. A clean one makes a collection feel like it was curated by a person who knew every record.

The trouble is that genre is also the messiest data there is. One album can be "Hip Hop" in one database, "hip-hop" in another, and "HipHop" in the tags someone typed years ago. Style labels are plentiful, opinionated, and inconsistent. So the system's job is to turn a pile of hints into a small, consistent vocabulary, decide each album's genres from the evidence, and write the result in a way Lyrion understands.

Three principles

  1. One authority. Genre is decided in exactly one place: a synthesis step in the nightly pipeline. The steps that fetch data from MusicBrainz and Discogs are barred from proposing a genre, and the writeback stage refuses any genre change that did not come from the synthesis step. No single source ever writes the genre tag directly.
  2. One axis. The system describes lineage, the family tree of a style. It deliberately does not mix in mood or "how you listen," because the player has only one genre tag to hold it all.
  3. Nothing is silently folded away. An unwanted style is rewritten to a preferred one, and that rewrite is written down and can be audited. A genre is never quietly merged or deleted.

Where the hints come from

For every album, the system gathers genre evidence from five places:

  • MusicBrainz release-group genres and tags
  • MusicBrainz per-recording genres
  • Discogs genres
  • Discogs styles
  • genre tags already embedded in the audio files

The sources are weighted, so curated ones outvote loose ones. Discogs styles and Discogs genres get fixed weights, styles higher. MusicBrainz contributes its own vote counts, since its genre data is community-voted, which makes it a folksonomy. Embedded tags and a folder-based fallback count the least. A Discogs match judged not to be this album is thrown out before its genres are counted.

The project does not use Last.fm or any other social-tag service.

Cleaning raw values

Raw strings are lowercased and run through a hand-kept configuration file that holds:

  • Rewrites. Variant to canonical name, so "hip hop," "hiphop," and "rap hip-hop" all become one thing.
  • A junk blocklist. Values like URLs, pure digits, and strings that are simply too long to be genres.
  • A non-genre blocklist. Descriptors that are real but not genres: moods, languages, vocal types.
  • The fixed top-level list, pins for favorite playlists, and explicit parent assignments.

One rule keeps the rewrites honest: a rewrite's target must sit at the same altitude as its source. An umbrella label goes to a top-level bucket, and a narrow style goes to a narrower style. The rule exists because an umbrella "funk and soul" label was once swept into Funk, and a lot of Soul went with it.

Values the system cannot resolve are parked in an "unmapped" cache. That cache clears itself each run of anything the vocabulary now understands, and what is left waits for my attention.

The three tiers

Every genre in the vocabulary belongs to one of three tiers, each with a different job.

Tier Role How it is decided
Tier 1 A small, fixed set of broad buckets: Rock, Pop, Jazz, Classical, Blues, Country, Folk, R&B, Soul, Hip-Hop, Electronic, Latin, Reggae, and a few more. Hand-chosen. A new top-level bucket is a deliberate policy decision, never a routine one.
Tier 2 The finer "playlist" level that you browse by: Metal, Motown, Ambient, and so on. Automatic. A genre earns it when enough albums and enough tracks use it. It slips back to Tier 3 only when it falls clearly below that line, and a dead band stops it from flickering. A short hand-kept list pins favorites here regardless of size.
Tier 3 Very specific flavors: the analytical detail. Everything else seen on at least a couple of albums. Anything rarer is dropped as cruft.

Every Tier 2 and Tier 3 belongs to exactly one Tier 1. A Tier 3's parent is resolved in order: an explicit hand assignment; a word-suffix match to a bucket (free jazz belongs under Jazz); a word-suffix match to a playlist (power metal goes through Metal to Rock); then co-occurrence with other genres on the same albums, which is only a weak guess; and finally "orphan." Guessed parents get listed in a curation report for review, because co-occurrence guesses can be wrong.

The whole vocabulary is rebuilt from scratch every night by scanning the library. Nobody edits it by hand. The only hand-edited inputs are the rules file and the lists above.

Sentinels

Three outcomes are sentinels: Xmas Music, Comedy, and Film Score. They take the first slot alone and override everything else, and no override can change them, so a player can filter holidays, stand-up, or instrumental screen music in or out as a block. (An ordinary soundtrack with songs is not a sentinel; it stays Soundtrack, a regular Tier 1.) Christmas albums are found by a whole-word keyword match against the folder path, with a hand-kept list for exceptions in both directions. The match is whole-word and letter-bounded, so "Santana" does not match "santa." A second, precise per-track check catches a stray holiday song on an otherwise ordinary compilation. A film score is recognized as a soundtrack album in which few tracks have lyrics.

Why "easy listening" is a playlist, not a facet

Styles like Easy Listening, Ambient, and Downtempo are really about how a listener uses the music, not about lineage. But the player has one genre tag, so they cannot be a separate axis. Each is filed as a best-fit Tier 2 under the bucket most of its albums land in, while each album keeps its own true Tier 1.

Picking an album's genres

The synthesis step takes each album through the same sequence:

  1. Gather every hint, weighted as above.
  2. Resolve each value through the rewrites and the vocabulary. Anything unrecognized goes to the unmapped cache.
  3. Check the sentinels. A Christmas album becomes exactly Xmas Music, stand-up becomes Comedy, and an instrumental score becomes Film Score. These short-circuit everything below.
  4. Pick a value per slot. Each album has three labeled slots, one per tier, and each holds a single value or stays empty. Within a tier, the system adds up the weights for each value and takes the heaviest, preferring a Tier 2 whose parent matches the Tier 1 it already chose. If no Tier 1 evidence exists but a sub-genre hint does, the Tier 1 is inferred from that sub-genre's parent. An empty slot is usually intentional: it is an honest "no strong character," not a gap to fill with a guess. The one exception is a slot the vocabulary itself can fill, from the parent of a neighbor's value.
  5. Apply overrides (below).
  6. Stage the result with confidence planned whenever a Tier 1 exists, so the writeback applies it automatically.

The step is deterministic and makes no network calls, and the notebook is rewritten only if the result actually changed, so settled albums are never churned. The reasoning for any one album is kept in that album's readable summary, which lists the hints and how they were weighed.

Compilations

A various-artists compilation cannot honestly have one genre, so it gets a genre per track, through a five-level fallback: strong MusicBrainz recording genres first, then the track artist's own known genres, then a mid-strength recording signal plus the album's context, then the track's embedded tag, and finally the album's own genre. A track on a rock compilation can be Jazz, and Lyrion will file it that way.

Overrides

The data is not always right, so a hand-kept overrides file lets a specific album, artist, or track bypass it. The actions are add (fill empty slots alongside the synthesis), replace (use only the listed genres), and exclude (drop a matching slot), plus switches to force per-track synthesis on or off. Each entry records a written reason and the dates it was added and verified. Typical uses are an artist whose signature style the data misses, big-band leaders, and albums confirmed to have no MusicBrainz genre data. A weekly upkeep step re-keys overrides when a folder is renamed and removes entries for albums that are gone.

What gets written, and how

Only the top two tiers, Tier 1 and Tier 2, are written into the audio files today. The third slot is computed and kept in the notebook, held in reserve behind a setting. A normal track therefore carries up to two genres, such as Rock and Hard Rock, and is filed under both.

Multiple genres go into a single genre tag, joined with a semicolon and a space: Rock; Hard Rock. An earlier design used repeated native tags, and it was dropped in favor of the joined tag.

How Lyrion reads it

A few facts about the player side:

  • Lyrion files genre per track, not per album. Its database has no genre on the album itself, so an album's genre is whatever its tracks carry. Writing the album's genre onto every track of a normal album is therefore the correct, and only, way to give an album one.
  • The multi-value separator must include a semicolon. The joined tag becomes separate genres only because a server preference tells Lyrion to split multi-valued tags on a semicolon. Left unset, Rock; Hard Rock would become one literal genre. A space as a separator would be worse, because on this server a space shatters multi-word genres.
  • Lyrion re-spells the standard ID3 genre names it knows, so a stored "Hip-Hop" displays as "Hip Hop." Terms outside that list pass through verbatim.
  • A normal rescan will not notice a genre change. Rewriting a tag in place does not change the folder's modified time, and the "new and changed" scan skips folders by that time. Only a full clear-and-rescan re-reads them, and that interrupts playback. Progress is also back-loaded: a junk genre disappears from the browse list only after every album carrying it has been rewritten.

What I do with genres

Most of the genre work is scripted. Two tasks need judgment, and both have a hands-on form and a timed form.

Add genres is about values. It works through the unmapped cache, and for each raw value I propose one of four outcomes: a rewrite (an unambiguous spelling or punctuation variant of an existing genre), a blocklist entry (junk), a non-genre entry (a mood, language, vocal type, or structure), or leave (a real genre that will classify itself once enough albums use it). The default for anything I do not recognize as junk or a variant is leave, so the thresholds decide. I read the cache with first-seen and last-seen dates, plus the current configuration and vocabulary, so I never propose a rewrite target that does not exist. Because a mistake spreads to every album and eventually into file tags, I take this one slowly, and I propose before I edit.

Genre curate is about policy. It pins a favorite as a playlist, rewrites an unwanted automatic promotion to a preferred genre, fixes a wrong parent bucket, assigns explicit parents to guessed Tier 3s, and tunes the thresholds. I build a triage queue, capped per section so a session stays manageable, and present each item as a card: counts, sample albums, a line of musical context, my recommendation, and the choices. Before I propose a parent bucket, I load the live list of top-level buckets and choose only from it, because an off-list parent silently does nothing. (The trap is offering World when Latin is a bucket of its own.) Before I change a threshold, I run a read-only preview that shows which genres would be promoted, demoted, or added. After edits, I validate the file and do a dry-run rebuild before anything is kept, and the configuration is committed, so rolling back is a matter of restoring the committed file.

In the hands-on form, I recommend and Mike decides. Since mid-November 2026 there is also a weekly timed form: during the weekly housekeeping, I add rewrites for flagged cruft variants and choose parent buckets for guessed Tier 3s on my own, re-run the rebuild, require the worklists to come out empty, commit, and report what I did. The bigger policy questions, such as adding a new top-level bucket, still go through Mike.

A related task, add tags, does the same job for raw tag field names rather than genre values.

A guide that writes itself

Every night the system also regenerates a readable genre guide and a short curation report. The guide holds a plain-English account of the process, a catalog with a definition and sample artists for each top-level bucket, and a decisions log. The curation report lists genres whose parent is missing and genres that still lack a prose definition. The generated files are not hand-edited; the source files and the configuration are.

Not built yet

  • Classical. A dedicated classical subsystem is designed but parked. It would use a specialist signal for "is this classical?" because the general vote is easily fooled by messy tags, with Tier 1 as Classical, Tier 2 as work form, and Tier 3 as period. It is parked with no date, and the tagging plug-in it depended on did not survive a Picard upgrade. Today Classical is simply one of the fixed Tier 1 buckets and goes through the same synthesis as everything else.
  • Mood and style. A concept note proposes a separate style or mood tag so that "how you listen" stops being squeezed into the genre tag. It is a planning document, not a specification.

Next: Enhancement shows where the evidence for all of this is fetched from.