Skip to content

Presets Reference

Complete reference for all configurable presets in MIDI Sketch Bach.

Reading these tables

ID and String are API values. Voices, meter, raw natural bars, key, and character are musical structure choices. If those terms are new, keep the Music Primer for Engineers open while reading this page.

Forms Reference

All 10 Forms

IDNameStringCategoryDefault InstrumentVoicesMeterRaw Natural BarsShort Output Bars
0Fugue"fugue"OrganOrgan34/44244
1Prelude and Fugue"prelude_and_fugue"OrganOrgan34/42424
2Trio Sonata"trio_sonata"OrganOrgan34/41616
3Chorale Prelude"chorale_prelude"OrganOrgan34/41616
4Toccata and Fugue"toccata_and_fugue"OrganOrgan34/43232
5Passacaglia"passacaglia"OrganOrgan33/42424
6Fantasia and Fugue"fantasia_and_fugue"OrganOrgan34/43232
7Cello Prelude"cello_prelude"SoloCello14/488
8Chaconne"chaconne"SoloViolin23/41616
9Goldberg Variations"goldberg_variations"VariationHarpsichord34/42020

Bar counts

"Raw Natural Bars" is the form's base length before snapping. scale multiplies that value (~1x/2x/3x/4x), then the result snaps to the form's bar grid. Fugue's raw 42 bars therefore produce 44 bars with scale: "short". targetBars overrides scale, and every form caps at 128 output bars.

Natural bars are not seconds

A bar count is musical length, not wall-clock duration. Playback time also depends on bpm and meter. A 44-bar fugue at 80 BPM lasts longer than the same 44 bars at 140 BPM.

Form Selection Flowchart

Organ System (Forms 0--6)

The seven organ forms cover the major genres of Bach's organ repertoire. All default to organ registration and use three voices.

Solo Instrument System (Forms 7--8)

The two solo forms generate music for unaccompanied string instruments. The cello prelude is a single continuous line; the chaconne pairs a ground bass with an upper line. Implied polyphony emerges through register shifts, arpeggiation, and chordal writing.

Variation System (Form 9)

The Goldberg Variations form is a theme-and-variations cycle over an immutable bass, defaulting to harpsichord.

BWV References by Form
FormNotable Bach Works
FugueBWV 578 (G minor "Little" Fugue), BWV 542/2
Prelude and FugueBWV 532, 541, 548, 846--893 (Well-Tempered Clavier)
Trio SonataBWV 525--530 (Six Trio Sonatas)
Chorale PreludeBWV 599--644 (Orgelbüchlein), BWV 651--668
Toccata and FugueBWV 565 (D minor), BWV 540
PassacagliaBWV 582 (C minor)
Fantasia and FugueBWV 537, 542, 561
Cello PreludeBWV 1007--1012 (Cello Suites)
ChaconneBWV 1004/5 (Partita No. 2 in D minor)
Goldberg VariationsBWV 988

Instruments Reference

IDNameStringGM ProgramSoundAccepted by
0Organ"organ"19Church OrganOrgan forms (0--6)
1Harpsichord"harpsichord"6HarpsichordGoldberg Variations (9)
2Piano"piano"0Acoustic Grand PianoGoldberg Variations (9)
3Violin"violin"40ViolinChaconne (8)
4Cello"cello"42CelloCello Prelude (7)
5Guitar"guitar"24Nylon Guitar--

Instrument does not decide the composition

The instrument selects MIDI sound, playable range, and ornament density. It does not change voice count, meter, form layout, or validator rules; those come from form.

The form fixes the instrument

Every form except the Goldberg Variations accepts exactly one instrument — the one it was written for. Requesting another throws an incompatible-instrument error rather than transcribing the piece. The Goldberg Variations is the one form that offers a choice, between harpsichord and piano.

Subject Characters

IDNameStringEffect
0Severe"severe"Strict, intellectually rigorous (default)
1Playful"playful"Light, agile, rhythmically lively
2Noble"noble"Stately, broad, dignified
3Restless"restless"Driving, chromatic, dramatically charged

