# Lucid Music — the heritage corpus of the world's musical structure

> **The ask (AJ, 2026-06-28).** "Ingest the exhaustive corpus of sheet music and reduce using a
> vector graph and learn the structure of music from around the world. A heritage project. Internet
> Archive of folk music." **Part of Lucid AI.**
>
> This is **Lucid's musical-knowledge domain** — not a new engine. Lucid is already the cite-or-refuse
> computational-knowledge engine over the One-Record store ([[one-record-knowledge-store]]); this
> teaches it the *structure of music* the way it already knows physics constants and Wikidata facts.
> The honest-Wolfram thesis, applied to humanity's songs.

---

## Why it belongs to Lucid (not a side project)

Lucid's spine is already: **ingest open/PD sources → map to a vector + fact graph → answer by
traversing + citing, refuse when it can't.** Sheet music is just another corpus on that spine:
- **ingest** the world's notated music (see sources, all open/PD-first),
- **reduce** each piece to a **vector-graph** representation of its structure (key, mode, scale,
  chord motion, rhythm, form, melodic contour, ornament) — the *grammar* of a song, not the audio,
- **learn** the cross-cultural structure: what a maskandi turnaround shares with a delta-blues one,
  how a Xhosa call-and-response maps to a Appalachian ballad — the universal + the particular,
- **cite or refuse:** "this cadence appears in [these traditions], sourced [here]" — never invent a
  provenance (the one law). A heritage corpus that fabricated lineage would be the opposite of heritage.

This is also the honest engine behind SongBench's "jazzify any genre" claim ([[songbench-congotunes]]):
that claim is a SPEC until Lucid actually *knows* music structure — **this corpus is how it learns it.**

## The Internet Archive of folk music (the heritage mission)

The point is **preservation + dignity**, not extraction: the world's folk and indigenous music,
much of it oral and undernotated, mapped and kept — an open, citeable archive of humanity's musical
heritage. Dignity-first (the Covenant in music): the traditions of the unrecorded get a permanent,
sovereign home, attributed to their people, never laundered into anonymous "AI training data."

## Sources (open / public-domain first — the provenance must be clean)

- **IMSLP / Petrucci** (PD classical + folk scores), **Mutopia** (free sheet music), **Internet
  Archive** folk/ethnomusicology collections, **Wikimedia Commons** scores, national folk-song
  archives (PD), field-recording archives with open licenses.
- **MusicBrainz / AcousticBrainz** for metadata (already used by [[congotunes-wizard]]).
- ⚖️ **Provenance + rights are load-bearing:** ingest PD/open-licensed first; anything else needs a
  rights check BEFORE ingest (this is a heritage archive, not a scrape). Indigenous/traditional music
  carries community rights even when "public domain" — attribute to the tradition, honor takedown +
  community-control requests (the LightWeb accountable + the Emancipation right-to-be-forgotten ethos).

## The representation — a vector graph of structure

Each piece reduces to a graph node carrying its structural vector (key/mode, chord-transition matrix,
rhythmic signature, form, contour) + edges to the tradition, region, era, and structurally-similar
pieces. The store is the existing **One-Record** (append-only, delta-only, Merkle — re-seedable,
tamper-evident). Querying = the same cite-or-refuse traversal Lucid already does for facts.

## Build order (honest — what's built vs still spec)

1. **[spec]** this doc + cards (this pass).
2. **[BUILT]** `the420code/proofs/music-structure/` — the deterministic engine. The core proof
   (`demo.py`: scales, derived diatonic triads, transposition, key detection, theory-correct jazzify)
   PLUS the deep "language of music" layer (`demo_world.py`, both green + in CI via PROOFS.json):
   - `scales.py` — 50 scales / 10 families (diatonic modes → maqam → raga → African/maskandi);
     microtonal traditions tagged `approx_12tet` + credited; modes PROVEN by rotation math.
   - `tuning.py` — pitch as exact cents/ratios ("slightly out of tune" is math); the open Scala
     `.scl` format (parse your own files; the archive is freeware, not shipped).
   - `rhythm.py` — odd/asymmetric meter, swing, clave/tresillo/bembé, Euclidean rhythms.
   - `chords.py` — chord dictionary that names a chord from its notes (honest about dim7 symmetry).
   - `glossary.py` — cite-or-refuse craft vocabulary (definition WITH a source, or refuse).
   - `sheet.py` — dependency-free MusicXML ingest → the note model.
   - `perform.py` — deterministic performance in a style (the lounge savant / maskandi feel),
     mirrored audibly in `games/congoband/` (humanfeel.js + a Maskandi groove + intonation drift).
3. **[next]** an ingest path for ONE clean PD source (e.g. Mutopia/OpenScore) → vector-graph →
   One-Record, end to end small. `sheet.py` proves the parse; this wires it to the store.
4. **[next]** cross-cultural structural similarity (the "learn the world's music" claim) — `scales.py`
   has `is_mode_of` / `shared_tones` as the seed; the corpus-scale similarity is measured, not asserted.
5. **[spec]** the public heritage-archive surface (browse/cite/attribute by tradition) + community-control.

### FOSS posture (researched 2026-06-29)
The cleanest deterministic spine is **data, not code** — so the engine is hand-encoded pure-stdlib with
provenance (heritage-not-harvest), and FOSS is used as *reference data + subprocess converters*, never
linked into the core. Permissive (vendor freely): **music21** (BSD), **partitura** (BSD), **tonal.js**
(MIT), **librosa** (ISC), **MSAF** (MIT). LGPL (link OK): **Verovio** (MEI→SVG render). The Scala tuning
archive (freeware) + Ian Ring's 2048-scale universe (license-unclear) are *cited as reference*, not
shipped. AGPL/NC (isolate or avoid): Essentia, madmom models, MAESTRO, Lakh MIDI (murky provenance).

---
*Heritage, not harvest. Lucid learns the grammar of the world's songs and cites where each came from;
the traditions keep their names. Companions: [[one-record-knowledge-store]] (the store),
[[lucid-engine]] (the engine this extends), [[songbench-congotunes]] (the corpus unblocks its
"jazzify" claim), `ARTIST_HUB.md` (where living artists meet the heritage). With love, and with salt.*
