Old 03-04-2018, 05:39 PM   #41
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Here is a set of three scripts:
* Two scripts to move the edit cursor left or right to the nearest edge of an item in selected tracks. The default offset can be specified in the script text file.
* A script that opens a dialog box in which you can easily set a new offset while you are working. (This overrides the default offsets; blank input restores the default.)

Code:
-- Move edit cursor to next item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = math.huge
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemStart > cursorTimePos and itemStart < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart
        elseif itemEnd > cursorTimePos and itemEnd < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd       
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor right to item edge", -1)
Code:
-- Move edit cursor to previous item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = -math.huge 
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemEnd < cursorTimePos and itemEnd > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd  
        elseif itemStart < cursorTimePos and itemStart > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart     
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor left to item edge", -1)
Code:
-- Sets offset for the "Move edit cursor" scripts.
-- Blank input restores default offset (as specified in the "Move edit cursor" scripts).
currentOffset = reaper.GetExtState("MoveEditCursor", "offset")
repeat
    OK, newOffset = reaper.GetUserInputs([[Set offset for "Move cursor" script]], 1, "Offset (in seconds)", currentOffset)
    if not OK then return end
until newOffset == "" or tonumber(newOffset)
reaper.SetExtState("MoveEditCursor", "offset", newOffset, true)
juliansader is offline   Reply With Quote
Old 03-06-2018, 06:57 AM   #42
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 98
Default

Quote:
Originally Posted by juliansader View Post
Here is a set of three scripts:
* Two scripts to move the edit cursor left or right to the nearest edge of an item in selected tracks. The default offset can be specified in the script text file.
* A script that opens a dialog box in which you can easily set a new offset while you are working. (This overrides the default offsets; blank input restores the default.)

Code:
-- Move edit cursor to next item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = math.huge
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemStart > cursorTimePos and itemStart < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart
        elseif itemEnd > cursorTimePos and itemEnd < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd       
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor right to item edge", -1)
Code:
-- Move edit cursor to previous item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = -math.huge 
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemEnd < cursorTimePos and itemEnd > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd  
        elseif itemStart < cursorTimePos and itemStart > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart     
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor left to item edge", -1)
Code:
-- Sets offset for the "Move edit cursor" scripts.
-- Blank input restores default offset (as specified in the "Move edit cursor" scripts).
currentOffset = reaper.GetExtState("MoveEditCursor", "offset")
repeat
    OK, newOffset = reaper.GetUserInputs([[Set offset for "Move cursor" script]], 1, "Offset (in seconds)", currentOffset)
    if not OK then return end
until newOffset == "" or tonumber(newOffset)
reaper.SetExtState("MoveEditCursor", "offset", newOffset, true)
Incredible! Thank you Julian, Will try this as soon as i get back into the studio tonight.
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 03-07-2018, 12:04 PM   #43
tusitala
Human being with feelings
 
tusitala's Avatar
 
Join Date: Apr 2010
Location: London (UK)
Posts: 412
Default

Quote:
Originally Posted by me2beats View Post
Save selected tracks, slot 1 (persist).lua
Save selected tracks, slot 2 (persist).lua
Save selected tracks, slot 3 (persist).lua

Toggle show-hide saved tracks, slot 1 (persist).lua
Toggle show-hide saved tracks, slot 2 (persist).lua
Toggle show-hide saved tracks, slot 3 (persist).lua

Added.
They use project notes.
You can make as slots as you want
for this you need to create the same script and just replace the variable (slot number) in the first line for example
Code:
local slot = 4


Hi! I think it's possible, but I'm not good at JS


Hi! I'll see what i can do


Hi, Do you guys know how to have this script work exactly like it is working now, but leaving racks visible in the mixer?
I would like to hide them only on the arrange view but keep seeing them in the mixer.

Thanks a lot!
All the best
-t
tusitala is offline   Reply With Quote
Old 03-21-2018, 06:00 AM   #44
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 98
Default

Quote:
Originally Posted by juliansader View Post
Here is a set of three scripts:
* Two scripts to move the edit cursor left or right to the nearest edge of an item in selected tracks. The default offset can be specified in the script text file.
* A script that opens a dialog box in which you can easily set a new offset while you are working. (This overrides the default offsets; blank input restores the default.)

