Write notes to a MIDI file
midi_writeWrites inline JSON note tracks, including tempo and time-signature maps, or exports a project's tracks to a Standard MIDI File (.mid) for playback or another program.
Instructions
Writes inline tracks (with an optional tempo map and time signatures), or a project file's tracks and tempo map, as a Standard MIDI File. Use it to turn notes you composed as JSON into a playable .mid file, or to export a project for another program. Not for changing the music (use midi_edit) and not for generating music (use midi_compose); to hear it, put the .mid on a project track with project_edit addMidiClip and call project_render. Example: {"source": [{"name": "lead", "program": 80, "notes": [{"pitch": 60, "start_ppq": 0, "length_ppq": 1}]}], "output": "lead.mid"}.
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": {
"source": "<source>"
},
"name": "midi_write"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| detail | No | 'concise' returns the summary and the most useful fields; 'full' returns all. | concise |
| output | No | Output .mid path. Omit to auto-name a file in the output directory. | |
| source | Yes | What to write: inline tracks, or a project file (its tracks and tempo map are exported). A .mid/.midi file path, a project file path (.sonare.json) or inline tracks [{name?, program?, channel?, is_drum?, notes: [{pitch, start_ppq, length_ppq, velocity}]}]. Track ids of a file are the core's (1, 2, ...); inline tracks count from 1. | |
| dry_run | No | Report what would be written, with the planned path, only. | |
| overwrite | No | Replace an existing file at 'output' (default false). | |
| tempo_segments | No | Tempo map for inline tracks (default: constant 120 BPM). Not for a project source, which carries its own. | |
| time_signatures | No | Time signatures for inline tracks (default: 4/4). Not for a project source. |