Thread: Insert Time Key
View Single Post
Old 03-03-2020, 06:19 PM   #12
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Try this it should work on the current time signature and tempo at the cursor:
Code:
retval_inputs, bars_set = reaper.GetUserInputs( "Set Bars to Insert", 1, "Insert Bars", "0" )
if retval_inputs then   
  cur_pos = reaper.GetCursorPosition()
  
  timesig_num, timesig_denom, bpm = reaper.TimeMap_GetTimeSigAtTime(0, cur_pos)
  
  time_set = (((bars_set * timesig_num) / bpm) * 60) 

  start_time, end_time = reaper.GetSet_LoopTimeRange2(0, true, false, cur_pos, cur_pos + time_set, true)
  
  reaper.Main_OnCommand(40200, 0)  -- Time selection: Insert empty space at time selection (moving later items)
  
  reaper.Main_OnCommand(40635, 0)  -- Time selection: Remove time selection  
end
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote