Skip to content

Repository files navigation

Crown of Embers

A generative "epic minor" orchestral theme engine. It composes an original ~3-minute hero theme from a seeded random motif, then renders it either as a retro synth piece (pure numpy/scipy DSP) or as a full sampled orchestra — section strings, brass, mixed choir, timpani and percussion — through a built-in SFZ sampler, with a measurement-driven mixing chain.

🎧 Listen: Crown of Embers (Orchestral Version).mp3 — seed 23, the canonical render.

The musical pattern

The engine was built by reverse-engineering the structure of a reference track with librosa (key correlation, energy contour, tempo, spectral analysis), then re-composing original material inside that structure:

  • Reference: Daniel Pemberton — Masters of the Universe (2026) main theme ("Eternia"), in the extended edit by Gilles Nuytens: https://youtu.be/e1nb9hhsb_U. The reference audio is not included in this repository; no melodic material from it is used. What the analysis extracted — and what the generator reuses — is the pattern itself:
  • A minor, ~129 BPM, with E minor (unresolved minor dominant) bookends — the piece opens and closes on a harmonic question mark.
  • A 96-bar double-wave arc: quiet intro → driving anthem statement (i–bVI–bVII) → dark sparse middle → densest climax → sudden breakdown → triumphant finale (Am–F–C–G, the borrowed-major lift) → fading outro.
  • Section-level dynamics, brightness and rhythmic density targets measured from the reference.

Every render is verified against that pattern with verify_pattern.py (the canonical render scores: tempo 129.2, E-minor bookends confirmed, energy-contour correlation 0.98).

Architecture

flowchart TD
    DNA["Musical DNA — hero_theme_generator.py<br/>A-minor pattern · 129 BPM · double-wave arc · seeded motif engine"]
    DNA -->|"seed N"| SYNTH["Retro synth render<br/>pure numpy/scipy DSP"]
    DNA -->|"seed N"| SCORE["Score layer — orchestral_theme.py<br/>~2,500 note events · 17 orchestral parts"]
    SCORE --> PERF["Performance layer<br/>timing & velocity humanization · phrasing · legato overlaps"]
    PERF --> SFZ["SFZ sampler — sfz_sampler.py<br/>VPO3 samples: strings · brass · choir · percussion"]
    PERF --> TSF["tinysoundfont backend<br/>FluidR3 GM harp"]
    SFZ --> MIX["Mix chain<br/>per-part EQ slotting · accent air layers · stage panning · hall reverb · harmonic exciter"]
    TSF --> MIX
    SYNTH --> OUT(["WAV → MP3"])
    MIX --> OUT
    OUT --> VERIFY["verify_pattern.py<br/>key correlations · tempo · energy contour"]
    VERIFY -.->|"scored against the reference pattern"| DNA
Loading
File Role
hero_theme_generator.py The musical DNA (sections, progressions, seeded motif engine) + the original pure-DSP synth renderer
sfz_sampler.py Minimal SFZ engine: scoped opcodes, velocity layers, round-robin/random layers, loop-extension, humanization opcodes (pitch_random, delay_random, amp_random, pan)
orchestral_theme.py Score layer (17 orchestral parts) → performance layer (timing/velocity humanization, phrasing, legato) → render (VPO3 samples + FluidR3 GM harp via tinysoundfont, per-part EQ, stage panning, hall reverb, harmonic exciter)
verify_pattern.py Checks a render against the target pattern (keys, contour, tempo)

The mixing chain is measurement-driven: per-part high-pass ladders and low-mid cuts to keep layers separated, accent-patch layers under the sustains for attack definition, and a master harmonic exciter that synthesizes the top octave the samples don't carry — tuned band-by-band against the reference's tutti spectral balance.

Setup

Requires Python ≥ 3.13, uv and ffmpeg (for MP3 encoding only).

uv sync

Sample libraries (not bundled, ~750 MB)

  1. Virtual Playing Orchestra 3 (free, WAV+SFZ): download the wave files archive and the standard scripts from https://virtualplaying.com/virtual-playing-orchestra/ and unzip both into orchestral-libs/, producing orchestral-libs/Virtual-Playing-Orchestra3/Virtual-Playing-Orchestra3/{Strings,Brass,Vocals,Percussion,libs,...}.
  2. FluidR3_GM.sf2 (MIT-licensed General MIDI soundfont, used for the harp): place it at orchestral-libs/FluidR3_GM.sf2. It ships with many distros (fluid-soundfont-gm package) or can be found on Musical Artifacts.

Usage

# orchestral render (seed 23 = Crown of Embers)
uv run python orchestral_theme.py 23 crown.wav

# retro synth render of the same composition
uv run python hero_theme_generator.py 23 crown_synth.wav

# any other seed = a new original melody in the same structure
uv run python orchestral_theme.py 42 another_theme.wav

# verify a render against the pattern
uv run python verify_pattern.py crown.wav

# encode to mp3
ffmpeg -i crown.wav -codec:a libmp3lame -b:a 320k crown.mp3

License

Everything in this repository — code and the released MP3 alike — is dedicated to the public domain under CC0 1.0. It was built as teaching/demo material: fork it, study it, break it, improve it, no attribution required.

Third-party assets you download separately keep their own licenses: Virtual Playing Orchestra samples are free to use in music productions (see the VPO FAQ and its source libraries — Sonatina, VSCO2 CE, et al.); the FluidR3 soundfont is MIT.

About

Generative epic-minor orchestral theme engine — seeded composition, built-in SFZ sampler, measurement-driven mixing

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages