remove_overlapping_midi_notes
Resolve overlapping MIDI notes on the same pitch and channel by trimming earlier notes or deleting quieter ones to clean up your MIDI track.
Instructions
Clean up overlapping MIDI notes (same pitch stacked on itself).
Two notes conflict only if they share a pitch AND a channel AND overlap in time, so a chord is never a conflict and notes that merely touch are left alone. "trim" shortens the earlier note to stop where the next begins, losing nothing; "delete" drops one note of each overlapping pair, keeping the louder (ties go to the longer note).
Either mode can remove notes: notes stacked on the exact same onset collapse to the loudest, since there is nothing to trim between them, and a trim left shorter than min_length_beats is removed rather than left as a click.
Args: mode: "trim" (shorten the earlier note) or "delete" (drop the quieter note). min_length_beats: A trimmed note left shorter than this is removed instead. Default 1/128 of a beat; 0 disables it. pitch_low, pitch_high: Notes outside the filter are invisible: never touched, and never counted as an overlap partner.
Returns: {ok, mode, notes_changed, clamped, skipped, out_of_bounds, notes_removed, trimmed, deduped, deleted, notes:[...]} where notes_removed = deduped + deleted.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mode | No | trim | |
| fields | No | ||
| channel | No | ||
| end_beat | No | ||
| pitch_low | No | ||
| item_index | Yes | ||
| pitch_high | No | ||
| start_beat | No | ||
| track_index | Yes | ||
| return_notes | No | ||
| min_length_beats | No |