Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Bug Reports

Reply
 
Thread Tools Display Modes
Old 10-14-2021, 03:11 AM   #1
andivax
Human being with feelings
 
Join Date: Jan 2011
Posts: 284
Default Delta conflict with Amagalma script

Hi guys!
New DELTA (difference between dry and wet) function is in conflict with this Script: amagalma_Toggle wet 0-100% (or current value) for focused FX.lua

I am using this script very often to compare before/after without latency issues (like simple plugin bypass do).

Is it problem with DELTA implementation? Or script?
Or is it workaround to TOGGLE between current fx value and 0% fx?
Attached Images
File Type: png dw.png (8.9 KB, 62 views)
__________________
www.andivax.com - Made In Ukraine
andivax is offline   Reply With Quote
Old 10-14-2021, 03:28 AM   #2
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,750
Default

What happens when you run the script? Can you post the script here?
schwa is offline   Reply With Quote
Old 10-14-2021, 03:50 AM   #3
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

amagalma will need to update the script for v6.37, script is assuming Wet param is last.
Edgemeal is offline   Reply With Quote
Old 10-14-2021, 03:53 AM   #4
sockmonkey72
Human being with feelings
 
sockmonkey72's Avatar
 
Join Date: Sep 2021
Location: Berlin
Posts: 1,935
Default

Quote:
Originally Posted by andivax View Post
Hi guys!
New DELTA (difference between dry and wet) function is in conflict with this Script: amagalma_Toggle wet 0-100% (or current value) for focused FX.lua

I am using this script very often to compare before/after without latency issues (like simple plugin bypass do).

Is it problem with DELTA implementation? Or script?
Or is it workaround to TOGGLE between current fx value and 0% fx?
It's the script; it assumes that wet/dry is the last parameter in the parameter list.

Here's a fixed script, but I think I found a bug in reaper.TakeFX_GetParamFromIdent(), so it might not work 100% yet:

Code:
-- @description amagalma_Toggle wet 0-100% (or current value) for focused FX
-- @author amagalma
-- @version 1.0
-- @about
--   # Toggles wet from 0% to current value (or 100%) for the FX in focus

local reaper, math = reaper, math

local focus, track, item, fx = reaper.GetFocusedFX()

function round(num, numDecimalPlaces)
    local mult = 10^(numDecimalPlaces or 0)
    if num >= 0 then return math.floor(num * mult + 0.5) / mult
    else return math.ceil(num * mult - 0.5) / mult end
end


if focus == 1 then --------------- TRACK FX ---------------

  if track == 0 then
    track = reaper.GetMasterTrack(0)
  else
    track = reaper.GetTrack(0, track-1)
  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 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.SetExtState( "ToggleWet", fxguid, val, false )
      reaper.TrackFX_SetParam( track, fx, wetparam, 0 )
      reaper.Undo_OnStateChangeEx( "Set " .. name .. " to 0% wet", 2, -1 )
    else -- set to previous value if exists or 100%
      if reaper.HasExtState( "ToggleWet" , fxguid ) then
        val = tonumber(reaper.GetExtState( "ToggleWet", fxguid ))
      else
        val = 1
      end
      reaper.TrackFX_SetParam( track, fx, wetparam, val )
      reaper.DeleteExtState( "ToggleWet", fxguid, false )
      val = round (val * 100)
      reaper.Undo_OnStateChangeEx( "Set " .. name .. " to " .. val .. "% wet", 2, -1 )
    end    
  
  else
  
    reaper.defer(function () end)
    
  end
  
elseif focus == 2 then --------------- TAKE FX ---------------

  item = reaper.GetMediaItem(0, item)
  track = reaper.GetMediaItemTrack(item)
  local take = reaper.GetMediaItemTake(item, fx >> 16)
  -- check if it is really visible
  local hwnd = reaper.TakeFX_GetFloatingWindow( take, fx )
  local chain_vis = reaper.TakeFX_GetChainVisible( take )
  if hwnd or chain_vis > -1 then
  
    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.SetExtState( "ToggleWet", fxguid, val, false )
      reaper.TakeFX_SetParam( take, fx, wetparam, 0 )
      reaper.Undo_OnStateChangeEx( "Set " .. name .. " to 0% wet", 4, -1 )
    else -- set to previous value if exists or 100%
      if reaper.HasExtState( "ToggleWet" , fxguid ) then
        val = tonumber(reaper.GetExtState( "ToggleWet", fxguid ))
      else
        val = 1
      end
      reaper.TakeFX_SetParam( take, fx, wetparam, val )
      reaper.DeleteExtState( "ToggleWet", fxguid, false )
      val = round (val * 100)
      reaper.Undo_OnStateChangeEx( "Set " .. name .. " to " .. val .. "% wet", 4, -1 )
    end
  
  else
  
  reaper.defer(function () end)
  
  end
  
elseif focus == 0 then

  reaper.defer(function () end)
  
end
sockmonkey72 is offline   Reply With Quote
Old 10-14-2021, 03:58 AM   #5
schwa
Administrator
 
schwa's Avatar
 
Join Date: Mar 2007
Location: NY
Posts: 15,750
Default

Ah, I see. The script makes an assumption about where the wet/dry parameter is in the parameter list. The script should call TrackFX_GetParamFromIdent(":wet") instead.
schwa is offline   Reply With Quote
Old 10-14-2021, 04:21 AM   #6
andivax
Human being with feelings
 
Join Date: Jan 2011
Posts: 284
Default

Thanks guys!
Shwa for clarification and sockmonkey72 for fixing the script.
It is WORKING as expected now.
i will send Amagalma the link to this topic.
__________________
www.andivax.com - Made In Ukraine
andivax is offline   Reply With Quote
Old 10-16-2021, 05:13 AM   #7
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Thanks sockmonkey72!

The fix will break the script for versions previous to v6.37, though.

I'll update the script so that it works for all versions.

edit: fixed in v1.01
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 10-16-2021 at 05:27 AM.
amagalma is offline   Reply With Quote
Old 10-16-2021, 05:51 AM   #8
andivax
Human being with feelings
 
Join Date: Jan 2011
Posts: 284
Default

Quote:
Originally Posted by amagalma View Post
Thanks sockmonkey72!

The fix will break the script for versions previous to v6.37, though.

I'll update the script so that it works for all versions.

edit: fixed in v1.01
Thank you! Donated a little bit ))
__________________
www.andivax.com - Made In Ukraine
andivax is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:30 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.