Code:
-- Move edit cursor to next item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = math.huge
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemStart > cursorTimePos and itemStart < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart
        elseif itemEnd > cursorTimePos and itemEnd < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd       
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor right to item edge", -1)
Code:
-- Move edit cursor to previous item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = -math.huge 
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemEnd < cursorTimePos and itemEnd > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd  
        elseif itemStart < cursorTimePos and itemStart > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart     
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor left to item edge", -1)
Code:
-- Sets offset for the "Move edit cursor" scripts.
-- Blank input restores default offset (as specified in the "Move edit cursor" scripts).
currentOffset = reaper.GetExtState("MoveEditCursor", "offset")
repeat
    OK, newOffset = reaper.GetUserInputs([[Set offset for "Move cursor" script]], 1, "Offset (in seconds)", currentOffset)
    if not OK then return end
until newOffset == "" or tonumber(newOffset)
reaper.SetExtState("MoveEditCursor", "offset", newOffset, true)
Thank you Julian, works great!
Where do i send beer-money?
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 03-21-2018, 06:05 AM   #45
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 98
Default

Desperatly need this: i want to press key #3 and activate smart tool split item.
Posssible scripting this?
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 03-21-2018, 10:36 AM   #46
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Jonas Ekstrom View Post
Where do i send beer-money?
paypal.me/juliansader, thanks!


Quote:
Originally Posted by Jonas Ekstrom View Post
Desperatly need this: i want to press key #3 and activate smart tool split item.
Posssible scripting this?
It might be possible... What exactly do you mean by "key #3" and "activate smart tool split item"?

Last edited by juliansader; 03-22-2018 at 08:40 AM.
juliansader is offline   Reply With Quote
Old 03-24-2018, 09:14 AM   #47
Gianfini
Human being with feelings
 
Join Date: Jan 2015
Posts: 794
Default script not working

hi, I cannot get me2beats_remove selected regions contents (moving later items) to work

I created a region, selected it but it does nothing...

g
Gianfini is offline   Reply With Quote
Old 03-25-2018, 03:47 AM   #48
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 98
Default

Quote:
Originally Posted by juliansader View Post

It might be possible... What exactly do you mean by "key #3" and "activate smart tool split item"?

Right now I right click the split item icon to make it a smart tool, split always active until I click it again, effectively making the edit cursor a scissor tool.

Now, is there a way of scripting that instead of right clicking the button? In that case I could assign a key to it.

Coming from Samplitude, one of the most things I miss is the universal mouse mode.
I've set up mouse modifiers to come close, just miss a proper scissor tool.
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 03-25-2018, 04:43 AM   #49
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Jonas Ekstrom View Post
Now, is there a way of scripting that instead of right clicking the button? In that case I could assign a key to it.
Do you want mouse cursor to reflect the default vs "split tool" state, similar to how the cursor changes when you arm a toolbar button? If so, try this script:

Code:
--[[
Description: Toggles left-click mouse modifier between "split item" and whatever was previously the assigned action

Author: juliansader

Instructions: 
* Assign any shortcut to script.  
* Press shortcut once to start script, and once again to stop script. 
* If the "ReaScript task control" window pops up with the question 
  "Would you like to terminate all instances of this script or launch a new instance?", 
  select "Terminate instances" and check "Remember my answer for this script".
]]

originalAction = reaper.GetMouseModifier("MM_CTX_ITEM_CLK", 0, "")
is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()


function exit()
    reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, originalAction)
    reaper.TrackCtl_SetToolTip("", 0, 0, true)
    reaper.SetToggleCommandState(sectionID, cmdID, 0)
    reaper.RefreshToolbar2(sectionID, cmdID)
end
reaper.atexit(exit)

function loopDrawTooltip()
    x, y = reaper.GetMousePosition()
    reaper.TrackCtl_SetToolTip(" ][", x+8, y+9, true)
    reaper.defer(loopDrawTooltip)
end

reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, 40746 ) -- Split item at mouse cursor
reaper.SetToggleCommandState(sectionID, cmdID, 1)
reaper.RefreshToolbar2(sectionID, cmdID)
loopDrawTooltip()
But would it not be simpler to assign the keystroke shortcut to the split action itself? Then you can just press the shortcut whenever you want to split.

EDIT: Updated to reflect state in toolbar button.

For a simpler script that doesn't change the mouse cursor, try:
Code:
currentAction = reaper.GetMouseModifier("MM_CTX_ITEM_CLK", 0, "")

