Skip to content

5. Tonal Grammar

The rules so far judge notes and lines. This chapter judges sentences: how phrases end, how the music borrows chords from neighboring keys, and how it travels to a new key and back. These checks need more context than an interval — the validator reads them against the declared harmonic plan.

What is V to I?

Roman numerals describe chords relative to the key. In C major, I is C major, IV is F major, V is G major, vi is A minor. A cadence is a closing gesture; V to I is the common dominant-to-tonic closure, but the validator also checks how the individual voices arrive there.

Cadences are voice-leading contracts

A cadence is more specific than "the harmony is V then I". Each declared cadence type promises particular outer-voice behavior — the highest and lowest lines, the two the listener tracks most easily — at the cadence tick, and cadence_voice_leading verifies it. The engine knows seven types.

Authentic: the period

Cadence cellAuthentic cadence voice leading
The validator checks the declared cadence type, not just chord labels.
cadence_voice_leadingThe leading tone resolves upward while the bass moves V to I.

The perfect authentic cadence demands the strongest close: the upper voice resolves the leading tone up to the tonic while the bass falls from dominant to tonic. The imperfect authentic variant relaxes the soprano requirement — same harmony, softer punctuation.

Bach signs the Goldberg Aria with exactly this close:

From BachBach: Goldberg Aria — the final cadence
The last two bars of the Goldberg Aria (BWV 988). In the penultimate bar the melody's sixteenths circle down onto F♯ — the leading tone — while the bass winds through the cadential harmony and lands on D. Then the contract closes: F♯ rises a semitone to G, the bass falls D to G, and an inner voice slips in only for the final bar to fill the chord. Outer-voice behavior at the cadence tick is exactly what cadence_voice_leading verifies for a perfect authentic close. The final notes are held under a fermata in performance; the excerpt trims them at the double bar.
cadence_voice_leadingThe melody lands on the leading tone F♯ and rises to G while the bass falls from dominant to tonic.

Plagal: the amen

Cadence cellPlagal cadence (IV - I)
The "Amen" cadence. There is no leading tone, so the sense of closure comes entirely from the bass motion IV to I. The validator recognizes the plagal type from the declared cadence event and checks the bass accordingly.
cadence_voice_leadingThe bass falls from the subdominant to the tonic while the upper voice holds the tonic.

Half: the comma

Cadence cellHalf cadence (ends on V)
A half cadence parks the music on V and leaves it expecting continuation. Inside a generated piece it articulates phrase boundaries without closing the paragraph; the final cadence of a section is authentic instead.
cadence_voice_leadingThe phrase stops on the dominant — a musical comma, not a period.

Deceptive: the feint

Cadence cellDeceptive cadence (V - vi)
Everything promises a final close — then the bass moves to vi instead of I. Bach uses the deception to extend a phrase that seemed finished. The validator accepts the declared deceptive type only when the bass really arrives on the sixth degree.
cadence_voice_leadingThe leading tone still resolves up, but the bass sidesteps to the sixth degree.

Here is the feint in the wild — three voices of the F major fugue assemble a complete V7, the upper voices resolve exactly as promised, and only the bass slips upward to vi:

From BachBach: WTC I Fugue in F major — the bass that breaks its promise
Bars 10–11 of the dance-like F major fugue. On the last eighth of the bar the three voices align into a complete dominant seventh: C in the bass, the leading tone E on top, the seventh B♭ in the inner voice. Then every tendency tone keeps its promise — E rises to F, B♭ falls to A — except the bass, which breaks its own: instead of dropping home to F it steps up to D, and the downbeat chord is vi. The phrase that sounded finished keeps moving, and Bach rides the evasion straight into the next entry. The validator accepts a declared deceptive cadence on exactly this evidence: the upper voices resolve as if the close were real, and the bass alone lands on the sixth degree.
cadence_voice_leadingA full V7 gathers on the last eighth of the bar — and the bass steps up to D instead of home to F.

