XHS Β· Hum to Symphony

made by Shingyui (Roy) He

Hum a tune.
Get a symphony.

From 20 seconds of free humming to a fully structured, 90-bar orchestral piece β€”
with harmony solved by dynamic programming in neo-Riemannian space, not predicted on a whim.

Listen to the result Try the harmony planner
0.018Target MAE
100%cadence & return hit
24triads in PLR space
90bars of full form

The project

A symbolic pipeline
from humming to symphony.

XHS deliberately avoids end-to-end black-box generation. The task is decomposed into an explainable, controllable, verifiable five-stage pipeline β€” transcription, harmonic planning, melody development, orchestration, rendering β€” and every stage emits an inspectable symbolic artifact (MIDI, chord plan, form markers).

01

Transcription

basic-pitch converts audio to MIDI, followed by conservative cleaning: wobble filtering, key estimation with confidence, optional scale and rhythm-grid snapping.

β†’
02

Harmonic planning

NRT-DP runs a boundary-aware dynamic program over the PLR graph, realizing the per-section remoteness profile with exact cadence and terminal returns.

β†’
03

Melody development

A theme-and-variations engine: the user's theme is restated verbatim in the A-sections and developed by sequencing and fragmentation in B/Dev.

β†’
04

Orchestration

AccoMontage-3 (NeurIPS 2024) conditions on the lead sheet β€” melody, chord plan and form markers β€” to produce multi-track orchestral MIDI.

β†’
05

Rendering

FluidSynth with the FluidR3 sound font renders audio; section dynamics and melody-presence post-processing keep the texture balanced.

You hear yourself

The theme's pitches and rhythm survive verbatim at every presentation (97.7%–100% index-aligned pitch-class identity against the original hum) β€” what you hum is what you hear.

Harmony by design

A quiet Intro, a wandering B, a Dev section at maximal remoteness, a Coda that comes home β€” the tension curve is explicitly specified as a target profile and realized exactly by the planner.

Fully reproducible

The planner is pure-standard-library and deterministic; every intermediate artifact (chords_by_bar, form markers, melody MIDI) can be inspected and swapped independently.

Core technology

NRT-DP: the reference planner that thinks in neo-Riemannian space.Read the full paper β†—

The state space is the 24 major/minor triads. Adjacent harmonies may only move by three parsimonious transformations β€” P (parallel), L (leading-tone exchange), R (relative) β€” plus HOLD. The structural remoteness of a triad is its shortest-path distance from the tonic in this graph.

Given a tonic, section lengths, a target mean-remoteness profile Ο„ over sections, section-end target sets and a terminal return condition, the planner runs dynamic programming on the state (previous-previous chord, current chord, cumulative remoteness), optimizing lexicographically: section-mean error J₁, cadence-window approach Jβ‚‚, and HOLD/oscillation regularization J₃ (Ξ» = 0.15 / 0.60). Boundary-aware initialization keeps the whole multi-section trajectory continuous.

Exact-deadline feasibility sets Fr(C) prune every partial path that cannot land exactly on its section's required ending β€” and with section lengths β‰₯ 6 the sequential planner provably never goes infeasible (graph diameter D = 5).

Measured on the 90-bar XHS form

MetricGreedy heuristicNRT-DP
Target MAE ↓0.3660.018
Contrast MAE ↓0.2880.036
Max adjacent distance2 (violated)1 (strict)
Section-end hit rate0.86–1.001.00
Terminal returnβœ“βœ“

Melody-aware extension: a b9-avoidance / coverage cost term added to the objective lets the harmony adapt to the user's melody pitches β€” coverage at presentation bars rose from 0.24 to 0.63, with planning metrics unchanged.

Code

The core, in plain sight.

Three real excerpts: the NRT-DP planner core, the melody engine's only pitch rule, and the JavaScript planner running live on this very page (switch with the tabs above the window).

Listen

It starts with one hummed tune.

The complete chain from a single 23-second original hum (F major).

β‘  Hummed input

The user's theme after transcription and cleaning (Voice Oohs)

β‘‘ Theme + harmonic backbone

Theme-and-variations melody over the NRT-DP chord pad

β‘’ Full piece Β· ensemble A

AccoMontage-3 orchestration: strings / horn / piano / bass

β‘£ Full piece Β· ensemble B

The same melody and harmony in a different instrumentation

Try it

Drive NRT-DP yourself.

A complete JavaScript port of the paper's reference planner, running live in your browser β€” pick a tonic and a tension profile, watch dynamic programming solve a 90-bar harmonic backbone, and listen to it right away.

Pick your parameters and press "Plan harmony".
Near tonic (remoteness 0) Medium tension (2–3) Far from tonic (5)