create_midi_item
Create an empty MIDI item on a REAPER track. Specify its start and length in time or measure terms to prepare a canvas for adding MIDI notes.
Instructions
Create an empty MIDI item on a track.
Important: It is recommended to avoid overlapping MIDI items. Ensure to double-check before creating a new one.
Returns both track_pos_idx and direct_item_id for flexible item referencing:
track_pos_idx: 0-based position index within the track (0, 1, 2, etc.)
direct_item_id: REAPER's internal item ID (string pointer)
Both can be used interchangeably in subsequent operations like add_midi_note.
Args: track_index: 0-based track index (0 = first track, 1 = second, etc.) Note: REAPER UI shows "Track 1, Track 2" but API uses 0, 1, etc. start_time: Start position in seconds (optional if start_measure is provided) start_measure: Start position as "measure:beat,fraction" (optional if start_time is provided) where fraction is milliseconds (e.g., "1:1,500" = measure 1, beat 1, half beat) length_time: Duration in seconds from start position (from start_time or start_measure)(optional if length_measure is provided). length_measure: Duration as "measure:beat,fraction" from start position (e.g., "2:1,000" = 2 measures from start_time or start_measure)(optional if length_time is provided). The range starts from 0:1,0. The value 0:4,0 equals three beats in a 4/4 time signature. Thus, if you want the length of all beats from one measure, then use 1:1,0; for two measures, use 2:1,0; and for three, use 3:1,0.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_time | No | ||
| length_time | No | ||
| track_index | Yes | ||
| start_measure | No | ||
| length_measure | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |