Harmony Engine

Pick a style and press Play. The engine assigns probabilities to the possible next chords, based on the current chord. A preset plays a fixed progression instead. Each workbench panel shows one stage and the choice that it produced. Markov chains explains the probability model. Chord qualities shows the intervals in one chord. Neo-Riemannian harmony follows small note movements between triads.

Visual key: the ring shows all 12 pitch classes. Red marks the root, black marks selected notes, and the shaded polygon shows the chord. A dim polygon shows the previous chord. Small flashes mark added notes that approach or suspend a chord tone.

Controls

1 Plan

The engine chooses phrase type and rhythm one phrase ahead. When a question phrase (antecedent) ends, the engine saves its shape. The next answer phrase (consequent) reuses its rhythm, harmonic contour, bass direction, and accompaniment.

Phrase
Rhythm
Cycle
Loop
Phrase type graph
Phrase memory
Phrase plans set arrivals and key changes

A phrase's last slot is its arrival, and the engine takes it outright. Earlier slots come from a probability row weighted toward that arrival, which they reach about nine times in ten. This weighted approach keeps two phrases of the same type from spelling themselves identically.

When a question phrase ends, the engine stores its rhythm, harmonic contour, distance from tonic, bass direction, and accompaniment. The answer phrase reuses these features at first. Its cadence then closes the pair instead of copying the question.

A form preset divides the progression into named sections, each with its own cadence and its own accompaniment density, so a section boundary is audible before you read the label.

A section can also use a different key. The engine transposes the seven chords in the key. It prefers to enter through a pivot chord that belongs to both keys. Roman numerals follow the current key.

Overrides can replace probability sampling

The stages run in order: cadence boosts at the phrase edges, style grammar, reuse of a stored phrase, and the cadence template near the end. A form adds goal weighting. Each chord is weighted by how likely the section's goal remains from that position, so the row narrows toward one option at the arrival.

An applied dominant borrows the dominant of the next chord and sounds it first. It then holds the target for the following slot. This move reaches outside the seven chords in the key. Jazz sometimes replaces the dominant with the chord six semitones away, called a tritone substitute.

A harmonic sequence states a root-motion pattern and repeats it for several chords, most often falling fifths. The row is not consulted again until the pattern finishes. It gives a long span that is going somewhere without arriving, which is what a phrase built only from local choices cannot produce.

Neither runs during the other, and neither runs through a cadence. Both appear in the trace as override lines, because in both cases the probabilities shown above them did not decide the chord.

Voicing score terms

The engine adds the score terms for each candidate. It measures each term as an equivalent number of semitones so that the terms can be compared. The display shows only terms that affected the score.

The engine checks parallel fifths and octaves before scoring. It removes a candidate that contains either interval. This rule applies only to common-practice styles. Pop and blues allow parallel chord shapes.

motion
Total distance the voices travel from the previous chord.
next move
Distance to the chord likely to follow, weighted at 0.4. Smoothing the move at hand matters more than the projected one.
leading tone
A leading tone that fails to rise while the tonic sounds.
direct perfect
A fifth or octave arrived at by similar motion with the top voice leaping into it.
spacing
A gap over an octave between adjacent upper voices.
crowds melody
1.5 per semitone by which the chord sits too high for the melody to have room above it.
answers bass
A credit for moving the bass the way the phrase being answered moved its own, so an answer mirrors the contour of its question.

The choice is made one chord at a time and cannot revise an earlier one. Every fault can be avoided on its own and they cannot all be avoided at once, so the weights below the prohibition are a trade rather than a solution.

Which pitches are admissible, and what the rest cost

The cell asks for a scale degree, and the scorer answers with the cheapest pitch it can justify, which is often not the one asked for. Pitch classes outside the key and pitches outside the range the recordings cover are filtered rather than scored: they are not worse answers, they are not answers.

