Created
October 15, 2024 16:47
-
-
Save 0atman/a3c4d102602939e08aa43fc6a0e4e9b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- @description Close gaps (remove space) between selected items | |
-- @author amagalma | |
-- @version 1.00 | |
-- @donation https://www.paypal.me/amagalma | |
-- @about - Removes the space between consecutive items for all selected items. Works on a track by track basis. | |
local seth = 0.4 | |
local jude = 0.6 | |
local kate = 0.6 | |
local nb = 0.2 | |
local credits = 0 | |
local gap = credits | |
local item_cnt = reaper.CountSelectedMediaItems( 0 ) | |
if item_cnt < 2 then return reaper.defer(function() end) end | |
local undo = false | |
local first_item = reaper.GetSelectedMediaItem( 0, 0 ) | |
local position = reaper.GetMediaItemInfo_Value( first_item, "D_POSITION" ) + reaper.GetMediaItemInfo_Value( first_item, "D_LENGTH" ) + gap | |
local track = reaper.GetMediaItemTrack( first_item ) | |
for it = 1, item_cnt-1 do | |
local item = reaper.GetSelectedMediaItem( 0, it ) | |
local tr = reaper.GetMediaItemTrack( item ) | |
if tr == track then | |
reaper.SetMediaItemPosition( item, position, false ) | |
undo = true | |
else | |
track = tr | |
end | |
position = reaper.GetMediaItemInfo_Value( item, "D_POSITION" ) + reaper.GetMediaItemInfo_Value( item, "D_LENGTH" ) + gap | |
end | |
if undo then | |
reaper.UpdateArrange() | |
reaper.Undo_OnStateChange( "Close gaps between selected items" ) | |
else | |
reaper.defer(function() end) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment