Old 08-06-2020, 01:48 PM   #1
antiClick
Human being with feelings
 
antiClick's Avatar
 
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 943
Default Pray for a simple modification

I hope here is the right place to ask this

How could this script be modified sodass it toggles between offline states instead of bypass states.

Reapack, scripts by MPL:

"mpl_Toggle bypass all project FX with latency (PDC) higher than X samples.lua"

Would be much appreciated
antiClick is offline   Reply With Quote
Old 08-06-2020, 02:46 PM   #2
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,263
Default

Bypassing releases the PDC for those FX.

What would be your case usage?

Cheers,

Andrew K
__________________
Cheers,
Andrew K
v6.03+dev0114 - January 14 2020 • Mac 10.12.+ • i7 Quad 2.9GHz • 24GB
Thonex is online now   Reply With Quote
Old 08-07-2020, 07:17 AM   #3
antiClick
Human being with feelings
 
antiClick's Avatar
 
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 943
Default

Quote:
Originally Posted by Thonex View Post
Bypassing releases the PDC for those FX.

What would be your case usage?

Cheers,

Andrew K
My intention is to use the script when I need to record something after I have already mixed a song, wich usually contains high latency plugins. This script lets me record with minimal latency, deactivating all those plugins from every track with a single click.

But as it toggles its bypass state, I would want the already bypassed inserts to stay so (you know how it looks a typical insert chain, some fx are let bypassed because of experimentation) and not become active the second time I run the script.

On the other hand, making then offline/online wouldn't conflict this recording/mixing workflow.


Greetings,
antiClick is offline   Reply With Quote
Old 08-07-2020, 07:28 AM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,924
Default

The script leaves already bypassed plugins untouched.
nofish is offline   Reply With Quote
Old 08-08-2020, 07:36 AM   #5
antiClick
Human being with feelings
 
antiClick's Avatar
 
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 943
Default

Quote:
Originally Posted by nofish View Post
The script leaves already bypassed plugins untouched.
Yes, I just noticed that and it's great.

But what if you have bypass as an envelope automated?
I just opened my last project and found that issue I didn't notice before.

