View Single Post
Old 01-13-2018, 09:21 AM   #23
Ice
Human being with feelings
 
Join Date: Aug 2014
Posts: 887
Default

Quote:
Originally Posted by Sexan View Post
Let me just make a simple GUI for changing time but for now just edit the script and set the time you want (in seconds)

Code:
local time = 2 -- TIME OFFSET (seconds)
local off_cur,store_cur

function main()
local state = reaper.GetPlayState() -- GET TRANSPORT STATE
local cur_pos = reaper.GetCursorPosition() -- GET EDIT CURSOR POSITION
 
if state == 0 then -- IF STOPED 
  if last_state ~= nil then -- IF PREVIOUS STATE WAS PLAY OR RECORD
    reaper.SetEditCurPos(store_cur,1, 1 ) -- RESTORE ORIGINAL EDIT CURSOR POSITION
    last_state = nil -- RESET LAST TRANSPORT STATE
    store_cur = nil -- RESET STORED EDIT CURSOR POSITION
  else -- IF PLAY OR RECORD
    store_cur = cur_pos -- STORE ORIGINAL EDIT CURSOR POSITION
    off_cur = cur_pos - time -- OFFSET CURSOR
  end
end  

if state ~= 0 and off_cur then
  reaper.SetEditCurPos( off_cur,1, 1 ) -- MOVE CURSOR WITH OFFSET
  last_state = state  -- SAVE LAST TRANSPORT STATE (PLAY OR RECORD)
  off_cur = nil
end

reaper.defer(main)
end
main()
test away

@EpicSound not yet working in recording mode (not sure if it can but I'm working on it)
I like the way you've got the play cursor returning to the original position. Thats just how it should work.

I can't get it to work here though. When I run the script (stopped on playing), nothing happens.
Ice is offline   Reply With Quote