| 1 | -- Insert a time-signature change at the edit cursor, then open REAPER's native |
| 2 | -- tempo/time-signature dialog to edit it. |
| 3 | -- |
| 4 | -- The bare Shift+C action (40256) opens that dialog with the "Time signature" |
| 5 | -- box UNchecked, so you have to tick it every time. Pre-inserting a marker that |
| 6 | -- already carries a time signature means the dialog opens in EDIT mode with the |
| 7 | -- box already checked (and tempo left alone) — the effect we actually want. |
| 8 | |
| 9 | local proj = 0 |
| 10 | local cursor = reaper.GetCursorPositionEx(proj) |
| 11 | |
| 12 | -- Inherit the time signature currently in effect so we edit it, not clobber it. |
| 13 | local num, denom = reaper.TimeMap_GetTimeSigAtTime(proj, cursor) |
| 14 | |
| 15 | reaper.Undo_BeginBlock() |
| 16 | -- ptidx=-1 insert new | timepos=cursor | measure/beat=-1 | bpm=-1 leave tempo as-is |
| 17 | reaper.SetTempoTimeSigMarker(proj, -1, cursor, -1, -1, -1, num, denom, false) |
| 18 | reaper.Undo_EndBlock("Insert time signature marker", -1) |
| 19 | reaper.UpdateTimeline() |
| 20 | |
| 21 | -- 40256 = "Tempo envelope: Insert tempo/time signature change marker at edit |
| 22 | -- cursor" (the action bound to Shift+C). With a marker already at the cursor it |
| 23 | -- opens in edit mode, time-signature enabled. |
| 24 | reaper.Main_OnCommand(40256, 0) |