View Single Post
Old 01-21-2018, 05:43 PM   #76
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Okay, so I found a method that works somehow. However, I need to make some adjustments to the script. Let me explain. The script does the following:

- get the edit cursor position (in seconds)
- subtract 2 bars of the position (in seconds)
- convert the position (in seconds) to TC (format hh:mm:ss:sss)
- copy the new TC to the clipboard (can be pasted into the project start field)

Apparently, I get some issues during the conversion to hh:mm:ss:sss.
The desired TC does not sit 100% on bar 3, instead it's shifted a bit to the right.
Maybe you have some expertise in that area?

Code:
pos = reaper.GetCursorPosition() -- get edit cursor position
nom, _, _ = reaper.TimeMap_GetTimeSigAtTime(0, pos) -- get nominator of time signature
project_start = reaper.GetProjectTimeOffset(0, false) -- get project start
two_bars = reaper.TimeMap2_beatsToTime(0, 2*nom, 0) -- convert 2 bars to time
new_pos = pos - two_bars -- subtract 2 bars from position
new_pos = new_pos + project_start -- add project start offset to position

new_tc = reaper.format_timestr(new_pos, "") -- convert new position to TC (format hh:mm:ss:sss)

reaper.CF_SetClipboard(new_tc)
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote