insert_midi_events
Create a new MIDI item on one track from a list of raw events (notes, CC, pitch bend, program change), with no humanizing.
Instructions
Create a new MIDI item on one track from a list of raw events (notes, CC, pitch bend, program change), with no humanizing. Use this for exact, hand-specified MIDI; use insert_midi_file when a .mid already exists, insert_groove for humanized drums, insert_riff for humanized guitar or bass, cut_band for a whole four-track jam. Two timing units. Default time_unit "seconds": start_seconds + length_seconds, event time and duration in seconds from the item start. time_unit "beats" (use this to write music): start_bar (1-based) or start_beats (project quarter notes), length_beats, and event time and duration in quarter notes from the item start, so notes follow the tempo map. Mixing units is refused. For drums, keep the golden rule yourself: no drum hits the same velocity twice in a row. Returns {track_guid, notes, controls, time_unit, start_seconds, length_seconds} plus start_bar/start_beats/length_beats in beats mode. Errors: BAD_PAYLOAD (an event or the timing is out of range; nothing is written), INSERT_FAILED / VERIFY_FAILED (the new item is deleted again). Undoable.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| track | No | Exact track name (case-insensitive); "master" targets the master track. Used when no GUID is given; errors if two tracks share the name. | |
| events | Yes | 1..10000 events. Each needs type and time; the other fields depend on type. | |
| dry_run | No | Preview: return what would run without changing the project. | |
| start_bar | No | beats mode: 1-based bar the item starts on (or use start_beats). | |
| time_unit | No | Default seconds. beats = quarter notes, tempo-map aware. | |
| start_beats | No | beats mode: project quarter-note position the item starts on. | |
| length_beats | No | beats mode: item length in quarter notes (4 = one 4/4 bar). | |
| start_seconds | No | seconds mode: project time where the new item starts. | |
| length_seconds | No | seconds mode: item length; every event must fit inside it. | |
| track_contains | No | Case-insensitive substring; used only when no GUID or exact name is given. Errors if it matches more than one track. | |
| target_track_guid | No | Stable REAPER track GUID; preferred when available. Wins over every other track selector. | |
| use_selected_track | No | Target the first selected track; ignored when any other track selector is given. Errors if nothing is selected. |