Phrygian: the archaic close

Cadence cellPhrygian cadence (iv6 - V in minor)
The signature Baroque ending for a slow minor movement: the half-step descent in the bass against contrary stepwise rise above. It ends on V like a half cadence, but the chromatic bass approach gives it a distinct, archaic color.
cadence_voice_leadingThe bass descends by half step onto the dominant while the upper voice rises by step.

Bach ends an entire movement this way. The Largo of the fifth organ trio sonata closes on V — phrygian descent in the pedal, a pair of suspensions resolving above — and hands the open door to the finale:

From BachBach: Trio Sonata No. 5, Largo — a movement that ends on V
The last two bars of the Largo from the fifth organ trio sonata (BWV 529), in A minor. The pedal descends A-G-F and then makes the signature half-step drop onto E: the phrygian close. Above it Bach hangs two suspensions across the final bar line — the fourth (A) and the raised seventh (D♯) hold over the new bass, then melt into G♯ and E. The movement ends on that E major sonority and never comes home: a phrygian cadence is a half cadence by nature, and what it opens the door to is the finale in A minor that follows. Dominant preparation at the scale of a whole movement.
cadence_voice_leadingThe pedal walks down to F, slides a half step onto E — and the movement stops there, on the dominant, door open.

Picardy: minor ends major

Cadence cellPicardy third
The final chord of a minor-mode work brightens to major. The raised third demands an accidental, and the validator checks the declared Picardy cadence for both the leading-tone resolution and the major third in the final sonority.
cadence_voice_leadingA minor-key piece closes on a major tonic chord — the third is raised.

And here is the convention at work — the very last bar of the C minor fugue from WTC I, dominant tension over a tonic pedal melting into a major chord:

From BachBach: BWV 847 — the final bar turns major
The last bar of the C minor fugue (WTC I, BWV 847). The bass has held the tonic C since bar 29; above it the dominant harmony gathers one last time, the upper voice climbs F–G–A♭ and falls back, and the chordal seventh F resolves down to E natural — the raised, major third, sounding on top as the piece ends. A minor fugue closing on a major chord is the Picardy convention the validator's Picardy check encodes: the leading tone resolves, and the final tonic chord carries a major third. (One inner voice is omitted; the score doubles the pedal an octave lower.)
cadence_voice_leadingOver the tonic pedal, the seventh of the dominant harmony (F) falls to E♮ — a major third ends a C minor fugue.
Cadence typeValidator checks
PerfectLeading tone resolves up by semitone to tonic; bass moves dominant → tonic.
Imperfect authenticSame harmonic frame with relaxed soprano.
PlagalBass moves subdominant → tonic (IV → I).
HalfThe phrase comes to rest on the dominant.
DeceptiveThe bass evades the tonic, arriving on the sixth degree (V → vi).
PhrygianIn minor: bass descends by half step onto the dominant (iv6 → V). The stepwise rise in the upper voice is stylistic — the engine checks only the bass motion.
Picardy thirdLeading tone resolves and the final tonic chord carries a major third.

Reading the chord symbols

This chapter's tables use three decorations on Roman numerals. A small 6 (as in iv6) marks first inversion: the chord's third is the lowest note instead of its root — that is how the Phrygian cadence gets its half-step bass descent. A ° (as in vii°) marks a diminished chord, stacked from two minor thirds. A superscript 7 (as in V7) adds a fourth note a seventh above the root; that added note is the "chordal seventh" whose doubling is banned below. Combining the two gives vii°7, the diminished seventh chord: three minor thirds stacked, its outer span the diminished seventh (9 semitones) the chord is named after — Baroque music's most dramatic dominant substitute.

Doubling: tendency tones stay single

Some scale degrees carry an obligation (the leading tone wants the tonic; a chordal seventh wants to fall). Giving the same obligation to two voices guarantees one of them breaks it — or they resolve in parallel octaves.

