Skip to content

Commit

Permalink
Update amagalma_Toggle wet 0-100% (or current value) for focused FX.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
amagalma authored Feb 12, 2024
1 parent d775b0d commit b10230c
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions FX/amagalma_Toggle wet 0-100% (or current value) for focused FX.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
-- @description amagalma_Toggle wet 0-100% (or current value) for focused FX
-- @author amagalma
-- @version 1.11
-- @changelog
-- - Support for FX Containers
-- - Requires Reaper v7.06+
-- - Fix bugs of v1.10
-- @version 1.12
-- @changelog Added tooltip info
-- @donation https://www.paypal.me/amagalma
-- @about
-- # Toggles wet from 0% to current value (or 100%) for the FX in focus
Expand All @@ -15,7 +12,7 @@ if tonumber(v1) < 7 or tonumber(v2) < 6 then
return reaper.defer(function() end)
end

local floor, ceil = math.floor, math.ceil
local floor, ceil, integ = math.floor, math.ceil, math.tointeger

local retval, track, item, take, fx, parm = reaper.GetTouchedOrFocusedFX( 1 )
if not retval then return reaper.defer(function () end) end
Expand All @@ -34,21 +31,23 @@ if item == -1 then --------------- TRACK FX ---------------
else
track = reaper.GetTrack(0, track)
end

-- check if it is really visible
local hwnd = reaper.TrackFX_GetFloatingWindow( track, fx )
local chain_vis = reaper.TrackFX_GetChainVisible( track )
if hwnd or chain_vis > -1 then


local msg
local wetparam = reaper.TrackFX_GetParamFromIdent( track, fx, ":wet" )
local val = reaper.TrackFX_GetParam( track, fx, wetparam )
local fxguid = reaper.TrackFX_GetFXGUID( track, fx )
local _, name = reaper.TrackFX_GetFXName( track, fx, "" )

if val > 0 then -- store value and set wet to 0%
reaper.SetProjExtState( 0, "ToggleWet", fxguid, val )
reaper.TrackFX_SetParam( track, fx, wetparam, 0 )
reaper.Undo_OnStateChangeEx( "Set " .. name .. " to 0% wet", 2, -1 )
msg = ({reaper.GetTrackName(track)})[2] .. " | ".. ({reaper.TrackFX_GetFXName(track, fx)})[2] .. " => 0%"
else -- set to previous value if exists or 100%
local hasState, val = reaper.GetProjExtState( 0, "ToggleWet" , fxguid )
if not hasState == 1 then
Expand All @@ -57,15 +56,18 @@ if item == -1 then --------------- TRACK FX ---------------
reaper.TrackFX_SetParam( track, fx, wetparam, val )
reaper.SetProjExtState( 0, "ToggleWet", fxguid, "" )
val = round (val * 100)
msg = ({reaper.GetTrackName(track)})[2] .. " | ".. ({reaper.TrackFX_GetFXName(track, fx)})[2] .. " => " .. integ(val) .. "%"
reaper.Undo_OnStateChangeEx( "Set " .. name .. " to " .. val .. "% wet", 2, -1 )
end

end
local x, y = reaper.GetMousePosition()
reaper.TrackCtl_SetToolTip(msg, x, y, true)

else

reaper.defer(function () end)

end

else --------------- TAKE FX ---------------

item = reaper.GetMediaItem(0, item)
Expand All @@ -75,16 +77,18 @@ else --------------- TAKE FX ---------------
local hwnd = reaper.TakeFX_GetFloatingWindow( take, fx )
local chain_vis = reaper.TakeFX_GetChainVisible( take )
if hwnd or chain_vis > -1 then


local msg
local wetparam = reaper.TakeFX_GetParamFromIdent( take, fx, ":wet" )
local val = reaper.TakeFX_GetParam( take, fx, wetparam )
local fxguid = reaper.TakeFX_GetFXGUID( take, fx )
local _, name = reaper.TakeFX_GetFXName( take, fx, "" )

if val > 0 then -- store value and set wet to 0%
reaper.SetProjExtState( 0, "ToggleWet", fxguid, val )
reaper.TakeFX_SetParam( take, fx, wetparam, 0 )
reaper.Undo_OnStateChangeEx( "Set " .. name .. " to 0% wet", 4, -1 )
msg = reaper.GetTakeName( take ) .. " | ".. ({reaper.TakeFX_GetFXName(take, fx)})[2] .. " => 0%"
else -- set to previous value if exists or 100%
local hasState, val = reaper.GetProjExtState( 0, "ToggleWet" , fxguid )
if not hasState == 1 then
Expand All @@ -93,13 +97,16 @@ else --------------- TAKE FX ---------------
reaper.TakeFX_SetParam( take, fx, wetparam, val )
reaper.SetProjExtState( 0, "ToggleWet", fxguid, "" )
val = round (val * 100)
msg = reaper.GetTakeName( take ) .. " | ".. ({reaper.TakeFX_GetFXName(take, fx)})[2] .. " => " .. integ(val) .. "%"
reaper.Undo_OnStateChangeEx( "Set " .. name .. " to " .. val .. "% wet", 4, -1 )
end

local x, y = reaper.GetMousePosition()
reaper.TrackCtl_SetToolTip(msg, x, y, true)

else

reaper.defer(function () end)

end

end

0 comments on commit b10230c

Please sign in to comment.