To build a fugue into B.A.C.H., I started from the basics, from what a textbook fugue is: the module creates a subject, brings it into the voices following the classical plan, and hands everything that is not thematic to a counterpoint solver.

By Gilles de Kaona

The FUGUE algorithm does not replay any score from The Art of Fugue. The reference to Bach goes without saying: it is a natural tribute to a musician who has been part of my life for as long as I can remember. Yet at no point are the master's scores used.

The word fugue is much older than Bach. The Latin fuga means both flight (fugere, to flee) and pursuit (fugare, to chase). It appears as early as the 14th century, describing voices that flee from and pursue one another by imitation (so it was originally a canon). Over four centuries the technique was refined, then taken to a remarkable level of complexity by Bach in The Well-Tempered Clavier and The Art of Fugue.

As you turn the encoders, your own fugues will emerge, more or less complex, and sometimes even on the edge… of no longer really being fugues!

The subject: eight models

The MATERIAL encoder selects one of eight families. Each one is a model written in scale degrees, and all of them touch the dominant.

Family Shape Rhythm
ARCH rises by thirds to the dominant, comes back down by step six eighth notes, one quarter note
FIFTHS arpeggio on tonic, dominant, octave; returns through the leading tone eight eighth notes
SCALAR rising scale up to the dominant, then back down sixteenth notes
SYNCOPATED leap to the dominant, return, another leap dotted eighth and sixteenth, a quarter note in the middle
TURN a turn (a small ornament of a few notes) around the tonic, then a rise towards the dominant sixteenth notes, then eighth notes
PEDAL the tonic returns every other note beneath a descending line eighth notes, final quarter note
WEDGE fans out on either side of the tonic eighth notes, final quarter note
CHORALE stepwise rise and fall, in chorale style quarter notes, final half note

With each new cycle, the engine derives a new statement from the model. The inner durations rotate by one position, which keeps the total length, and therefore the timing of the entries, unchanged. One or two inner notes shift by one degree, without leaving the range of the model. The first and last notes never move, and if the drift has erased the dominant, the nearest inner note restores it. The family is always recognisable; the exact phrase changes from one cycle to the next.

A change of MATERIAL does not take effect immediately. The new value must stay stable for a full beat, then a new exposition starts at the beginning of the next bar. This prevents a sweep of the encoder across three families from triggering three aborted expositions. You can still force the change with the Reset button.

MEMORY: how faithful the subject stays

At each new section, the subject may mutate: an inner note moves by one degree, or two neighbouring rhythmic values swap places. The probability follows the inverse of MEMORY, and these mutations accumulate from one section to the next, within one degree of the model (two degrees below 45%). The countersubject is rebuilt behind it.

  • Above 72%, every section restores the subject of the current cycle: the recapitulation is literal.
  • Below that threshold, the drift continues without being erased: the theme travels step by step.
  • MEMORY also acts on the tonal plan. Above 60%, every other middle entry returns to the tonic; below 50%, the entries stray more and more often from the expected degrees.

Even at 100%, two successive cycles never present the same statement: the per-cycle derivation never drops to zero. This is deliberate. A fugue can run indefinitely without ever using exactly the same phrase, and so without producing a loop.

The form: a cycle in five stages

The fugue moves through exposition, episode, middle entry, stretto and coda, then returns to an exposition. Each section ends on a bar line and every entry falls on a whole beat.

  1. Exposition. The voices enter one after another, alternating subject (dux) and answer (comes). The order of entry rotates with each cycle among four: top to bottom, alto first, from the middle outwards, bottom to top. The gap between two entries equals the length of the subject, shortened by up to 45% by INTERACTION and rounded to the beat. A voice that has finished its subject moves on to the countersubject, then to free counterpoint.
  2. Episode. The first four notes of the subject are repeated as a descending sequence, one degree lower each time, over a harmony of descending fifths. The motif is repeated 2 to 6 times depending on GROWTH. Above 55% of MORPH, it is inverted. Above 50% of GROWTH, one episode can call for a second, carried by another voice.
  3. Middle entry. The subject returns in a single voice, transposed. Below 55% of TENSION, the transpositions stay close: dominant above or below, supertonic, leading tone. Above that, they range further afield: dominant, submediant, subdominant in the bass. The neighbouring voice holds the countersubject if DENSITY allows at least two entries. MORPH above 66% may invert the subject, above 85% play it in retrograde; GROWTH above 70% may augment it (doubled values).
  4. Stretto. After at least two middle entries, the stretto is called with a probability tied to TENSION: a 25% chance at mid-travel, 80% at 90%. Two overlapping entries, three above 60% of TENSION, within the limit set by DENSITY. The gap between them ranges from half the subject down to a fifth, always rounded to the beat. Above 50% of MORPH, every other entry is inverted.
  5. Coda. The bass holds a tonic pedal, renewed every bar. The harmony goes through I then IV, then V and I in the last bar: a cadence in which the solver leads the leading tone to the tonic.

Without a stretto, the form still closes: after 2 to 5 middle entries (depending on GROWTH), the coda arrives.

GROWTH sets the length of every section, within a range of 1 to 24 bars. This is recalculated at every step: turning GROWTH shortens or lengthens the section immediately, not just the next one. A shortened section never stops in the middle of a bar.

The answer and the countersubject

The answer is the subject transposed to the fifth, that is, to the scale degree closest to seven semitones. Below 50% of INTERACTION, the answer is tonal: on its first two notes, a dominant is answered by the tonic, as in simple fugues.

