Generate chords, bass, drums or melody
midi_composeGenerates deterministic MIDI parts—chords, bass, drums, melody, harmonization, or backing tracks—from a key, length, and seed, optionally matching a song's tempo, meter, key, and chords.
Instructions
Generates music from a key, length and seed: a chord progression, voicings, a bass line, drums, a melody, a motif, a rhythm, a counter-melody to a given melody, chords for a given melody (harmonize), or a ready backing (chords, bass and drums in one file). Writes a .mid; the same arguments and seed always give identical files. Pass 'context' (a song's audio, .mid or project file) to take tempo, meter, key, chords and length from it, so the part fits the song and the file's tempo map equals the song's. Use it for 'make a chord progression', 'add a bass line', 'drum pattern' or a quick accompaniment; Inputs per part: progression {key, style, bars}; bass {chords, style}; drums {style, bars}; counterMelody {melody, chords?}; melody {melody? as the reference}; motif {key, bars, style = contour}; rhythm {time_signature, bars}; harmonize {melody}; voicing {chords, style}; backing {key, style, bars}. Not for changing existing notes (use midi_edit), for analyzing chords (use theory_analyze) or for audio (put the .mid on a project track with project_edit addMidiClip, then project_render). Example: {"part": "bass", "context": "song.sonare.json", "seed": 7}.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"part": "<part>"
},
"name": "midi_compose"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| key | No | Key such as 'C major', 'A minor', 'D dorian'. Default: the context's key, else 'C major' (harmonize infers it from the melody instead). | |
| bars | No | Length in bars (1-128). Default: the context's length, else 4. Ignored by bass and voicing (the chords set the length), counterMelody and harmonize (the melody does). | |
| part | Yes | What to generate: progression, bass, drums, counterMelody, melody, motif, rhythm, harmonize, voicing, backing. Inputs per part: progression {key, style, bars}; bass {chords, style}; drums {style, bars}; counterMelody {melody, chords?}; melody {melody? as the reference}; motif {key, bars, style = contour}; rhythm {time_signature, bars}; harmonize {melody}; voicing {chords, style}; backing {key, style, bars}. | |
| seed | No | Random seed 0-4294967295; the same arguments and seed give identical files (default 0). | |
| style | No | Style per part: progression and backing take a progression style (minimal, dance, idol, rock); bass takes root, rootFifth, pop, walking or arpeggio; drums takes standard, funk, shuffle, bossa, trap, halftime, breakbeat, house or synthpop; voicing takes smooth, close, drop2, drop3, shell or rootless; motif takes arch, ascending, descending or wave; counterMelody takes strict or pop; harmonize takes diatonic, secondaryDominant or borrowed (reharmonization). melody and rhythm take none. Defaults: progression minimal, bass root, drums standard, voicing close, backing minimal. | |
| chords | No | Chords for bass and voicing (needed there unless the context gives them) and optionally counterMelody. | |
| detail | No | 'concise' returns the summary and the most useful fields; 'full' returns all. | concise |
| melody | No | Melody for counterMelody and harmonize (required there) and optionally melody (as the reference to derive from): inline tracks, or the path of a .mid or project file. The first non-drum track with notes is used. | |
| output | No | Output .mid path. Omit to auto-name a file in the output directory. | |
| context | No | An audio file, a .mid file or a project file (.sonare.json) to take the tempo map, time signature, key, chords and length (bars) from. The written file carries the context's tempo map. Explicit key, chords, tempo_bpm, time_signature and bars win and are listed in derived_from.overridden. A .mid context carries no key or chords; chords from audio or a project need a libsonare that converts seconds to PPQ and reads annotations. | |
| dry_run | No | Generate and report, with the planned path, without writing. | |
| overwrite | No | Replace an existing file at 'output' (default false). | |
| tempo_bpm | No | Constant tempo in quarter notes per minute, written into the file. Default: the context's tempo map, else 120. | |
| time_signature | No | Time signature. Default: the context's first one, else 4/4. drums accepts only 4/4. |