legato_midi_notes
Close gaps in selected MIDI notes by extending ends to the next onset, or set every targeted note to a fixed length without changing starts.
Instructions
Close the gaps in a MIDI line (legato), or set every note to one length.
Only note ends move; starts are never touched. "connect" extends each note's end to the next onset and never shortens anything; a gap wider than max_gap_beats is left as a rest and counted in gaps_preserved, and the last note is left alone. "fixed" instead sets every targeted note's length to length_beats. Notes whose new end passes the item end are kept and reported in out_of_bounds.
Args: mode: "connect" (extend each end to the next onset) or "fixed" (set every length). voice: connect only. "chordal" extends to the next onset of any note, so a chord's notes move together; "per_pitch" extends to the next note of the SAME pitch and channel, keeping interleaved voices independent. max_gap_beats: connect only. Gaps wider than this are left as rests (>= 0). length_beats: fixed only. The length every targeted note is set to (> 0).
Returns: {ok, notes_changed, clamped, skipped, out_of_bounds, gaps_preserved, notes:[...]}.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | connect | |
| voice | No | chordal | |
| fields | No | ||
| channel | No | ||
| end_beat | No | ||
| pitch_low | No | ||
| item_index | Yes | ||
| pitch_high | No | ||
| start_beat | No | ||
| track_index | Yes | ||
| length_beats | No | ||
| return_notes | No | ||
| max_gap_beats | No |