Old 08-17-2022, 04:33 PM   #1
Miscreant
Human being with feelings
 
Miscreant's Avatar
 
Join Date: Mar 2012
Posts: 375
Default Select and move a single marker?

Hey everyone--title says it all. I have a marker action that I want moved to the end of a time selection whenever I am reamping. But I'm not seeing anything in Reaper or online.

Any ideas?
Miscreant is offline   Reply With Quote
Old 08-17-2022, 06:44 PM   #2
Philbo King
Human being with feelings
 
Philbo King's Avatar
 
Join Date: May 2017
Posts: 3,201
Default

Left click it and drag.
__________________
Tangent Studio - Philbo King
www.soundclick.com/philboking - Audio streams
Philbo King is online now   Reply With Quote
Old 08-18-2022, 05:36 AM   #3
Miscreant
Human being with feelings
 
Miscreant's Avatar
 
Join Date: Mar 2012
Posts: 375
Default

Sorry--I meant as part of a custom action, so moving it manually with the mouse is not what I'm referring to.
Miscreant is offline   Reply With Quote
Old 08-18-2022, 06:01 AM   #4
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

AFAIK the ReaScript API doesn't yet have a function to select project markers. You can find a marker by name and change its position pretty easily with a Lua script. For example, move first marker named "reamp" to end of the time selection...

Code:
-- Move project marker 'reamp' to end of time selection.lua

-- get time selection
local start_time, end_time = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
if start_time == end_time then return end -- abort if no time selection
-- move marker
reaper.Undo_BeginBlock()
for idx = 0, reaper.CountProjectMarkers(0)-1 do
  local retval, isrgn, pos, rgnend, name, markrgnindexnumber = reaper.EnumProjectMarkers(idx)
  if not isrgn and name == "reamp" then
    reaper.SetProjectMarker(markrgnindexnumber, isrgn, end_time, rgnend, name)
    break
  end
end
reaper.Undo_EndBlock("Move project marker 'reamp' to end of time selection", -1)
Edgemeal is offline   Reply With Quote
Old 08-18-2022, 06:25 AM   #5
Miscreant
Human being with feelings
 
Miscreant's Avatar
 
Join Date: Mar 2012
Posts: 375
Default

Quote:
Originally Posted by Edgemeal View Post
AFAIK the ReaScript API doesn't yet have a function to select project markers. You can find a marker by name and change its position pretty easily with a Lua script. For example, move first marker named "reamp" to end of the time selection...

Code:
-- Move project marker 'reamp' to end of time selection.lua

-- get time selection
local start_time, end_time = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
if start_time == end_time then return end -- abort if no time selection
-- move marker
reaper.Undo_BeginBlock()
for idx = 0, reaper.CountProjectMarkers(0)-1 do
  local retval, isrgn, pos, rgnend, name, markrgnindexnumber = reaper.EnumProjectMarkers(idx)
  if not isrgn and name == "reamp" then
    reaper.SetProjectMarker(markrgnindexnumber, isrgn, end_time, rgnend, name)
    break
  end
end
reaper.Undo_EndBlock("Move project marker 'reamp' to end of time selection", -1)
Thanks for this. Two q's:

1. Since my marker is actually a marker action, it starts with "!_" followed my the command ID for the action. Where in this script would I substitute in this marker ID?

2. As well, could this script be modified to encode a second action that moves the marker action back to its original spot (or at least somewhere else, away from the time selection to which the first action moved it?)
Miscreant is offline   Reply With Quote
Old 08-18-2022, 08:07 AM   #6
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by Miscreant View Post
Thanks for this. Two q's:

1. Since my marker is actually a marker action, it starts with "!_" followed my the command ID for the action. Where in this script would I substitute in this marker ID?

2. As well, could this script be modified to encode a second action that moves the marker action back to its original spot (or at least somewhere else, away from the time selection to which the first action moved it?)
I think this will work,..
EDIT Uses marker_name to save/restore marker position so script can be used for more then a single marker.
Code:
local marker_name = "!1016" --< Set name of marker here!

function MoveMarker(mark_name, new_pos, save)
  reaper.Undo_BeginBlock()
  for idx = 0, reaper.CountProjectMarkers(0)-1 do
    local retval, isrgn, pos, rgnend, name, markrgnindexnumber = reaper.EnumProjectMarkers(idx)
    if not isrgn and name == mark_name then
      if save then reaper.SetExtState("Move_"..mark_name, "Position",tostring(pos), false) end
      reaper.SetProjectMarker(markrgnindexnumber, isrgn, new_pos, rgnend, name)
      break
    end
  end
  reaper.Undo_EndBlock("Move project marker "..mark_name, -1)
end

local val = reaper.GetExtState("Move_"..marker_name,"Position")
if val ~= "" then  -- restore previous pos.
  reaper.DeleteExtState("Move_"..marker_name, "Position", false)
  MoveMarker(marker_name, tonumber(val), false)
else  -- move marker to end of time selection, save current pos.
  local start_time, end_time = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
  if start_time == end_time then return end
  MoveMarker(marker_name, end_time, true)
end

Last edited by Edgemeal; 08-19-2022 at 05:55 AM.
Edgemeal is offline   Reply With Quote
Old 08-19-2022, 06:50 AM   #7
Miscreant
Human being with feelings
 
Miscreant's Avatar
 
Join Date: Mar 2012
Posts: 375
Default

Quote:
Originally Posted by Edgemeal View Post
I think this will work,..
EDIT Uses marker_name to save/restore marker position so script can be used for more then a single marker.
Code:
local marker_name = "!1016" --< Set name of marker here!

function MoveMarker(mark_name, new_pos, save)
  reaper.Undo_BeginBlock()
  for idx = 0, reaper.CountProjectMarkers(0)-1 do
    local retval, isrgn, pos, rgnend, name, markrgnindexnumber = reaper.EnumProjectMarkers(idx)
    if not isrgn and name == mark_name then
      if save then reaper.SetExtState("Move_"..mark_name, "Position",tostring(pos), false) end
      reaper.SetProjectMarker(markrgnindexnumber, isrgn, new_pos, rgnend, name)
      break
    end
  end
  reaper.Undo_EndBlock("Move project marker "..mark_name, -1)
end

local val = reaper.GetExtState("Move_"..marker_name,"Position")
if val ~= "" then  -- restore previous pos.
  reaper.DeleteExtState("Move_"..marker_name, "Position", false)
  MoveMarker(marker_name, tonumber(val), false)
else  -- move marker to end of time selection, save current pos.
  local start_time, end_time = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
  if start_time == end_time then return end
  MoveMarker(marker_name, end_time, true)
end
Works perfectly. Thanks for being a random internet hero. Much appreciated!
Miscreant is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 10:23 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.