drift
Per semitone away from the pitch the motif asked for. Without it every note collapses onto the nearest chord tone and the motif stops being a motif.
non-chord
A note the chord does not contain. Expensive on a stressed beat, nearly free in passing.
dissonance
A semitone against a sounding chord tone. Cheap when stepped into and out of, since that is what a passing tone is, and dear when leapt onto or left hanging.

Notes are chosen together rather than one after another. Each pass re-scores every note knowing where its neighbors landed, and repeats until nothing moves.

2 Decision

Each chord starts with transition probabilities. Several stages adjust these probabilities before the engine selects a chord. The trace shows each change.

Function
Borrowed
Next likely
Function graph + cadence lens
Decision trace

The stages run in this order: initial probabilities, cadence boost, style, memory, cadence template, and final selection. A changed distribution gets its own row. Unchanged stages appear together on one line.

Fixed preset mode reads chords from a written sequence, so it does not use a probability row. The function dots and graph still show each chord's role in the current key.

3 Voicing

Every inversion is scored, and each card carries the terms that produced its score, so a candidate that lost says what it lost to.

Voice motion
Inversion candidates

4 Motif

At the start of a phrase, the engine chooses a short pattern of scale steps called a motif. It changes this motif through repetition, echo, answer, and cadence. The notes form a light melody above the accompaniment.

Cell
Transform
Chromatic
Phrase transformations
Note choice
Piano-roll overlay
Chromatic line
Motif memory

5 Surface

One accompaniment pattern is chosen per phrase and held for the whole of it. How much decoration a slot earns follows its position in the phrase, and the style's meter decides where the weight falls and how long a cycle runs.

Where the weight falls in each style

An answering phrase reuses the pattern its question used, so the pair match. A preset section can ask for a busier figuration across its whole span, which is how a form boundary becomes audible without being announced.

Openings stay bare, and middle slots can use passing tones. Before a cadence, an appoggiatura lands on the beat and resolves into a chord tone. Every cadence lasts longer than a middle chord. A walking bass approaches the next root.

Meter is where the styles differ most. Pop takes a backbeat on 2 and 4. Jazz is far flatter, its off-beats almost level with its beats. Meter also fixes how far a swung eighth is displaced, further for a blues shuffle than for a jazz swing, and how many beats a cycle holds. La Folia runs in three with the weight on the second beat. Flamenco runs in a twelve-beat compás accented on 3, 6, 8, 10 and 12, the tenth carrying the resolution.

The dot row counts one turn of the cycle and rings the beats its meter accents.

Pitch labels
Wheel order

Chord details
Intervals above root
Stack from bass
Bass
Recognized root
Symbol
Semitones above root

Step
Timeline
chord

Beat
Figuration
Handoff
Gravity terrain
Tonic basin, dominant ridge, predominant slope, and deceptive side basin.

Sources for the Markov tables

Markov (major) and (minor)

These tables follow common-practice harmony. See Aldwell and Schachter, Harmony and Voice Leading, and Schoenberg, Structural Functions of Harmony (1954). The weights are hand-tuned, not measured from a collection of music.

Markov (pop)

The table favors I–V–vi–IV and the deceptive V→vi move. These patterns appear in the McGill Billboard Project (Burgoyne, Wild, and Fujinaga 2011) and de Clercq and Temperley (2011).

Markov (jazz)

The ii–V–I progression and vi→ii return are commonly taught, for example by Aebersold. Broze and Shanahan (2013) measured both patterns in the iRealPro collection.

Markov (Bach)

Strong vii°→I and V→I transitions are common in chorales. Allan and Williams (2005) trained probabilistic models on chorales. The earlier HARMONET system appears in Hild, Feulner, and Menzel (1992).

Phrase types

Antecedent / consequent / deceptive / open phrase types follow William Caplin, Classical Form (1998). The phrase-level transitions here are hand-tuned to favor the antecedent→consequent period.

Caveat

The five chord tables are hand-tuned examples, not measurements from the cited collections. The sources describe the musical patterns or report measured transition frequencies.

Every instrument uses recordings from the MusyngKite soundfont (CC BY-SA 3.0). The page redistributes them unchanged and shifts pitch by at most one semitone.