View Single Post
Old 03-11-2019, 09:25 AM   #24
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,671
Default

Quote:
Originally Posted by lexaproductions View Post
Well that's what I tried to do but if you can see in my last example, the way I did it does not work...
The playState variable does not appear to be defined (or if it is elsewhere in the script, it's not being updated in the loop).

Code:
function onNextMeasure(callback)
  local beatsSinceLastMeasure = reaper.TimeMap2_timeToBeats(0, reaper.GetPlayPosition())
  
  if beatsSinceLastMeasure < 0.1 then
    -- if we're at (or very near) the start of a measure, call the given function
    callback()
  else if reaper.GetPlayState()&1 == 1 -- only if the project is playing
    -- or, if we're not at the start of a measure, check again ~33ms later
    reaper.defer(function() onNextMeasure(callback) end)
  end
end

onNextMeasure(function()
  -- code to run at the next measure here
  reaper.ShowConsoleMsg("Hello Next Measure!\n")
end)
Quote:
Originally Posted by lexaproductions View Post
I believe so. But I can't find where to reset it. Where do we change the Terminate instances settings?
Remove and re-import the script in the action list.
cfillion is online now   Reply With Quote