INFO

The character parameter affects the melodic profile of the fugue subject or primary thematic material. It has the most noticeable effect on fugal forms, where the subject defines the character of the entire piece. Two combinations are forbidden and throw: chorale_prelude rejects playful/restless, and toccata_and_fugue rejects noble.

Scale Modes

scale multiplies the form's natural length. targetBars overrides it.

IDNameStringApproximate Length
0Short"short"~1x natural (default)
1Medium"medium"~2x natural
2Long"long"~3x natural
3Full"full"~4x natural

TIP

The actual output length depends on each form's natural length (see the Forms Reference table above): the same scale produces different bar counts for different forms because each scales from its own natural length. Use targetBars for precise length control; values are clamped to [form minimum, 128].

Key Reference

IDNamePitch ClassCommon Baroque Associations
0CCPurity, simplicity, clarity
1C# / DbC#Devotion, depth
2DDTriumph, brilliance (D major); passion, drama (D minor)
3D# / EbEbHeroic grandeur, nobility
4EEJoy, brightness (E major); lament (E minor)
5FFPastoral, calm
6F# / GbF#Intensity, brilliance
7GGGrace, simplicity (G major); seriousness (G minor)
8G# / AbAbSolemn, devotional
9AATenderness, elegance (A major); gentle melancholy (A minor)
10A# / BbBbNobility, warmth
11BBHard brilliance (B major); somber weight (B minor)

Pitch class and mode

key chooses the pitch class, such as C or D. isMinor chooses major or minor. For example, key: 2, isMinor: false is D major; key: 2, isMinor: true is D minor.

Key Associations in Baroque Music

Baroque composers associated specific keys with emotional qualities (Affektenlehre). D minor was the key of passion and drama (BWV 565 Toccata and Fugue), while C major represented purity (BWV 846 Prelude). These associations are subjective and vary by era, but they influenced Bach's choice of key for his compositions.

All keys work with both isMinor: false (major) and isMinor: true (minor).

Default Mapping

Cross-reference of form defaults (voices and meter are fixed by the form; BPM defaults to 100 unless you set it):

FormInstrumentVoicesMeterShort Output Bars
FugueOrgan (0)34/444
Prelude and FugueOrgan (0)34/424
Trio SonataOrgan (0)34/416
Chorale PreludeOrgan (0)34/416
Toccata and FugueOrgan (0)34/432
PassacagliaOrgan (0)33/424
Fantasia and FugueOrgan (0)34/432
Cello PreludeCello (4)14/48
ChaconneViolin (3)23/416
Goldberg VariationsHarpsichord (1)34/420

Programmatic Access

Use the preset enumeration functions to access these values at runtime:

js
import {
  init,
  getForms,
  getInstruments,
  getCharacters,
  getDefaultInstrumentForForm,
  getKeys,
  getScales,
  getVersion
} from '@libraz/midi-sketch-bach'

await init()

// List all forms
const forms = getForms()
for (const form of forms) {
  console.log(`${form.id}: ${form.display ?? form.name}`)
}
// 0: Fugue
// 1: Prelude and Fugue
// 2: Trio Sonata
// 3: Chorale Prelude
// 4: Toccata and Fugue
// 5: Passacaglia
// 6: Fantasia and Fugue
// 7: Cello Prelude
// 8: Chaconne
// 9: Goldberg Variations

// List all instruments
const instruments = getInstruments()
// [{ id: 0, name: "organ" }, ...]

// List all keys
const keys = getKeys()
// [{ id: 0, name: "C" }, { id: 1, name: "C#" }, ...]

// Look up a form's default instrument ID
const celloPreludeInstrument = getDefaultInstrumentForForm(7)
// 4 (cello)

TIP

These functions are useful for building UI components like dropdowns or form selectors. The demo on this site uses them to populate the form selection interface.

getDefaultInstrumentForForm(formId: number): number accepts form IDs 0--9. Invalid or out-of-range values return 0 (organ).

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