Forms
MIDI Sketch Bach generates compositions in ten Baroque instrumental forms. Each form follows specific compositional rules and produces distinct musical structures.
If the form names are unfamiliar
Read a form name as a composition template, not just a style label. The form decides the number of voices, the meter, the reference length, and which musical materials are fixed or generated. For vocabulary such as subject, ground bass, and cantus firmus, see the Music Primer for Engineers.
The form decides the voice count
Each form fixes its own number of voices, meter, and natural length. The engine applies scale or targetBars, then snaps the result to the form's bar grid and clamps it between the form's minimum and 128 bars. A targetBars value of 0 uses scale; a positive value overrides it. See Option Relationships for the accepted range and snapping caveat. There is no numVoices option — choose the form to choose the texture.
Character also shapes performance
character selects the melodic and figuration profile. Every form applies that profile to note articulation and the MIDI CC profile in the finished output. In cello_prelude, it also orders the figure palette used for each bar. See Instruments for the instrument-specific expression output.
| Form | Voices | Meter | Natural length | Min bars | Grid | Default instrument |
|---|---|---|---|---|---|---|
fugue | 3 | 4/4 | 44 bars | 20 | 4 | Organ |
prelude_and_fugue | 3 | 4/4 | 24 bars | 24 | 4 | Organ |
trio_sonata | 3 | 4/4 | 16 bars | 8 | 4 | Organ |
chorale_prelude | 3 | 4/4 | 16 bars | 8 | 4 | Organ |
toccata_and_fugue | 3 | 4/4 | 32 bars | 16 | 4 | Organ |
passacaglia | 3 | 3/4 | 24 bars | 16 | 8 | Organ |
fantasia_and_fugue | 3 | 4/4 | 32 bars | 16 | 4 | Organ |
cello_prelude | 1 | 4/4 | 8 bars | 8 | 4 | Cello |
chaconne | 3 | 3/4 | 16 bars | 8 | 4 | Violin |
goldberg_variations | 3 | 4/4 | 20 bars | 12 | 4 | Harpsichord |
The grid is the multiple the resolved length is rounded to. scale multiplies the natural length by 1, 2, 3, or 4 for short, medium, long, and full.
Organ System (Forms 0--6)
Seven forms covering the major genres of Bach's organ repertoire.
0. Fugue
A pure contrapuntal fugue -- the cornerstone of Baroque polyphony.
Structure: Opens with a single-voice subject statement in bars 1–4, followed by the answer (typically at the fifth) in bars 5–8 and a third entry in bars 9–12 (the exposition). Every subject fits in four bars. Each voice waits for its own thematic entry. Development entries alternate with authored, motif-derived Fortspinnung episodes — short motifs spun into sequential continuations. The episodes thin to two voices before the final episode restores all three; see Voice Architecture for the rest rotation and bass support. A four-bar coda closes in the home key. Which development devices appear depends on length; see Fugue devices by form and length.
Reading the fugue description
The subject is the main theme. The answer is the same idea entering in another voice, usually shifted by a fifth. An episode is a freer connector between subject entries. Stretto means entries overlap before the previous one finishes.
- Default instrument: Organ
- Voices: 3
- Meter: 4/4
- Natural length: 44 bars
- Character: Intellectual, architecturally rigorous
Bach's Fugues
Bach's organ fugues (e.g., BWV 578 "Little" Fugue in G minor, BWV 542) are among the most celebrated works in the repertoire. The fugue is the most structured of all Baroque forms, with strict rules governing how voices enter and interact.
generator.generate({
form: 'fugue',
key: 7, // G
isMinor: true,
character: 'playful'
})1. Prelude and Fugue
A flowing prelude paired with an elaborate fugue, following the model of Bach's Well-Tempered Clavier and organ preludes.
Structure: The prelude establishes the key through idiomatic keyboard figuration -- arpeggiated patterns, sequential passages, or motivic development. It takes about a third of the piece (rounded to a multiple of 4 bars, between 4 and 32), and the fugue gets at least 20 bars, so the default 24 bars split 4 + 20. The fugue is built by the same assembler as the standalone fugue: exposition, middle entries, stretto, and a coda, with episodes where the development has room.
- Default instrument: Organ
- Voices: 3
- Meter: 4/4
- Natural length: 24 bars
- Character: Balanced, with a flowing prelude and intellectual fugue
Bach's Preludes and Fugues
The pairing of prelude and fugue is one of Bach's signature forms, represented in both the Well-Tempered Clavier (BWV 846--893) and the great organ preludes and fugues (for example BWV 532 and 548).
generator.generate({
form: 'prelude_and_fugue',
key: 0, // C
isMinor: false
})2. Trio Sonata
A three-voice texture modeled on Bach's organ trio sonatas, where two upper voices interact over an independent bass line.
Structure: The two upper voices engage in imitative counterpoint, trading melodic ideas while maintaining independence. The bass voice (typically played on the organ pedals) provides a foundation with its own melodic character. A longer scale setting extends this continuous layout and its internal periods; it does not add separate movements.
- Default instrument: Organ
- Voices: 3
- Meter: 4/4
- Natural length: 16 bars
- Character: Conversational, with two "treble" voices in dialogue
Bach's Trio Sonatas
Bach's six organ trio sonatas (BWV 525--530) are among the most demanding works in the organ repertoire, requiring complete independence of both hands and feet. Each "voice" has its own manual or the pedals.
generator.generate({
form: 'trio_sonata',
key: 5, // F
isMinor: false,
bpm: 90
})3. Chorale Prelude
A setting of a hymn melody (chorale) with contrapuntal accompaniment.
Structure: The engine models the texture of the Schübler chorale prelude BWV 645: the chorale melody sits in the middle voice, one whole note per bar, in the C3 region; a running figuration voice moves above it (C4 and up) and a quarter-note walking bass supports it below (C2 to B2), landing on the root of each bar's chord. The chorale is not a quoted tune. The engine generates a hymn-like melody from the seed in four-bar phrases, alternating authentic and half cadences, with the final phrase closing on the tonic.
Cantus firmus
A cantus firmus is a fixed melody in long notes. Each bar's downbeat tone is an immutable skeleton that the figuration and bass are built around; the ornament pass may decorate only the notes inside a bar (never under Severe).
- Default instrument: Organ
- Voices: 3
- Meter: 4/4
- Natural length: 16 bars
- Character: Devotional, meditative; figuration above, cantus firmus in the middle, bass below
Character restriction
playful and restless characters are rejected for the chorale prelude — generation throws. Use severe or noble for this devotional form.
Bach's Chorale Preludes
Bach composed over 150 chorale preludes throughout his career, from the Orgelbüchlein (BWV 599--644) to the "Leipzig" Chorales (BWV 651--668). The Schübler Chorales (BWV 645--650), from which the engine takes its texture, are organ transcriptions of cantata movements. The chorale prelude tradition was central to the Lutheran liturgy.
generator.generate({
form: 'chorale_prelude',
key: 9, // A
isMinor: false,
character: 'noble',
bpm: 66
})4. Toccata and Fugue
A dramatic two-part work combining a free-form toccata with a strict fugue.
Structure: A free toccata section is followed by a self-contained fugue (the fugue tail). In the toccata, V0 runs figuration, V2 sustains chord roots as a pedal point, and V1 punctuates with short chord tones. The section ends on a half cadence (V); the fugue's answer enters over that dominant, and the home key returns by the end. The tail is exposition, stretto, and a two-bar cadence with figuration in between, not episodes. See Sectional split.
- Default instrument: Organ
- Voices: 3
- Meter: 4/4
- Natural length: 32 bars
- Character: Grand, dramatic, and virtuosic
Character restriction
The noble character is rejected for the toccata and fugue — generation throws. The form's virtuosic energy suits severe, playful, or restless.
Bach's Toccatas and Fugues
The Toccata and Fugue in D minor (BWV 565) is traditionally attributed to Bach, although its authorship has been debated. The toccata (from Italian "toccare" — to touch) showcases the player's virtuosity with free-flowing passage work before the structured fugue begins. See the Netherlands Bach Society's BWV 565 notes.
generator.generate({
form: 'toccata_and_fugue',
key: 2, // D
isMinor: true,
character: 'restless',
bpm: 80
})5. Passacaglia
A variation form built over a repeating bass theme (ostinato).
Structure: Historically, passacaglia and chaconne labels overlap, and recurring bass or harmonic frameworks can be revoiced and ornamented across variations (SFCM's ostinato analysis). In this engine, the form opens with a bass carrier, then adds a principal variation line and a middle counterline over it. The ground is an eight-bar sequence of one sustained note per bar, chosen by the seed and repeated exactly in every cycle. That carrier is deliberately immutable across the generated variations.
- Default instrument: Organ
- Voices: 3
- Meter: 3/4
- Natural length: 24 bars
- Character: Building intensity, monumental
Bach's Passacaglia
Bach's Passacaglia and Fugue in C minor (BWV 582) is a masterpiece of the variation form, building 20 variations over an 8-bar bass theme before culminating in a double fugue. The form originated in 17th-century Spain and Italy.
generator.generate({
form: 'passacaglia',
key: 0, // C
isMinor: true,
scale: 'long'
})6. Fantasia and Fugue
A pairing of a free-form fantasia with a structured fugue.
Structure: The fantasia section features improvisatory, rhapsodic writing — bold harmonic explorations, unexpected modulations, and dramatic gestures unconstrained by strict form. It leads into a fugue tail built the same way as the toccata's: exposition, stretto, and a two-bar cadence, with figuration instead of episodes. The free section keeps at least two voices sounding. See Sectional split.
- Default instrument: Organ
- Voices: 3
- Meter: 4/4
- Natural length: 32 bars
- Character: Imaginative fantasia, disciplined fugue
Bach's Fantasias and Fugues
Bach's organ fantasias and fugues (for example, BWV 537 and 542) combine the improvisatory freedom of the fantasia — from the Italian "fantasia" (imagination) — with the intellectual discipline of the fugue. The Fantasia and Fugue in G minor (BWV 542) is considered one of the greatest organ works ever written.
generator.generate({
form: 'fantasia_and_fugue',
key: 7, // G
isMinor: true,
bpm: 88
})Fugue devices by form and length
Four forms contain a fugue, and they do not build the same one. fugue and prelude_and_fugue share an assembler that adds devices as the development gets room for them. toccata_and_fugue and fantasia_and_fugue end in a shorter fugue tail with a fixed shape. Every fugue builds an exposition, a real or tonal answer, and a countersubject (the recurring accompanying line).
Terms used below
An entry cycle is one middle entry, a four-bar subject statement, plus the episode after it. A middle entry is a subject statement after the exposition, usually in a related key. Stretto is two statements of the subject overlapping, the second entering before the first ends. A dominant pedal is a held bass note on the fifth scale degree under the harmony above, building tension before the home return. Bar counts are for the fugue section only (the whole piece for fugue).
Devices
| Device | What the engine builds |
|---|---|
| Exposition | Subject in V0 (bars 1–4), answer in V1 (bar 5), third entry in V2 (bar 9). Every subject fits in four bars. |
| Middle entries | The entry voice rotates V0, V1, V2 and each voice has a fixed key area (table below). |
| Stretto | At the entry cycle nearest 80% of the entry span. The follower enters at the octave or the fifth, 1 to 3 bars after the leader. The 3-bar delay is used only for a subject that combines with itself at no closer distance. |
| Inverted entry | The second entry cycle states the subject mirrored. Needs at least 3 entry cycles. |
| Second stretto | Needs at least 4 entry cycles; the seed enables it in about one fugue in three. |
| Dominant pedal | On the last entry cycle, when the development has at least 2 entry cycles. V0 carries the subject over the held dominant. |
| Coda | A final subject entry in V0 over two bars, then a two-bar cadence. |
Middle-entry key areas, by the voice that carries the entry (the pedal cycle always states the dominant in V0):
| Carrying voice | Major | Minor |
|---|---|---|
| V0 | V | v |
| V1 | vi | III |
| V2 | IV | iv |
In major each station is a real key: the entry is transposed into it and arrives with that key's accidentals. In minor the station is a degree shift inside the home key, so every note stays in the home minor collection and the chord changes without a key change.
By form and length
fugue and prelude_and_fugue (uniform 8-bar entry cycles; the fugue section is the whole piece for fugue and the piece minus the prelude for prelude_and_fugue):
| Fugue section | Entry cycles | Devices present |
|---|---|---|
| 20 bars | 1 | Middle entry with no episode after it; stretto on that entry |
| 24 bars | 1 | Adds a 4-bar episode |
| 28 bars | 1 | Adds a second, entry-less 4-bar episode |
| 32 bars | 2 | Adds the dominant pedal on the last entry cycle |
| 40 bars | 3 | Adds the inverted entry |
| 48 bars and up | 4 or more | Adds the seed-gated second stretto |
The coda and the three-entry exposition are present at every length. Middle entries and stretto appear even at 20 bars; episodes appear only where the development has room for one.
toccata_and_fugue and fantasia_and_fugue (the tail after the free section):
| Piece length | Tail | Exposition | Stretto | Between entries |
|---|---|---|---|---|
| below 24 bars | 10–12 | Two entries (subject, answer); no bass entry | None | Figuration |
| 24–31 bars | 16 | Three entries | None | Figuration |
| 32 bars and up | 20 or more | Three entries | One, near the climax | Figuration |
The tail has no episodes, middle entries, inversion, or pedal; it ends in a two-bar cadence, with a Picardy third on seeds that elect it in a minor key (the final chord is major).
Sectional split for toccata and fantasia
The free section takes about three eighths of the piece, rounded to a multiple of 4 bars and never below 8, while the fugue tail keeps at least 10 bars for a complete four-bar answer plus the cadence.
| Piece length | Free section | Fugue tail |
|---|---|---|
| 16 bars | 6 | 10 |
| 20 bars | 8 | 12 |
| 24 bars | 8 | 16 |
| 32 bars | 12 | 20 |
| 48 bars | 20 | 28 |
| 64 bars | 24 | 40 |
Solo Instrument System (Forms 7--8)
Two forms for unaccompanied string instruments.
7. Cello Prelude
A flowing prelude for solo cello, modeled on the opening movements of Bach's Cello Suites.
Structure: A single continuous line can outline harmonic progressions through broken chords and other figuration. Implied voices emerge from register shifts — bass notes, inner harmonies, and upper melodies interweave within one melodic line. The character orders the builder's figure palette for each bar, so its surface pattern changes while the voice count stays one.
- Default instrument: Cello
- Voices: 1
- Meter: 4/4
- Natural length: 8 bars
- Character: Flowing, harmonically rich, meditative
Bach's Cello Suites
The six Suites for Unaccompanied Cello (BWV 1007--1012) are cornerstones of the cello repertoire, but their preludes use different textures. The First Suite opens with flowing broken-chord writing, while the Fifth Suite (BWV 1011) begins with a slow French-overture texture before its faster continuation. These idiomatic solo lines can imply several voices without all being arpeggiated; see the Netherlands Bach Society's BWV 1011 notes.
generator.generate({
form: 'cello_prelude',
key: 7, // G
isMinor: false,
instrument: 'cello'
})8. Chaconne
A monumental variation form for solo violin, inspired by the Chaconne from Bach's Partita No. 2 in D minor.
Structure: The engine declares three lanes for its repeating 3/4 cycle: V0 carries the variation, V1 is a middle line that realises the ground's implied harmony when clean register space is available, and V2 carries the ground: a four-bar sequence of one sustained note per bar, repeated exactly. V1 starts as a rest and may withdraw from individual bars or whole cycles where no clean placement exists. Bach's BWV 1004 Chaconne realizes its recurring harmonic and bass framework through double stops, arpeggiated figuration, and implied voices, so the historical texture is richer than the engine's three-lane abstraction.
- Default instrument: Violin
- Voices: 3
- Meter: 3/4
- Natural length: 16 bars
- Character: Epic, intensely expressive, architecturally grand
Bach's Chaconne
The Chaconne from Partita No. 2 in D minor (BWV 1004) is widely regarded as one of the greatest achievements in all of music. In approximately 15 minutes, Bach builds an entire world from a simple harmonic framework, exploring every register and technique available to the violin.
generator.generate({
form: 'chaconne',
key: 2, // D
isMinor: true,
instrument: 'violin'
})Variation System (Form 9)
9. Goldberg Variations
A theme-and-variations cycle modeled on Bach's Goldberg Variations (BWV 988), with a repeated four-bar immutable carrier in the engine's abstraction.
Structure: The engine's layout is a compressed model of the set, not a reconstruction of the BWV 988 score. The two sides differ as follows.
| Bach's BWV 988 | This engine | |
|---|---|---|
| Frame | Aria, thirty variations, Aria da capo | One four-bar block per variation; an aria block opens, and from 24 bars up an aria restatement with a closing coda ends the set |
| Ground | A fundamental bass the variations preserve while surface notes, durations, and textures change | A dedicated four-bar aria-bass phrase (one chord root per bar, three variants per mode, chosen by the seed) tiled into every four-bar block as an immutable carrier |
| Canons | Every third variation from 3 through 27, at an interval rising from unison to the ninth | The same positions and intervals; the follower is the leader moved a fixed number of scale steps (diatonic, not a chromatic transposition), re-spelled under the chord it sounds in |
| Variation 30 | A Quodlibet | A Quodlibet slot: the densest figuration plus a second recurring chord-tone tune in the middle voice |
| Ending | Aria da capo | From 24 bars up the aria returns. Either way the last bars close on a tonic triad, with the leading tone sounded in the dominant approach. A set too short for a da capo ends on a free variation instead of a cut-off canon |
Length sets how much of the cycle is built. The default 20 bars hold the aria and four variations (the third is the first canon). scale: "full" without a positive targetBars gives 128 bars: the aria, all thirty variations (nine canons and the Quodlibet slot), and the aria da capo. A positive targetBars overrides the scale. See the Bach-Archiv Leipzig overview and the Netherlands Bach Society's BWV 988 notes.
- Default instrument: Harpsichord
- Voices: 3
- Meter: 4/4
- Natural length: 20 bars
- Character: Inventive, encyclopedic, architecturally unified
Bach's Goldberg Variations
The Goldberg Variations (BWV 988) are a pinnacle of the variation form: an aria and thirty variations, with canons at every third variation from 3 through 27 and a Quodlibet at 30. The variations share the aria's fundamental-bass and harmonic framework, while their sounding bass lines and textures change.
generator.generate({
form: 'goldberg_variations',
key: 7, // G
isMinor: false,
instrument: 'harpsichord'
})Form Selection by Use Case
| Use Case | Recommended Forms |
|---|---|
| Grand organ work | Toccata and Fugue, Fantasia and Fugue, Prelude and Fugue |
| Studying counterpoint | Fugue, Trio Sonata |
| Solo cello piece | Cello Prelude |
| Solo violin piece | Chaconne |
| Meditative/devotional | Chorale Prelude |
| Variation techniques | Passacaglia, Chaconne |
| Chamber ensemble texture | Trio Sonata |
| Theme and variations | Goldberg Variations |
| Complex polyphony | Fugue, Fantasia and Fugue |
| Dramatic, virtuosic work | Toccata and Fugue, Fantasia and Fugue |
TIP
See the Presets Reference for complete default values and valid ranges for each form.