-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release Select previous item with take FX v1.00 (#1349)
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Items Properties/amagalma_Select previous item with take FX.lua
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
-- @description Select previous item with take FX | ||
-- @author amagalma | ||
-- @version 1.00 | ||
-- @donation https://www.paypal.me/amagalma | ||
|
||
|
||
local sel_items = reaper.CountSelectedMediaItems( 0 ) | ||
if sel_items == 0 then | ||
reaper.MB("Please, select one or more items.", "No items selected!", 0) | ||
return | ||
end | ||
|
||
local change = false | ||
local tracks, tracks2 = {}, {} | ||
|
||
-- Store first item on each track | ||
for i = sel_items-1, 0, -1 do | ||
local item = reaper.GetSelectedMediaItem( 0, i ) | ||
local track = reaper.GetMediaItemTrack( item ) | ||
tracks[track] = item | ||
end | ||
|
||
|
||
-- Find previous item with TakeFX | ||
for track, item in pairs(tracks) do | ||
local ip = reaper.GetMediaItemInfo_Value( item, "IP_ITEMNUMBER" ) | ||
local track_items_cnt = reaper.CountTrackMediaItems( track ) | ||
for i = ip-1, 0, -1 do | ||
local item = reaper.GetTrackMediaItem( track, i ) | ||
local take = reaper.GetActiveTake( item ) | ||
if take and reaper.TakeFX_GetCount( take ) > 0 then | ||
if not tracks2[track] then | ||
tracks2[track] = { i, track_items_cnt } | ||
change = true | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
-- Select only previous item with TakeFX | ||
if change then | ||
reaper.Undo_BeginBlock() | ||
reaper.PreventUIRefresh( 1 ) | ||
for track, info in pairs(tracks2) do | ||
for i = 0, info[2]-1 do | ||
local item = reaper.GetTrackMediaItem( track, i ) | ||
reaper.SetMediaItemSelected( item, i == info[1] ) | ||
end | ||
end | ||
reaper.UpdateArrange() | ||
reaper.PreventUIRefresh( -1 ) | ||
reaper.Undo_EndBlock( "Select previous item with TakeFX", 4 ) | ||
end |