Skip to content

Commit

Permalink
Release Save and restore selected tracks floating FX windows (4 slots…
Browse files Browse the repository at this point in the history
…) v1.03 (#1274)

Add support for Master track
  • Loading branch information
Edgemeal authored Oct 18, 2023
1 parent 427cf4b commit 2ada076
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)

Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 2ada076

Please sign in to comment.