1
1
-- @description Copy FX from item under mouse to selected items
2
2
-- @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
4
7
-- @link Forum Thread https://forum.cockos.com/showthread.php?t=239565
5
8
-- @donation Donate https://www.paypal.me/Edgemeal
6
9
-- @about See forum link.
@@ -11,21 +14,41 @@ function Main()
11
14
if src_item == nil then return end
12
15
local src_take = reaper .GetActiveTake (src_item )
13
16
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
16
19
-- get source fx index
17
20
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 ()
22
45
if src_fx < 0 then return end
23
46
end
24
47
-- 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" )
26
49
if not retval then return end
27
50
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
29
52
-- copy source fx to dest fx
30
53
reaper .PreventUIRefresh (1 )
31
54
reaper .Undo_BeginBlock ()
@@ -43,5 +66,9 @@ function Main()
43
66
reaper .PreventUIRefresh (- 1 )
44
67
end
45
68
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
47
74
reaper .defer (function () end )
0 commit comments