The countersubject is built, not copied. Its rhythm is offset: its first value lasts half as long as the subject's, so the attacks of the two lines never coincide. Its pitches are exclusively thirds and sixths against the subject, favouring contrary motion and stepwise movement. No fifths, no octaves, no unisons: the counterpoint is invertible at the octave, the thirds becoming sixths. In an exposition, where it accompanies an offset entry it cannot anticipate, it is "allowed" to bend by one degree to avoid a harsh dissonance; otherwise it keeps its contour.

The free voices and the solver

Every note that does not belong to the thematic material is chosen by a solver. It examines the nine degrees around the previous note and gives each one a penalty; the least penalised wins. In decreasing order of weight:

  • parallel fifths and octaves: very heavily penalised;
  • dissonance against a sounding note, especially on a strong beat;
  • unison with another voice;
  • a note outside the chord on a strong beat;
  • a repeated note;
  • an unresolved leap: after a leap, the voice is pushed to return by step in the opposite direction;
  • voice crossing;
  • moving away from its own register.

Contrary motion with the other voices is rewarded, and the leading tone is drawn towards the tonic. The fourth is only counted as a dissonance against the actual bass of the moment. A simple harmony, one chord per half bar, is shared by all four voices: tonic and dominant in the exposition, descending fifths in the episode, I-IV-V in the middle entry.

DENSITY never removes a thematic note. It decides how many entries the exposition has (one below 16%, two below 40%, three below 68%, then four) and how many free voices may sound on top (none below 28%, then one, two, three above 80%). It also sets how much they breathe: frequent rests at the bottom of the range, base values moving from quarter notes to eighth notes, and above 70% more and more sixteenth notes.

INTERACTION has two sides. Below 35%, the free voices avoid what the leading voice has just played: the lines are layered without answering one another. Above that, they imitate: they pick up a degree recently stated by the subject, with a delay that tightens from six notes to one as the encoder goes up. INTERACTION also tightens the entries of the exposition and decides whether the answer is tonal.

TENSION stays within the scale

Everything TENSION does in FUGUE is diatonic, except for one strictly limited case.

  • The suspension. On a chord change falling on a strong beat, a free voice may hold its note, which has become dissonant, then resolve it one degree lower. The probability rises to 60%, and only if the held note is foreign to the new chord and the degree below belongs to it.
  • The tolerated dissonance on strong beats increases, and the ban on voice crossing is relaxed.
  • Tonal distance: episodes start their sequence further from the tonic, and middle entries modulate further away.
  • The call to stretto, depending on TENSION.
  • The chromatic passing note, the only note outside the scale: above 45%, on a weak beat, when a voice moves up or down by a degree that is a whole tone, it may pass through the semitone in between. The target note follows immediately. At most 30% of these opportunities are taken.

MORPH: range and speed

MORPH acts continuously on every note played. It widens or narrows the contour of the subject (from half its intervals at the bottom of the range to 1.7 times at the top) and stretches or compresses its rhythm (values doubled at the bottom, halved at the top). At the centre, the subject is played as written. The change follows the encoder within a few sixteenth notes, without jolts. The inversions, retrogrades and augmentations described above are added to this effect beyond their thresholds.

The trade-offs

  • Material first. A fugue in which DENSITY disrupted the subject would no longer be a fugue. So DENSITY works in steps of orchestration rather than note by note.
  • The bar line first. MATERIAL waits for a beat and then the bar line, and GROWTH never cuts a bar short. Responsiveness suffers a little, but phrases are never broken.
  • No requantisation. FUGUE itself guarantees that every note belongs to the scale, which allows its chromatic passing note. It therefore ignores SEQUENCE, which is disabled for FUGUE.
  • BREAK resumes the form in progress. After a break, the fugue picks up exactly where it left off, instead of starting a new exposition.
  • Register. The four voices are spaced a perfect octave apart around ROOT, so intervals written in degrees keep their meaning from one voice to another. ROOT does not go below C2 for FUGUE, and the voicing moves up an octave if the bass would otherwise fall below C1.

How far a fugue can go

The rules stay the same whatever the encoder settings, but what they produce changes completely. Three extreme settings show it.

  • DENSITY at zero. Only one line remains: it states the subject, continues with the countersubject, then falls silent until the next entry. No free voice joins in. It is a one-voice fugue, closer to a monodic invention than to a fugue.
  • MORPH and TENSION at maximum. The subject opens up into wide intervals and moves twice as fast. Middle entries often come back inverted, sometimes in retrograde, and modulate to distant degrees. The stretto arrives in every cycle from the second middle entry. Voices cross, suspensions multiply and chromatic passing notes appear. The plan of the fugue is intact, but you hear it less and less.
  • GROWTH at zero, INTERACTION at maximum. Sections are cut to 40% of their length, the entries tighten and the answer is no longer tonal. The free voices, if DENSITY leaves room for them, keep echoing what the subject has just played. The whole cycle fits into a few bars: a miniature fugue of sorts, one that sounds almost like a canon.

Between these extremes, starting with the encoders at their centre, lies the textbook fugue. Everything that moves away from it is still built on the same rules.

So FUGUE is not a ready-made fugue but a composition tool. The module takes care of the overall construction: it leads the voices, avoids parallel fifths, steers the cadence and keeps the form. The musical decisions are yours: how many voices, which subject, how much tension, how long to linger in an episode, when to tighten the entries. And of course in which key, with what velocity response, with which ornaments or unexpected gestures from HUMANIZE.

You listen, you adjust, you start again, the way you work on a piece. The fugue that comes out of it is yours.