add_midi_notes
Add multiple MIDI notes to a REAPER MIDI item in one operation, with per-note pitch, timing, and velocity settings.
Instructions
Add multiple MIDI notes to a MIDI item in one operation.
Important: Please check MIDI item length in which you want to add notes. If any note extends beyond the item bounds, create another one or resize existing before note adding.
Item Identification - TWO ways to specify which item:
Using track_pos_idx (integer):
Simple position number: 0 = first item, 1 = second item, etc.
Get this from create_midi_item response field "track_pos_idx"
Quick but may become invalid if items are deleted/reordered
Using direct_item_id (string):
REAPER's internal pointer like "MediaItem*0x000001234567890A"
Get this from create_midi_item response field "direct_item_id"
Or from get_items_in_time_range response
Guaranteed to always point to the same item
Recommendation: Use track_pos_idx for quick scripts, direct_item_id for reliability.
Args: track_index: Index of the track track_pos_idx: EITHER integer track_pos_idx OR string direct_item_id notes: List of note definitions, each containing: - pitch: MIDI note pitch (0-127) - start_time: Start position in seconds (optional if start_measure provided) - start_measure: Start position as "measure:beat,fraction" (optional if start_time provided) - length_time: Duration in seconds (optional if length_measure provided) - length_measure: Duration as "measure:beat,fraction" (e.g., "0:2,000" = 2 beats) - velocity: Note velocity (0-127, optional, default: 96) - relative_start: Default mode for all notes. Per-note override supported via note['relative_start'] (bool).
Example: notes = [ { "pitch": 60, "start_measure": "1:1,000", "length_measure": "0:2,000", "velocity": 100 }, { "pitch": 64, "start_time": 2.5, "length_time": 0.5 } ]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| item | Yes | ||
| notes | Yes | ||
| track_index | Yes | ||
| relative_start | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |