Old 07-24-2017, 06:12 AM   #1
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 1,126
Default Action Marker: Calculate timing

Does anyone knows if there's a way to calculate the timing between Reaper sees an action marker and the timing Reaper actually does the action?

I must use Action Marker to switch Project tabs and I'd like to do it the smoothest way possible. Right now, I offset my Action Marker manually, Judging by ear what feels smooth but I find it's time consuming to do it this way. It doesn't need to be sample accurate but at least within a few ms.
lexaproductions is offline   Reply With Quote
Old 07-24-2017, 03:38 PM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Try this (put the script's command ID in an action marker):

Code:
-- @description Show distance between play cursor and nearest marker
-- @version 0.2
-- @author cfillion

local next_index, offset = 0, nil

local cur_pos = (function()
  if (reaper.GetPlayState() & 1) == 1 then
    return reaper.GetPlayPosition()
  else
    return reaper.GetCursorPosition()
  end
end)()

while true do
  local retval, isregion, pos = reaper.EnumProjectMarkers(next_index)
  next_index = retval
  if next_index == 0 then break end

  if not isregion then
    this_offset = cur_pos - pos
    if not offset or math.abs(this_offset) < math.abs(offset) then
      offset = this_offset
    end
  end
end

if not offset then return end

reaper.ShowConsoleMsg(string.format('Distance between edit/play cursor to nearest marker is %fs.\n', offset))
You'll find that the action marker delay changes slightly every time because SWS's Marker Actions uses REAPER's global timer for it's polling, which supposedly runs at 30Hz-50Hz. It cannot run the actions faster than that timer.

Last edited by cfillion; 07-24-2017 at 05:27 PM.
cfillion is offline   Reply With Quote
Old 07-24-2017, 04:33 PM   #3
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

This is something I did for my "Audion takes script"

eel:

Code:

function UserEditableValues()
(
  //*//user feel free to adjust these
  loopminimum=1.5;  //ignore loops less than this size
  setcolor=ColorToNative(55,187,55)|0x1000000; //Almost anoyying green color ;) 
  Mbuffvalue=1.2; //Default Media buffering is 1200ms
  AfxValue=.2; //Default Anticipative FX Render Ahead is 200ms
);

UserEditableValues();

//set offset for marker
track= GetMediaItem_Track(GetSelectedMediaItem(proj, 0)); //get first track with items
Mbuff=GetMediaTrackInfo_Value(track, "I_PERFFLAGS")&1; //is Media Buffering enabled?
AFx=GetMediaTrackInfo_Value(track, "I_PERFFLAGS")&2; //is Anticipative FX enabled?
perftiming=(Mbuffvalue*abs(Mbuff-1))+(AFxvalue*(abs(AFx-2))/2);
slack=(GetOutputLatency()+ perftiming); //might be trying to be too smart here haha
A bit involved. there is a user configurable value here for media buffering size and anticipative FX size (also a check weather media buffering is enabled on the track) none of this may be necessary for what you want to do, you might just want to get the output latency and be done with it.

(this code involves looping so needs to be tight af)

then you make the marker from the (edit cursor?) minus the "slack" value..
James HE is offline   Reply With Quote
Old 07-24-2017, 05:45 PM   #4
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 1,126
Default

Quote:
Originally Posted by cfillion View Post
Try this (put the script's command ID in an action marker):...
Thanks a lot for this. This reports a 20ms delay. But it made me realize that, the more commands you have on an action Marker, The larger the delay will be. (Make sense...)

My commands does:
1- Go To Next Projet Tab
2- Focus Tracks
3- Unset transport repeat state
4- Remove Loop Points selection
5- Next Project Tab
6- Call Good Screenset
7- PLAY

It seems that all these commands add up to the Delay before PLAY starts. I'll fiddle a bit with the order of my commands and will report back.

Thanks
lexaproductions is offline   Reply With Quote
Old 07-24-2017, 06:13 PM   #5
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by lexaproductions View Post
Thanks a lot for this. This reports a 20ms delay. But it made me realize that, the more commands you have on an action Marker, The larger the delay will be. (Make sense...)

My commands does:
1- Go To Next Projet Tab
2- Focus Tracks
3- Unset transport repeat state
4- Remove Loop Points selection
5- Next Project Tab
6- Call Good Screenset
7- PLAY

It seems that all these commands add up to the Delay before PLAY starts. I'll fiddle a bit with the order of my commands and will report back.

Thanks

Hmmm... yes the delay of the action marker itself. I forgot that my script does not actually use the SWS Action markers at all since it was faster performance wise to roll my own.

I'm no help here at all! lol
James HE 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 07:02 AM.


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