is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()

if currentAction == "40746" then
    reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, "1") -- Select Item
    reaper.SetToggleCommandState(sectionID, cmdID, 0) -- Toggle button OFF
else
    reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, "40746") -- Split item under mouse cursor
    reaper.SetToggleCommandState(sectionID, cmdID, 1) -- Toggle button ON
end

reaper.RefreshToolbar2(sectionID, cmdID)

Last edited by juliansader; 03-30-2018 at 03:07 AM.
juliansader is offline   Reply With Quote
Old 04-17-2018, 02:32 AM   #50
Jonas Ekstrom
Human being with feelings
 
Jonas Ekstrom's Avatar
 
Join Date: Feb 2017
Location: Stockholm
Posts: 98
Default

Quote:
Originally Posted by juliansader View Post
Do you want mouse cursor to reflect the default vs "split tool" state, similar to how the cursor changes when you arm a toolbar button? If so, try this script:

Code:
--[[
Description: Toggles left-click mouse modifier between "split item" and whatever was previously the assigned action

Author: juliansader

Instructions: 
* Assign any shortcut to script.  
* Press shortcut once to start script, and once again to stop script. 
* If the "ReaScript task control" window pops up with the question 
  "Would you like to terminate all instances of this script or launch a new instance?", 
  select "Terminate instances" and check "Remember my answer for this script".
]]

originalAction = reaper.GetMouseModifier("MM_CTX_ITEM_CLK", 0, "")
is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()


function exit()
    reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, originalAction)
    reaper.TrackCtl_SetToolTip("", 0, 0, true)
    reaper.SetToggleCommandState(sectionID, cmdID, 0)
    reaper.RefreshToolbar2(sectionID, cmdID)
end
reaper.atexit(exit)

function loopDrawTooltip()
    x, y = reaper.GetMousePosition()
    reaper.TrackCtl_SetToolTip(" ][", x+8, y+9, true)
    reaper.defer(loopDrawTooltip)
end

reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, 40746 ) -- Split item at mouse cursor
reaper.SetToggleCommandState(sectionID, cmdID, 1)
reaper.RefreshToolbar2(sectionID, cmdID)
loopDrawTooltip()
But would it not be simpler to assign the keystroke shortcut to the split action itself? Then you can just press the shortcut whenever you want to split.

EDIT: Updated to reflect state in toolbar button.

For a simpler script that doesn't change the mouse cursor, try:
Code:
currentAction = reaper.GetMouseModifier("MM_CTX_ITEM_CLK", 0, "")

is_new_value,filename,sectionID,cmdID,mode,resolution,val = reaper.get_action_context()

if currentAction == "40746" then
    reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, "1") -- Select Item
    reaper.SetToggleCommandState(sectionID, cmdID, 0) -- Toggle button OFF
else
    reaper.SetMouseModifier("MM_CTX_ITEM_CLK", 0, "40746") -- Split item under mouse cursor
    reaper.SetToggleCommandState(sectionID, cmdID, 1) -- Toggle button ON
end

reaper.RefreshToolbar2(sectionID, cmdID)
Thank you for this Julian!
Tested it and it seems to toogle so much it´s a bit slow.
And also, i think i was overlooking the mouse modifiers, i guess this can be done with that.

Only thing missing is a vertical ruler with the mouse-pointer, if this could be triggered with a script then my editing headache would be gone.
__________________
Jonas Ekstrom
www.northmastering.com
Jonas Ekstrom is offline   Reply With Quote
Old 06-20-2020, 12:36 AM   #51
alexgameaudio
Human being with feelings
 
alexgameaudio's Avatar
 
Join Date: Jun 2020
Location: Los Angeles, CA
Posts: 106
Default

Quote:
Originally Posted by juliansader View Post
Here is a set of three scripts:
* Two scripts to move the edit cursor left or right to the nearest edge of an item in selected tracks. The default offset can be specified in the script text file.
* A script that opens a dialog box in which you can easily set a new offset while you are working. (This overrides the default offsets; blank input restores the default.)

Code:
-- Move edit cursor to next item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = math.huge
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemStart > cursorTimePos and itemStart < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart
        elseif itemEnd > cursorTimePos and itemEnd < nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd       
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor right to item edge", -1)
Code:
-- Move edit cursor to previous item edge in selected tracks

defaultOffset = 0 -- User can change this value (in seconds)

