quantize_clip
Align MIDI notes to a beat grid in an Ableton Live clip. Tighten timing by snapping note starts, with optional strength to preserve groove and quantize ends to adjust note durations.
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. | |
| path | No | LOM path to a Session clip, song.tracks[N].clip_slots[M] with or without a trailing .clip, as an alternative to track and slot. A song.tracks[N].arrangement_clips[i] path is refused with code region_not_addressable. | |
| slot | No | Clip slot index in track.clip_slots, counted from 0, which is the scene the clip sits in. Give track and slot, or give path instead. These are Session coordinates; an Arrangement clip has none. | |
| track | No | Session track index in song.tracks, counted from 0. Give track and slot, or give path instead. These are Session coordinates; an Arrangement clip has none. | |
| 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 | |||