Skip to content

Commit 7257083

Browse files
authored
Release Copy FX from item under mouse to selected items v1.01 (ReaTeam#453)
Select source FX by name from menu (if more then one). Special Thanks to amagalma, https://forum.cockos.com/showthread.php?t=239556
1 parent 8ee63ed commit 7257083

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

Diff for: FX/edgemeal_Copy FX from item under mouse to selected items.lua

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
-- @description Copy FX from item under mouse to selected items
22
-- @author Edgemeal
3-
-- @version 1.0
3+
-- @version 1.01
4+
-- @changelog
5+
-- Select source FX by name from menu (if more then one).
6+
-- Special Thanks to amagalma, https://forum.cockos.com/showthread.php?t=239556
47
-- @link Forum Thread https://forum.cockos.com/showthread.php?t=239565
58
-- @donation Donate https://www.paypal.me/Edgemeal
69
-- @about See forum link.
@@ -11,21 +14,41 @@ function Main()
1114
if src_item == nil then return end
1215
local src_take = reaper.GetActiveTake(src_item)
1316
if src_take == nil then return end
14-
if reaper.TakeFX_GetCount(src_take) == 0 then return end -- ignore if no source FX
15-
17+
local cnt = reaper.TakeFX_GetCount(src_take)
18+
if cnt == 0 then return end -- abort if no source FX
1619
-- get source fx index
1720
local src_fx = 0
18-
if reaper.TakeFX_GetCount(src_take) > 1 then -- more then one FX, ask user for source slot #
19-
local retval, str = reaper.GetUserInputs("Copy Take FX", 1, "Copy source FX from slot #", "1")
20-
if not retval then return end
21-
src_fx = tonumber(str)-1
21+
if cnt > 1 then -- more then one FX, let user select FX from menu
22+
local x, y = reaper.GetMousePosition()
23+
local FXs = {} -- source fx names
24+
for fx = 0, cnt-1 do
25+
retval, name = reaper.TakeFX_GetFXName(src_take, fx, "")
26+
FXs[fx+1] = {name = name}
27+
end
28+
local menu = "#Copy source FX:||"
29+
for fx = 1, #FXs do
30+
local space = " "
31+
space = space:sub( tostring(fx):len()*2 )
32+
menu = menu .. (FXs[fx].act and "!" or "") ..fx .. space .. (FXs[fx].name == "" and "(unnamed)" or FXs[fx].name) .."|"
33+
end
34+
local title = "! Hidden window for menu !"
35+
gfx.init( title, 0, 0, 0, 0, 0 )
36+
local hwnd = reaper.JS_Window_FindTop( title, true )
37+
local out = 0
38+
if hwnd then
39+
out = 7000
40+
reaper.JS_Window_Move( hwnd, -out, -out )
41+
end
42+
gfx.x, gfx.y = x-52+out, y-70+out
43+
src_fx = gfx.showmenu(menu)-2
44+
gfx.quit()
2245
if src_fx < 0 then return end
2346
end
2447
-- set dest fx index from user
25-
local retval, str = reaper.GetUserInputs("Paste Take FX", 1, "Paste to FX slot # (-1=last)", "-1")
48+
local retval, str = reaper.GetUserInputs("Paste FX to selected items", 1, "Paste to FX slot # (-1 = last)", "-1")
2649
if not retval then return end
2750
local dest_fx = tonumber(str)
28-
if dest_fx > 0 then dest_fx=dest_fx-1 end
51+
if dest_fx > 0 then dest_fx = dest_fx-1 end
2952
-- copy source fx to dest fx
3053
reaper.PreventUIRefresh(1)
3154
reaper.Undo_BeginBlock()
@@ -43,5 +66,9 @@ function Main()
4366
reaper.PreventUIRefresh(-1)
4467
end
4568

46-
Main()
69+
if not reaper.APIExists('JS_Window_FindTop') then
70+
reaper.MB('js_ReaScriptAPI extension is required for this script.', 'Missing API', 0)
71+
else
72+
Main()
73+
end
4774
reaper.defer(function () end)

0 commit comments

Comments
 (0)