DoublingDoubled leading tone
Doubling the leading tone creates multiple voices demanding the same resolution.
doubling_no_leading_toneThe leading-tone pitch class appears in more than one voice.
DoublingDoubled seventh
The seventh is a tendency tone. Seventh-quality chords keep it single to avoid competing resolutions.
doubling_no_seventhThe chordal seventh appears in more than one voice.

Cross relations: chromatic contradictions

ChromaticCross relation
The red notes show a chromatic clash between voices inside the validator window. Natural E-F and B-C half steps are not cross-relations.
cross_relationDifferent voices contradict the same scale degree chromatically in close succession.

When one voice sounds F♯ while (or immediately after) another sounds F♮, the listener hears the key contradict itself: one line claims the chromatic form of a degree while another insists on the diatonic form. The validator window covers simultaneous notes and adjacent beats. Natural half-step pairs (E–F, B–C) are not cross relations — they are different letter names, not chromatic alterations of the same degree.

Secondary dominants: borrowed tension

Applied harmonySecondary dominant resolving (V/V - V)
A secondary dominant borrows dominant function for a chord other than the tonic. The raised note would normally fail the melodic checks — but inside a declared applied-dominant region, the validator exempts the chromatic motion and instead verifies that the next chord really is the targeted degree.
secondary_dominant_resolutionThe chromatic F sharp acts as a local leading tone and resolves up to G.

A secondary (applied) dominant treats a diatonic chord as a momentary tonic and approaches it with its own dominant — written with a slash and read "of": V/V is "the V of V" (in C major: D major, the dominant of G), V/vi the dominant of the vi chord, and so on. This is the engine's main source of legal chromaticism:

  • Inside the declared applied region, the melodic rules (augmented_melodic, diminished_melodic, tritone_melodic) are exempt — the chromatic motion is the device.
  • In exchange, secondary_dominant_resolution verifies the promise: the next chord must actually be the targeted degree. The rise of the borrowed leading tone is tracked descriptively via provenance, while the hard check is the degree-level resolution.

Pivot-chord modulation

ModulationPivot-chord modulation (C major to G major)
A pivot chord belongs to both the old key and the new one, so the ear can reinterpret it mid-phrase. Here Am (vi in C, ii in G) pivots into a D major chord that only makes sense in G, and the cadence confirms the new key. The validator requires the declared pivot chord to be diatonic in both keys.
modulation_pivot_chord_requiredThe A-minor sonority is vi in C and ii in G — diatonic in both keys.

To modulate convincingly, Baroque practice routes through a pivot chord — one that is diatonic in both the old key and the new key, so the ear can reinterpret it mid-phrase. For pivot-type modulations, modulation_pivot_chord_required verifies that the declared pivot really belongs to both keys. (The engine also models common-tone and phrase modulations, which carry their own declared shapes rather than a pivot.)

How the validator sees this chapter

RuleFailKindCheck
cadence_voice_leadingStructuralFail / MusicalFailOuter voices match the declared cadence type at the cadence tick (approach = one beat earlier). A malformed cadence layout (fewer than 2 voices, no distinct bass) is StructuralFail; the voice-leading mismatch itself is reported as MusicalFail.
doubling_no_leading_toneMusicalFailThe leading-tone pitch class sounds in at most one voice when the chord contains it (V, vii°, V7, vii°7).
doubling_no_seventhMusicalFailA seventh-quality chord's seventh is not doubled.
cross_relationMusicalFailNo chromatic pitch-class conflict between voices within a beat window. Both-material pairs exempt.
secondary_dominant_resolutionMusicalFailA chord marked V/x is followed by degree x.
modulation_pivot_chord_requiredMusicalFailA pivot modulation's pivot chord is diatonic in both keys.

Continue with Chapter 6 — Fugal Devices.

Dual-licensed: AGPL-3.0 · commercial licensing available. Generated MIDI is yours to use freely.