so please offline state (-:
antiClick is offline   Reply With Quote
Old 08-08-2020, 10:14 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,924
Default

Ok, makes sense, missed that aspect.

Are you a little familiar with scripting?
Would you be up for doing/trying it yourself when given some help?

Just had a quick look at the code and seems a few simple modifications (basically search and replace some functions) would do.
nofish is offline   Reply With Quote
Old 08-08-2020, 03:20 PM   #7
antiClick
Human being with feelings
 
antiClick's Avatar
 
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 943
Default

Quote:
Originally Posted by nofish View Post
Ok, makes sense, missed that aspect.

Are you a little familiar with scripting?
Would you be up for doing/trying it yourself when given some help?

Just had a quick look at the code and seems a few simple modifications (basically search and replace some functions) would do.
I'm not familiar with lua scripting but have some experience with other programming languages.
I am definetly up for trying it for myself.

Thank you a lot for looking into that
antiClick is offline   Reply With Quote
Old 08-08-2020, 04:13 PM   #8
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,924
Default

Alright.
This is the main function of mpl's script, the rest is mainly ReaPack stuff:

Code:
  function main(spl_thrshld)
    local state =  reaper.GetExtState( 'MPLPDCTOGGLE', 'STATE' )
    if not state or state == '' or tonumber(state)==0 then 
      
      -- bypass 
      local str = ''
      for tr_id = 0, reaper.CountTracks(0) do
        local track
        if tr_id ==0 then track = reaper.GetMasterTrack( 0 ) else track = reaper.GetTrack(0,tr_id-1) end
        
        for fx_id = 1,  reaper.TrackFX_GetCount( track ) do
          local retval, buf = reaper.TrackFX_GetNamedConfigParm( track, fx_id-1, 'pdc' )
          if retval and tonumber(buf) and tonumber(buf) > spl_thrshld then  
            local is_bypass = reaper.TrackFX_GetEnabled( track, fx_id-1)
            if is_bypass then is_bypass =1 else is_bypass = 0 end       
            str = str..'\n'..reaper.TrackFX_GetFXGUID( track, fx_id-1)..' '..is_bypass
            reaper.TrackFX_SetEnabled( track, fx_id-1, false)
          end 
        end

        for fx_id = 1, reaper.TrackFX_GetRecCount( track ) do
          local retval, buf = reaper.TrackFX_GetNamedConfigParm( track, 0x1000000+ fx_id-1, 'pdc' )
          if retval and tonumber(buf) and tonumber(buf) > spl_thrshld then  
            local is_bypass = reaper.TrackFX_GetEnabled( track, 0x1000000 + fx_id-1)
            if is_bypass then is_bypass =1 else is_bypass = 0 end       
            str = str..'\n'..reaper.TrackFX_GetFXGUID( track, 0x1000000 + fx_id-1)..' '..is_bypass
            reaper.TrackFX_SetEnabled( track, 0x1000000 + fx_id-1, false)
          end 
        end
                
        
      end
      
      
      
      reaper.SetExtState( 'MPLPDCTOGGLE', 'STATE', 1, true )
      reaper.SetProjExtState( 0, 'MPLPDCTOGGLE', 'FXGUIDS', str )
      
     else
      
      local ret, str = reaper.GetProjExtState( 0, 'MPLPDCTOGGLE', 'FXGUIDS' )
      local t = {}
      for line in str:gmatch('[^\r\n]+') do local GUID, bypass = line:match('({.*}) (%d)') t[GUID] = tonumber(bypass) end      
      
      for tr_id = 0, reaper.CountTracks(0) do
        local track
        if tr_id ==0 then track = reaper.GetMasterTrack( 0 ) else track = reaper.GetTrack(0,tr_id-1) end
        
        for fx_id = 1, reaper.TrackFX_GetCount( track ) do
          local GUID = reaper.TrackFX_GetFXGUID( track, fx_id-1)
          if t[GUID] then reaper.TrackFX_SetEnabled( track, fx_id-1, t[GUID]==1) end
        end
        
        for fx_id = 1, reaper.TrackFX_GetRecCount( track ) do
          local GUID = reaper.TrackFX_GetFXGUID( track, 0x1000000+fx_id-1)
          if t[GUID] then reaper.TrackFX_SetEnabled( track, 0x1000000+fx_id-1, t[GUID]==1) end
        end
        
      end     
      reaper.SetExtState( 'MPLPDCTOGGLE', 'STATE', 0, true )
    end
  end
  
  -- call the main function with the desired PDC threshold
  main(256)
The bolded lines would need to change:
1. TrackFX_Get/SetEnabled() is for bypass state of track FX.
The corresponding function for track FX offline state are:
TrackFX_GetOffline and TrackFX_SetOffline

2.
Get/SetExtState is for storing/restoring external data.
https://www.extremraym.com/cloud/rea...c/#GetExtState
https://www.extremraym.com/cloud/rea...c/#SetExtState


Here you should probably give another key name so it doesn't conflict with mpl's toggle bypass scripts (if you also use them).
e.g. (2nd line)
Code:
local state =  reaper.GetExtState( 'MPLPDCTOGGLE', 'STATE' )
->
Code:
local state =  reaper.GetExtState( 'ANTICLICKPDCOFFLINETOGGLE', 'STATE' )
and so forth.
Does this make sense?

edit (forgot):
To get started:
Open action list > New action... (if you're using up to date Reaper, previously it was a little different) > New ReaScript.. > name/save your script (with .lua extension) > copy/paste the text from the code box in the now opened ReaScript Development Environmet window > Ctrl+S to save/execute the code.


Last edited by nofish; 08-08-2020 at 04:41 PM.
nofish is offline   Reply With Quote
Old 08-10-2020, 07:47 AM   #9
antiClick
Human being with feelings
 
antiClick's Avatar
 
Join Date: Mar 2007
Location: Mediterrenean Sea
Posts: 943
Default

waw, I really appreciate that. Will try ASAP and report it back.

Yeah!
antiClick 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 01:49 AM.


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