6. Fugal Devices
A fugue is not a form like a sonata — it is a procedure: one theme (the subject) enters voice by voice, travels through related keys, and returns intensified. Every device in that procedure is a contract between declared material and emitted notes, and the validator checks each one. These rules sit above the local interval rules from chapters 2–3, which keep applying throughout.
The fugue procedure at a glance
Exposition: each voice enters in turn with the subject or its answer; a countersubject may accompany those entries. Episodes: passages often use sequences or subject-related ideas to travel between keys, but their material can vary. Development: middle entries restate the subject in related keys; stretto and pedal points raise the temperature toward the close. The primer's fugue terms table defines each word in one line.
These labels describe common procedures rather than universal requirements; see Open Music Theory's exposition overview and Puget Sound's fugue analysis guide.
Subject and answer
When the second voice enters, it usually carries the subject toward the dominant — the answer. A literal transposition is a real answer; the exact interval can be a fifth up or a fourth down, depending on the entering voice. A tonal answer makes small intervallic adjustments where a literal transposition would destabilize the tonal center. The adjustments depend on the subject and its context; they are not limited to an I↔V head followed by an untouched tail.
tonal_answer_dominant_mapping, which reads only the first note, cannot tell them apart; imitation_entry_match reads the whole answer window and can.The engine's fugue builder answers a fourth below the subject. It chooses a tonal answer when the subject opens on scale degree 5, or opens on 1 and reaches 5 within its next three notes. The tonal answer then swaps 1 and 5 inside its first four notes (in practice, a 5 in the subject is answered by 1 instead of 2) and transposes everything after that literally.
Two rules read the result. tonal_answer_dominant_mapping checks only the first note: a subject that opens on the tonic must be answered on the dominant, and the reverse. A real answer to a tonic-opening subject also starts on the dominant, so for those subjects this rule cannot tell real from tonal. The fuller check is imitation_entry_match, which reads the answer's whole window: a real answer keeps one transposition throughout, and a tonal answer may swap tonic and dominant only within its first four notes before rejoining the real transposition.
Here is the textbook case in Bach's own hand — the opening of the C minor fugue from WTC I. Play the two lines in turn and listen for the single bent note:
tonal_answer_dominant_mapping rule reads only the first note (C answered by G); the bent fourth note is checked by imitation_entry_match.A contrasting real answer appears in Bach’s G-minor “Little” Fugue (BWV 578): the displayed alto entry is a literal transposition of the quoted soprano opening, a perfect fourth below. The subject leaps from tonic to dominant at once, which is exactly the shape the textbook (and the engine) would answer tonally; Bach answers it literally:
The countersubject
A countersubject is a recurring companion in some fugues, but it is not a required part of every fugue. When material declares one, countersubject_continuous samples every quarter-beat of the answer's window and requires a sounding note from the countersubject voice at each one. Since the pair is designed to be reused with voices swapped (invertible counterpoint), invertible_at_octave also checks it at structural accents; fourths are judged against the actual bass by vertical_dissonance.
In the same C minor fugue, the countersubject enters the moment the answer does — and never stops sounding under it:
countersubject_continuous performs. The pair is built to be reused with the voices exchanged; chapter 2's invertible-counterpoint rules police that property, and bars 7–8 of the same fugue cash it in.Episodes and sequences
Episodes are where fugues travel. Historical episodes often develop fragments of the subject or countersubject, and sequences are common, but they can also use free counterpoint or another salient idea. In this engine, only material explicitly declared as a motif transform must be derived from a source slice — restatement re-anchors the slice at its new position, inversion mirrors the contour upside down, retrograde plays it backwards, and augmentation/diminution stretch or compress every duration (not to be confused with augmented intervals from chapter 4). A declared sequence uses the same seed on successively higher or lower scale degrees.
A sequence can move its pattern in two ways. A tonal (diatonic) sequence slides the pattern along the scale: a half step in the seed may come back as a whole step, and the music stays in its key. A real sequence copies every interval to the semitone, which brings in accidentals and pulls toward other keys. Bach uses both; the tonal kind is the everyday one. Switch the figure between them:
sequence_pattern_consistency checks this form: each step moves the seed by scale degrees in the key. Switch to the chromatic copy to see what it rejects.The engine's sequence_pattern_consistency rule is diatonic, like Bach's everyday sequence: each step moves the seed by scale degrees in the template's key (a minor key is respelled by the harmony, with the raised leading tone over V). A step shifted by the wrong number of degrees fails, and so does a semitone-exact copy that leaves the key. The fugue builder declares its episodes step by step.
Inversion has the same two forms. A diatonic mirror flips each move along the scale; a chromatic mirror flips each interval semitone for semitone. The engine expects the diatonic one:
episode_motif_derived mirrors scale degrees in the key in force, as the fugue builder does for its inverted middle entry.Bach builds whole stretches of fugue from the diatonic form. In the D♯ minor fugue the subject and its mirror are full partners — the inverted form quoted below even arrives in stretto with another inverted entry:
episode_motif_derived checks an inverted episode against a diatonic mirror in the key in force. Quoted in E♭ minor spelling for readability; the companion voices around each entry are omitted, and the final note of each quote is trimmed to close the two-bar frame.The C minor fugue puts both ideas on display the moment its exposition pauses. Bars 5–6 — between the answer and the bass entry — sequence the subject's own head figure upward, one scale step per half bar, as a tonal sequence:
sequence_pattern_consistency is diatonic too: it expects each step to move the seed by scale degrees in the key, so Bach's version passes, whether declared as one sequence or step by step as the engine's fugue builder declares its episodes. The soprano's last F is tied on into bar 7, where the bass entry — the passage chapter 2 quotes for invertible counterpoint — takes over.| Rule | Contract |
|---|---|
episode_motif_derived | For a declared episode fragment, every note matches the expected output of the declared motif operation applied to the declared source slice — pitch, duration, and tick. Inversion mirrors scale degrees around a declared pivot in the key in force at the episode, not exact semitones. |
sequence_pattern_consistency | For a declared sequence, each step is the seed moved by the declared number of scale degrees in the template's key (1 for a step, 4 for a falling fifth), minor respelled per the harmony. A copy that leaves the key fails. |
Imitation
Imitation generalizes the subject/answer idea to any material: a follower restates the leader's fragment at a declared time distance and interval. imitation_entry_match verifies both numbers — enter at leader.tick + distance, pitched at leader.pitch + interval — and then compares every note of the declared window. In the engine, the fugue's answer is the declared imitation: the fugue builder and the fugue tails of the toccata and fantasia forms each declare their answer as an imitation of the subject.
A canon is imitation that never stops: the follower copies the leader for the whole piece. Bach wrote a set of them into the Goldberg Variations, one every third variation, with the interval growing by one step each time. The last of them, a canon at the ninth, keeps the follower one bar behind:
| Variation | Canon at | Bach | Engine's Goldberg model |
|---|---|---|---|
| 3 | unison | upright, over a free bass | upright, one bar behind |
| 6 | second | upright, over a free bass | upright, one bar behind |
| 9 | third | upright, over a free bass | upright, one bar behind |
| 12 | fourth | follower inverted | upright, one bar behind |
| 15 | fifth | follower inverted, in G minor | upright, one bar behind |
| 18 | sixth | upright, over a free bass | upright, one bar behind |
| 21 | seventh | upright, in G minor | upright, one bar behind |
| 24 | octave | upright, over a free bass | upright, one bar behind |
| 27 | ninth | upright, two voices and no bass | upright, one bar behind, over the aria bass |
The engine's Goldberg model writes each canon the way Bach writes most of his: the follower is a diatonic transposition of the leader by the canon's number of scale steps, one bar later. It does not invert the canons at the fourth and fifth, it keeps the aria bass under every block, and it does not declare its canons as imitation entries, so imitation_entry_match does not apply to them; the canons are checked by the ordinary voice-leading rules.
Development devices
Middle entries
After the exposition, the subject returns in related keys.
What makes a key "related"?
Two keys are related when their scales share most of their notes, so the ear can slide between them without a jolt. The dominant and subdominant keys differ from home by a single accidental; the relative key (vi of a major key — A minor for C major) uses the same notes with a different center.
A key has five closely related keys, the ones whose scales differ from it by at most one accidental. Bach's middle entries draw on all five; the engine uses a subset:
| Home key | Bach's closely related keys | Validator accepts | Fugue builder uses |
|---|---|---|---|
| C major | G (V), F (IV), A minor (vi), D minor (ii), E minor (iii) | V, vi, IV, ii | V, vi, IV, each spelled in its own key |
| C minor | E♭ (III), G minor (v), F minor (iv), A♭ (VI), B♭ (VII) | v, III, iv | v, III, iv, as degree shifts inside C minor |
middle_entry_in_related_key checks the declared key and every note of the entry. A V, IV or ii entry is checked against that key's major scale. A vi entry is checked against its own minor collection, natural minor plus the raised seventh, so an A minor entry may use G♯. Every minor-mode entry is checked against the home minor collection: pitch-class offsets {0, 2, 3, 5, 7, 8, 10, 11} from the tonic, which holds both the natural and the raised seventh.
The builder's minor stations do not modulate. A "v" entry in C minor is the subject moved up four scale steps inside C minor, so it has no F♯, the leading tone a real G minor entry would need; the station states the chord on G rather than the key of G minor.
Stretto
No fugue demonstrates the device like the C major fugue that opens WTC I — Bach builds nearly the whole piece from strettos. By bar 7 the subject is already chasing itself at one beat's distance:
stretto_overlap_valid demands. (The bass voice of these bars is omitted for clarity.)Pedal point
The pedal point usually arrives near the end — a dominant pedal building tension before the final cadence, or a tonic pedal confirming arrival. Notice the rule's direction: it does not police the dissonances above the pedal (those are licensed by the device), it polices the pedal pitch itself.
The first prelude of WTC I shows the device at its barest. Before the ending, Bach spends eight bars hammering nothing but the dominant in the bass — here are two of them:
How the engine lays out a fugue
The fugue builder follows one plan, so every generated fugue shows these devices in the same order. The figure lays out a 48-bar fugue in a major key.
- The subject fits in four bars. The answer enters at bar 5 with the countersubject above it, and the third voice enters with the subject at bar 9. Fugues under 20 bars keep only the first two entries.
- The development alternates a four-bar middle entry with an episode, four bars long in most lengths and two to six bars in fugues of 80 bars or more. Entries rotate through the three voices and through V, vi and IV (v, III and iv in minor), and one of the other voices restates the countersubject.
- With three or more development entries, the second one is stated in diatonic inversion.
- The stretto sits at the entry nearest 80% of the development: another voice restates the subject one to three bars later, at the octave or the fifth. About one fugue in three with four or more entries adds a second stretto.
- With two or more entries, the last one is stated in the dominant over a held dominant pedal.
- The coda states the head of the subject in augmentation (double note values) and closes with a two-bar cadence.
- Fugues of 96 bars or more also state the subject once in augmentation and once in diminution.
The fugue tails of toccata_and_fugue and fantasia_and_fugue are shorter: exposition, stretto and cadence, with figuration instead of episodes between them. Below 32 bars they have no stretto, and below 24 bars the exposition has two entries and no bass entry.
How the validator sees this chapter
| Rule | Outcome | Check |
|---|---|---|
tonal_answer_dominant_mapping | MusicalFail | Reads the first note only: a subject opening on the tonic is answered on the dominant, and the reverse. Subjects opening on another degree pass. |
countersubject_continuous | MusicalFail | The countersubject voice sounds at every quarter-beat of the answer window. |
countersubject_invertible | Informational | A strong-beat perfect fifth between a marked countersubject and an overlapping subject or answer would become a fourth under octave inversion. This observation is informational and never blocks generation. |
episode_motif_derived | MusicalFail | Episode notes equal the declared motif transform of the declared source slice; inversion is a diatonic mirror in the key in force. |
sequence_pattern_consistency | MusicalFail | Each sequence step moves the seed by the declared number of scale degrees in the template's key. |
imitation_entry_match | MusicalFail | Follower enters at the declared tick distance and interval, and every note of the window matches; a tonal answer may swap tonic and dominant within its first four notes. |
imitation_entry_realization | MusicalFail | During Generation, emitted Material notes must match the declared leader/follower windows in pitch, onset, duration, voice, and intent; both entry heads need the realization marker. |
middle_entry_in_related_key | MusicalFail | In major mode, entry key ∈ {V, vi, IV, ii}; V, IV and ii entries stay in their key's major scale, a vi entry in its own minor collection (with the raised seventh). In minor mode, entry key ∈ {v, III, iv}; notes use home-minor pitch-class offsets {0, 2, 3, 5, 7, 8, 10, 11}. |
stretto_overlap_valid | MusicalFail | Follower starts strictly inside the leader's subject window and is an exact transposition. |
pedal_point_tonic_or_dominant | MusicalFail | Every pedal pitch class is the home tonic or dominant. |
Continue with Chapter 7 — Form-Specific Constraints.