reaper-oss / sws

The SWS extension is a collection of features that seamlessly integrate into REAPER, the Digital Audio Workstation (DAW) software by Cockos, Inc
https://www.sws-extension.org/
MIT License
456 stars 85 forks source link

feature request : create new actions : "Float FX (number) for monitoring fx" #1895

Open djabthrash opened 2 months ago

djabthrash commented 2 months ago

Hi !

Now in Reaper we have the following type of actions available for selected tracks :

SWS/S&M: Float FX 1 for selected tracks SWS/S&M: Float FX 2 for selected tracks etc ...

I'd need to use similar actions but for MONITORING FX, so actions like : SWS/S&M: Float FX 1 for monitoring FX SWS/S&M: Float FX 2 for monitoring FX etc ...

This would make my life way easier, since i use monitoring FX a ton and and I'd use custom buttons and toolbars to toggle float some of them frequently.

Thanks !

Buy-One commented 2 months ago

The following Lua script will do what you're looking for. Multiply it as many times as the numbers of Monitoring FX whose window you'd like to float and include the relevant FX number in the file name as suggested in the code. The script looks for the number in the file name.


-- NAME SCRIPT INSTANCE 'Float FX n for monitoring FX' where n is FX number in the chain

local is_new_value, scr_name, sect_ID, cmd_ID, mode, resol, val, contextstr = reaper.get_action_context()
local fx_idx = scr_name:match('.+[\\/].-FX (%d+)')
local master = reaper.GetMasterTrack(0)
local fx_cnt = reaper.TrackFX_GetRecCount(master)
local err = (not fx_idx or not tonumber(fx_idx) or fx_idx+0 == 0) and 'Valid FX number wasn\'t found in the script name'
or fx_cnt == 0 and 'No FX in the Monitoring FX chain' or fx_idx+0 > fx_cnt and 'FX No '..fx_idx..' doesn\'t exist in the chain'

    if err then
    reaper.MB(err,'ERROR',0) 
    return reaper.defer(function() do return end end) end

reaper.TrackFX_Show(master, fx_idx-1+0x1000000, 3) -- showFlag 3 float
djabthrash commented 2 months ago

The following Lua script will do what you're looking for. Multiply it as many time as the numbers of Monitoring FX whose window you'd like to float and include the relevant FX number in the file name as suggested in the code. The script looks for the number in the file name.


-- NAME SCRIPT INSTANCE 'Float FX n for monitoring FX' where n is FX number in the chain

local is_new_value, scr_name, sect_ID, cmd_ID, mode, resol, val, contextstr = reaper.get_action_context()
local fx_idx = scr_name:match('.+[\\/].-FX (%d+)')
local master = reaper.GetMasterTrack(0)
local fx_cnt = reaper.TrackFX_GetRecCount(master)
local err = (not fx_idx or not tonumber(fx_idx) or fx_idx+0 == 0) and 'Valid FX number wasn\'t found in the script name'
or fx_cnt == 0 and 'No FX in the Monitoring FX chain' or fx_idx+0 > fx_cnt and 'FX No '..fx_idx..' doesn\'t exist in the chain'

  if err then
  reaper.MB(err,'ERROR',0) 
  return reaper.defer(function() do return end end) end

reaper.TrackFX_Show(master, fx_idx-1+0x1000000, 3) -- showFlag 3 float

@Buy-One : Thanks a ton ! Worked like a charm !

djabthrash commented 2 months ago

@Buy-One : do you know what I should modify in the script to make it do "toggle float" instead of just "float" ?

Buy-One commented 2 months ago

Here's an updated code for toggling


-- NAME SCRIPT INSTANCE 'Float FX n for monitoring FX' where n is FX number in the chain

local is_new_value, scr_name, sect_ID, cmd_ID, mode, resol, val, contextstr = reaper.get_action_context()
local fx_idx = scr_name:match('.+[\\/].-FX (%d+)')
local master = reaper.GetMasterTrack(0)
local fx_cnt = reaper.TrackFX_GetRecCount(master)
local err = (not fx_idx or not tonumber(fx_idx) or fx_idx+0 == 0) and 'Valid FX number wasn\'t found in the script name'
or fx_cnt == 0 and 'No FX in the Monitoring FX chain' or fx_idx+0 > fx_cnt and 'FX No '..fx_idx..' doesn\'t exist in the chain'

    if err then
    reaper.MB(err,'ERROR',0) 
    return reaper.defer(function() do return end end) end

local fx_idx = fx_idx-1+0x1000000
local showFlag = reaper.TrackFX_GetFloatingWindow(master, fx_idx) and 2 or 3

reaper.TrackFX_Show(master, fx_idx, showFlag) -- showFlag is 3 float or 2 unfloat
djabthrash commented 2 months ago

Here's an updated code for toggling


-- NAME SCRIPT INSTANCE 'Float FX n for monitoring FX' where n is FX number in the chain

local is_new_value, scr_name, sect_ID, cmd_ID, mode, resol, val, contextstr = reaper.get_action_context()
local fx_idx = scr_name:match('.+[\\/].-FX (%d+)')
local master = reaper.GetMasterTrack(0)
local fx_cnt = reaper.TrackFX_GetRecCount(master)
local err = (not fx_idx or not tonumber(fx_idx) or fx_idx+0 == 0) and 'Valid FX number wasn\'t found in the script name'
or fx_cnt == 0 and 'No FX in the Monitoring FX chain' or fx_idx+0 > fx_cnt and 'FX No '..fx_idx..' doesn\'t exist in the chain'

  if err then
  reaper.MB(err,'ERROR',0) 
  return reaper.defer(function() do return end end) end

local fx_idx = fx_idx-1+0x1000000
local showFlag = reaper.TrackFX_GetFloatingWindow(master, fx_idx) and 2 or 3

reaper.TrackFX_Show(master, fx_idx, showFlag) -- showFlag is 3 float or 2 unfloat

@Buy-One : Thanks again ! Worked perfectly !