quantize_clip
Fix timing in MIDI clips by snapping notes to a specified beat grid. Adjust strength to preserve groove, or quantize note endings to alter note lengths.
Instructions
Quantize MIDI clip note positions and lengths to a specified beat grid.
Reads notes, calculates quantized positions, writes back using mode='replace',
and verifies the result.
Returns:
Dictionary with the write result, the number of notes moved, and how far.
Note:
Parameter interactions: ``strength`` scales note displacement towards ``grid`` from
0.0 (raw timing preserved) to 1.0 (full snap). Use partial strength (e.g. 0.5) to
tighten timing while preserving human groove feel. Setting ``quantize_ends=True``
snaps note ends to the grid too, adjusting note lengths. In contrast,
``quantize_ends=False`` shifts note onsets only and preserves articulation.
Quantising modifies notes in place and is not undoable. Read the notes first with
read_clip_notes if the original unquantized timing might be needed later.
To shift pitch instead of timing, use transpose_clip. To write custom or micro-timed
notes off-grid, use write_clip_notes.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| grid | No | Grid to snap to, in beats: 1.0 is a quarter note, 0.5 an eighth, 0.25 a sixteenth, and 0.3333 a triplet eighth. Must be positive. | |
| slot | Yes | Clip slot index in track.clip_slots, counted from 0. A slot index is the scene the clip sits in, so slot 2 is the third scene down. | |
| track | Yes | Track index in song.tracks, counted from 0. | |
| strength | No | How far to move each note towards the grid, 0.0 for not at all and 1.0 for all the way. 0.5 halves the distance and keeps some of the original feel. | |
| quantize_ends | No | True snaps note ends to the grid too, which changes durations. False moves onsets and leaves every duration as it was. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||