From 2ada0768d948082526eaa69d5b8bc4b53f229489 Mon Sep 17 00:00:00 2001 From: Edgemeal <47255672+Edgemeal@users.noreply.github.com> Date: Tue, 17 Oct 2023 22:39:14 -0500 Subject: [PATCH] Release Save and restore selected tracks floating FX windows (4 slots) v1.03 (#1274) Add support for Master track --- ...d tracks floating FX windows (4 slots).lua | 3 +- ...eal_Restore tracks floating FX windows.lua | 47 ++++++++++--------- ...ve selected tracks floating FX windows.lua | 40 +++++++++------- 3 files changed, 50 insertions(+), 40 deletions(-) diff --git a/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots).lua b/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots).lua index 9b8d78635..73fe80f3d 100644 --- a/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots).lua +++ b/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots).lua @@ -1,6 +1,6 @@ -- @description Save and restore selected tracks floating FX windows (4 slots) -- @author Edgemeal --- @version 1.02 +-- @version 1.03 -- @changelog Add support for Master track -- @metapackage -- @provides @@ -14,4 +14,5 @@ -- [main] edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Restore tracks floating FX windows.lua > edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Restore tracks floating FX windows from slot 4.lua -- @link Forum thread https://forum.cockos.com/showpost.php?p=2349852&postcount=2196 -- @donation https://www.paypal.me/Edgemeal +-- @about Support FX in Container (REAPER v7.00) diff --git a/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Restore tracks floating FX windows.lua b/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Restore tracks floating FX windows.lua index 5ff0b8e50..e777f003f 100644 --- a/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Restore tracks floating FX windows.lua +++ b/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Restore tracks floating FX windows.lua @@ -1,37 +1,42 @@ -- @noindex -local track_count = reaper.CountTracks(0) +local index, guidz = 0, {} -function View(track, guid) - local track_fx_count = reaper.TrackFX_GetCount(track) - for j = 0, track_fx_count-1 do - if reaper.TrackFX_GetFXGUID(track, j) == guid then - local hwnd = reaper.TrackFX_GetFloatingWindow(track, j) - if hwnd == nil then - reaper.TrackFX_Show(track, j, 3) -- show floating window - else - reaper.TrackFX_Show(track, j, 2) -- hide floating window - end - return - end +-- Special Thanks to Justin, https://forum.cockos.com/showpost.php?p=2714766&postcount=17 +function BuildFXTree_item(tr, fxid, scale) + index=index+1 guidz[index] = { track = tr, fxid = fxid, guid = reaper.TrackFX_GetFXGUID(tr, fxid) } + local c_ok, c_count = reaper.TrackFX_GetNamedConfigParm(tr, fxid, 'container_count') + if c_ok then + c_count = tonumber(c_count) + for child = 1, c_count do BuildFXTree_item(tr, fxid + scale * child, (scale*(c_count+1))) end end end +function BuildFXTree(tr) + local cnt = reaper.TrackFX_GetCount(tr) + for i = 1, cnt do BuildFXTree_item(tr, 0x2000000+i, cnt+1) end +end + function ShowFx(guid) - View(reaper.GetMasterTrack(0), guid) - for i = 0, track_count-1 do - local track = reaper.GetTrack(0, i) - View(track, guid) + for j = 1, #guidz do + if guidz[j].guid == guid then + local hwnd = reaper.TrackFX_GetFloatingWindow(guidz[j].track, guidz[j].fxid) + if hwnd == nil then + reaper.TrackFX_Show(guidz[j].track, guidz[j].fxid, 3) -- show floating window + else + reaper.TrackFX_Show(guidz[j].track, guidz[j].fxid, 2) -- hide floating window + end + end end end function Main() local name = ({reaper.get_action_context()})[2]:match("([^/\\_]+).lua$") local slot = tonumber(name:match(" slot (%d+)")) - if slot == nil then - reaper.MB("Error reading slot # from filename","ERROR",0) - return - end + if slot == nil then reaper.MB("Error reading slot # from filename","ERROR",0) return end + BuildFXTree(reaper.GetMasterTrack()) + local track_count = reaper.CountTracks(0) + for i = 0, track_count-1 do BuildFXTree(reaper.GetTrack(0, i)) end local guids = reaper.GetExtState("Edgemeal_fx_float", tostring(slot)) for guid in guids:gmatch("[^,]+") do ShowFx(guid) end end diff --git a/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Save selected tracks floating FX windows.lua b/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Save selected tracks floating FX windows.lua index 3067f832a..34d42df9b 100644 --- a/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Save selected tracks floating FX windows.lua +++ b/FX/edgemeal_Save and restore selected tracks floating FX windows (4 slots)/edgemeal_Save selected tracks floating FX windows.lua @@ -1,26 +1,30 @@ -- @noindex +local index, guidz = 0, {} + +-- Special Thanks to Justin, https://forum.cockos.com/showpost.php?p=2714766&postcount=17 +function BuildFXTree_item(tr, fxid, scale) + local hwnd = reaper.TrackFX_GetFloatingWindow(tr, fxid) + if hwnd ~= nil then index=index+1 guidz[index] = reaper.TrackFX_GetFXGUID(tr, fxid) end + local c_ok, c_count = reaper.TrackFX_GetNamedConfigParm(tr, fxid, 'container_count') + if c_ok then + c_count = tonumber(c_count) + for child = 1, c_count do BuildFXTree_item(tr, fxid + scale * child, (scale*(c_count+1))) end + end +end + +function BuildFXTree(tr) + local cnt = reaper.TrackFX_GetCount(tr) + for i = 1, cnt do BuildFXTree_item(tr, 0x2000000+i, cnt+1) end +end + function Main() local name = ({reaper.get_action_context()})[2]:match("([^/\\_]+).lua$") local slot = tonumber(name:match(" slot (%d+)")) - if slot == nil then - reaper.MB("Error reading slot # from filename","ERROR",0) - return - end - local guid = "" - local sel_tracks_count = reaper.CountSelectedTracks2(0, true) - for i = 0, sel_tracks_count-1 do - local track = reaper.GetSelectedTrack2(0, i, true) - local track_fx_count = reaper.TrackFX_GetCount(track) - for j = 0, track_fx_count-1 do - local hwnd = reaper.TrackFX_GetFloatingWindow(track, j) - if hwnd ~= nil then - local fx_GUID = reaper.TrackFX_GetFXGUID(track, j) - guid = guid .. fx_GUID .. ',' - end - end - end - reaper.SetExtState("Edgemeal_fx_float", tostring(slot), guid, false) + if slot == nil then reaper.MB("Error reading slot # from filename","ERROR",0) return end + local stc = reaper.CountSelectedTracks2(0, true) + for i = 0, stc-1 do BuildFXTree(reaper.GetSelectedTrack2(0, i, true)) end + reaper.SetExtState("Edgemeal_fx_float", tostring(slot), table.concat(guidz, ","), false) end Main()