|
|
|
07-29-2021, 05:01 AM
|
#1
|
Human being with feelings
Join Date: Feb 2021
Posts: 23
|
How to trim left edge of items to snap offset
Hi yall, I have a bunch of drum tracks that have been splitted, quantized, overlap removed and gap filled.
The gap filling operation obviously created snap offsets to the items along with the fades.
I would like to undo all of that except the original splits.
I am able to remove all the fades, but what's left is the snap offsets.
So basically what I'm looking for is either
trim left edges of items to snap offsets
or
a way to undo "Fill gaps between selected items", to place items' left edges to their original position
Thank you in advance
|
|
|
08-01-2021, 12:22 AM
|
#2
|
Human being with feelings
Join Date: Apr 2020
Posts: 214
|
This script should work:
Code:
function UnselectItems()
while reaper.CountSelectedMediaItems(0) > 0 do
reaper.SetMediaItemSelected(reaper.GetSelectedMediaItem(0, 0), false)
end
end
function SetOnlyItemSelected(item)
UnselectItems()
reaper.SetMediaItemSelected(item, true)
end
function SetSelectedItems(table)
UnselectItems()
for i = 1, #table do
reaper.SetMediaItemSelected(table[i], true)
end
end
function main()
reaper.Undo_BeginBlock()
local items = {}
local cursorPos = reaper.GetCursorPosition()
for i = 1, reaper.CountSelectedMediaItems(0) do
items[i] = reaper.GetSelectedMediaItem(0, i-1)
end
for i = 1, #items do
local item = items[i]
local itemPos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
local snapOffset = reaper.GetMediaItemInfo_Value(item, "D_SNAPOFFSET")
SetOnlyItemSelected(item)
reaper.SetEditCurPos(itemPos+snapOffset, false, false)
reaper.Main_OnCommand(41305, 0) -- trim left edge to cursor
end
SetSelectedItems(items)
reaper.SetEditCurPos(cursorPos, false, false)
reaper.Undo_EndBlock("Trim left edge of selected items to snap offsets", -1)
end
reaper.PreventUIRefresh(1)
main()
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
|
|
|
08-01-2021, 06:27 AM
|
#3
|
Human being with feelings
Join Date: Feb 2021
Posts: 23
|
Quote:
Originally Posted by poulhoi
This script should work:
Code:
function UnselectItems()
while reaper.CountSelectedMediaItems(0) > 0 do
reaper.SetMediaItemSelected(reaper.GetSelectedMediaItem(0, 0), false)
end
end
function SetOnlyItemSelected(item)
UnselectItems()
reaper.SetMediaItemSelected(item, true)
end
function SetSelectedItems(table)
UnselectItems()
for i = 1, #table do
reaper.SetMediaItemSelected(table[i], true)
end
end
function main()
reaper.Undo_BeginBlock()
local items = {}
local cursorPos = reaper.GetCursorPosition()
for i = 1, reaper.CountSelectedMediaItems(0) do
items[i] = reaper.GetSelectedMediaItem(0, i-1)
end
for i = 1, #items do
local item = items[i]
local itemPos = reaper.GetMediaItemInfo_Value(item, "D_POSITION")
local snapOffset = reaper.GetMediaItemInfo_Value(item, "D_SNAPOFFSET")
SetOnlyItemSelected(item)
reaper.SetEditCurPos(itemPos+snapOffset, false, false)
reaper.Main_OnCommand(41305, 0) -- trim left edge to cursor
end
SetSelectedItems(items)
reaper.SetEditCurPos(cursorPos, false, false)
reaper.Undo_EndBlock("Trim left edge of selected items to snap offsets", -1)
end
reaper.PreventUIRefresh(1)
main()
reaper.PreventUIRefresh(-1)
reaper.UpdateArrange()
|
Wow, thank you ever so much! Works brilliantly.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 06:12 AM.
|