----------------------------------------------------------------------------------
offset = tonumber(reaper.GetExtState("MoveEditCursor", "offset")) or defaultOffset
reaper.Undo_BeginBlock2(0)
nearestEdge = -math.huge 
cursorTimePos = reaper.GetCursorPositionEx(0)
for t = 0, reaper.CountSelectedTracks(0)-1 do
    local track = reaper.GetSelectedTrack(0, t)
    for i = 0, reaper.GetTrackNumMediaItems(track)-1 do
        local item = reaper.GetTrackMediaItem(track, i)
        local itemStart = offset + reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        local itemEnd = itemStart + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
        if itemEnd < cursorTimePos and itemEnd > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemEnd  
        elseif itemStart < cursorTimePos and itemStart > nearestEdge then
            mustMoveCursor = true
            nearestEdge = itemStart     
        end
    end
end
if mustMoveCursor then
    reaper.ApplyNudge(0, 1, 6, 1, nearestEdge, false, 0)
end
-- Whether undo point is created depends on Preferences -> Undo settings -> Include cursor position
reaper.Undo_EndBlock2(0, "Move edit cursor left to item edge", -1)
Code:
-- Sets offset for the "Move edit cursor" scripts.
-- Blank input restores default offset (as specified in the "Move edit cursor" scripts).
currentOffset = reaper.GetExtState("MoveEditCursor", "offset")
repeat
    OK, newOffset = reaper.GetUserInputs([[Set offset for "Move cursor" script]], 1, "Offset (in seconds)", currentOffset)
    if not OK then return end
until newOffset == "" or tonumber(newOffset)
reaper.SetExtState("MoveEditCursor", "offset", newOffset, true)
This script is ridiculously useful for pro tools users. I'm new here, and was surprised I didn't find this functionality in stock Reaper, or in SWS, ReaPack, etc. Can I vote for this to get added somehow? As a sound editor, this is one of my most used actions in a DAW. I was lucky to stumble upon this forum post.
alexgameaudio is offline   Reply With Quote
Old 12-24-2020, 05:19 PM   #52
Loulou92
Human being with feelings
 
Loulou92's Avatar
 
Join Date: Sep 2015
Location: Paris
Posts: 544
Default

Hey Julian !

I wonder if you could create an alternative version of the script. One version that would move the edit cursor to the nearest edge (could be move to the left or ove to the right, to a left edge, or right edge) of the currently selected items (one item or more items selected and if no item is selected, the scripts would do nothing). I need this script, I could paypal you a little bit of course .

merry christmas and thank you for all your cool scripts
xxxxxxxxxx

Last edited by Loulou92; 12-24-2020 at 05:36 PM.
Loulou92 is online now   Reply With Quote
Old 12-28-2020, 02:44 PM   #53
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Loulou92 View Post
Hey Julian !

I wonder if you could create an alternative version of the script. One version that would move the edit cursor to the nearest edge (could be move to the left or ove to the right, to a left edge, or right edge) of the currently selected items (one item or more items selected and if no item is selected, the scripts would do nothing). I need this script, I could paypal you a little bit of course .

merry christmas and thank you for all your cool scripts
xxxxxxxxxx
Sorry for not seeing this post sooner.
Code:
-- Move edit cursor to closest edge of any selected item

numSelItems = reaper.CountSelectedMediaItems(0)
if numSelItems > 0 then

    cursorTime = reaper.GetCursorPositionEx(0)
    tE = {} -- Store time positions of all edges
    
    for i = 0, numSelItems-1 do
        local item = reaper.GetSelectedMediaItem(0, i)
        tE[#tE+1] = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
        tE[#tE+1] = tE[#tE] + reaper.GetMediaItemInfo_Value(item, "D_LENGTH")
    end
    
    runningMinDist = math.huge
    closestEdgeTime = cursorTime
    for _, edgeTime in ipairs(tE) do
        local dist = math.abs(cursorTime - edgeTime)
        if dist < runningMinDist then runningMinDist, closestEdgeTime = dist, edgeTime end
    end
    
    if closestEdgeTime ~= cursorTime then
        reaper.Undo_BeginBlock2(0)
        reaper.ApplyNudge(0, 1, 6, 1, closestEdgeTime, false, 0)
        reaper.Undo_EndBlock2(0, "Move to closest item edge", -1)
    end
end
juliansader 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:49 AM.


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