Advertisement
Guest User

REAPER script: Move all project markers by the same amount in seconds

a guest
Oct 28th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.00 KB | None | 0 0
  1. -- Move all project markers by the same amount in seconds
  2.  
  3. local retval, num_markers, _ = reaper.CountProjectMarkers(0)
  4.     if num_markers == 0 then reaper.MB("No markers in the project.","Error",0) return end
  5.  
  6. local retval, value = reaper.GetUserInputs("Move all markers by..", 1, "Format = sec.ms", "")
  7.     if not retval or value == "" then return end
  8.     local value = value:match("(%-?%d*%.?%d*)")
  9.     if not value then reaper.MB("Illegal entry.","Error",0) return end
  10.  
  11. -- Save all project markers IDs
  12. local i = 0
  13. local t = {}
  14.     while i < num_markers do
  15.     local retval, _, pos, _, name, id = reaper.EnumProjectMarkers2(0, i)
  16.     t[id] = pos + value
  17.     i = i + 1
  18.     end
  19.  
  20. reaper.Undo_BeginBlock()
  21.  
  22. -- Move all saved project markers
  23.     for k,v in pairs(t) do
  24.     reaper.SetProjectMarker2(0, k, false, v, 0, "")
  25.     i = i + 1
  26.     end
  27.  
  28. -- Done in stages since setting marker in the same loop as enumeration messes up their order while they're being moved
  29.  
  30. reaper.Undo_EndBlock('Move all project markers by '..value..' sec',-1)
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement