|
|
|
08-02-2021, 04:06 PM
|
#1
|
Human being with feelings
Join Date: Oct 2013
Posts: 437
|
LUA "add fx chain" is inserting to first slot instead of last
I took MPL's "add fx chain to selected track" lua script and modded it so it inserts a pre determined fx chain rather than opening a files selection window.
The only problem is for some reason it adds the fx first in chain (rather than last or after selected fx).
How can I fix that?
Thanks!
Here's the code in case you need to take a look at it:
Code:
function AddChunkToTrack(tr, chunk) -- add empty fx chain chunk if not exists
local _, chunk_ch = reaper.GetTrackStateChunk(tr, '', false)
if not chunk_ch:match('FXCHAIN') then chunk_ch = chunk_ch:sub(0,-3)..'<FXCHAIN\nSHOW 0\nLASTSEL 0\n DOCKED 0\n>\n>\n' end
if chunk then chunk_ch = chunk_ch:gsub('DOCKED %d', chunk) end
reaper.SetTrackStateChunk(tr, chunk_ch, false)
end
function main()
local tr = reaper.GetSelectedTrack(0,0)
if not tr then return end
retval=true;
filenameNeed4096 = reaper.GetResourcePath() .. '\\FXChains\\Limiter.RfxChain';
if retval and filenameNeed4096 then
local f = io.open(filenameNeed4096,'r')
if f then
content = f:read('a')
f:close()
AddChunkToTrack(tr, content)
end
end
end
---------------------------------------------------------------------
function CheckFunctions(str_func) local SEfunc_path = reaper.GetResourcePath()..'/Scripts/MPL Scripts/Functions/mpl_Various_functions.lua' local f = io.open(SEfunc_path, 'r') if f then f:close() dofile(SEfunc_path) if not _G[str_func] then reaper.MB('Update '..SEfunc_path:gsub('%\\', '/')..' to newer version', '', 0) else return true end else reaper.MB(SEfunc_path:gsub('%\\', '/')..' missing', '', 0) end end
--------------------------------------------------------------------
local scr_name = ({reaper.get_action_context()})[2]
local num, denom = scr_name:match('Add (%d+) to (%d+) time signature')
local ret = CheckFunctions('VF_CheckReaperVrs')
if ret then
if VF_CheckReaperVrs(5.95) then main() end
end
|
|
|
08-03-2021, 01:46 PM
|
#2
|
Human being with feelings
Join Date: Oct 2013
Posts: 437
|
Quote:
Originally Posted by mpl
Code:
function main()
local tr = reaper.GetSelectedTrack(0,0)
if not tr then return end
filename = reaper.GetResourcePath() .. '\\FXChains\\Limiter.RfxChain';
if reaper.file_exists( filename ) then
f=io.open(filename,'r')
if f then
local content = f:read('a')
f:close()
reaper.PreventUIRefresh( 1 )
reaper.InsertTrackAtIndex( reaper.CountTracks(0), false )
last_tr = reaper.GetTrack(0,reaper.CountTracks(0)-1)
AddChunkToTrack(last_tr, content)
MoveFX(last_tr, tr)
reaper.DeleteTrack( last_tr )
reaper.PreventUIRefresh( -1 )
end
end
end
----------------------------------------------------------
function AddChunkToTrack(tr, chunk) -- add empty fx chain chunk if not exists
local _, chunk_ch = reaper.GetTrackStateChunk(tr, '', false)
if not chunk_ch:match('FXCHAIN') then chunk_ch = chunk_ch:sub(0,-3)..'<FXCHAIN\nSHOW 0\nLASTSEL 0\n DOCKED 0\n>\n>\n' end
if chunk then chunk_ch = chunk_ch:gsub('DOCKED %d', chunk) end
reaper.SetTrackStateChunk(tr, chunk_ch, false)
end
----------------------------------------------------------
function MoveFX(src_tr, dest_tr)
for src_fx= reaper.TrackFX_GetCount( src_tr ), 1, -1 do
reaper.TrackFX_CopyToTrack( src_tr, src_fx-1, dest_tr, reaper.TrackFX_GetCount( dest_tr ), true )
end
end
----------------------------------------------------------
main()
|
Thanks MPL!
|
|
|
10-30-2023, 06:45 AM
|
#3
|
Human being with feelings
Join Date: May 2022
Posts: 17
|
Is it possible to modify this script to work for more selected tracks? I need an option so that fx is always inserted in the first position. In some cases this is very helpful!
|
|
|
10-30-2023, 07:39 AM
|
#4
|
Human being with feelings
Join Date: Feb 2021
Location: Right here
Posts: 1,320
|
Quote:
Originally Posted by Jonson N.
Is it possible to modify this script to work for more selected tracks? I need an option so that fx is always inserted in the first position. In some cases this is very helpful!
|
Code:
function main()
for i = 0, reaper.CountSelectedTracks(0) do
local tr = reaper.GetSelectedTrack(0, i)
if not tr then goto continue end
filename = reaper.GetResourcePath() .. '\\FXChains\\Limiter.RfxChain';
if reaper.file_exists(filename) then
f = io.open(filename, 'r')
if f then
local content = f:read('a')
f:close()
reaper.PreventUIRefresh(1)
reaper.InsertTrackAtIndex(reaper.CountTracks(0), false)
last_tr = reaper.GetTrack(0, reaper.CountTracks(0) - 1)
AddChunkToTrack(last_tr, content)
MoveFX(last_tr, tr)
reaper.DeleteTrack(last_tr)
reaper.PreventUIRefresh(-1)
end
end
::continue::
end
end
----------------------------------------------------------
function AddChunkToTrack(tr, chunk) -- add empty fx chain chunk if not exists
local _, chunk_ch = reaper.GetTrackStateChunk(tr, '', false)
if not chunk_ch:match('FXCHAIN') then chunk_ch = chunk_ch:sub(0, -3) ..
'<FXCHAIN\nSHOW 0\nLASTSEL 0\n DOCKED 0\n>\n>\n' end
if chunk then chunk_ch = chunk_ch:gsub('DOCKED %d', chunk) end
reaper.SetTrackStateChunk(tr, chunk_ch, false)
end
----------------------------------------------------------
function MoveFX(src_tr, dest_tr)
for src_fx = reaper.TrackFX_GetCount(src_tr), 1, -1 do
reaper.TrackFX_CopyToTrack(src_tr, src_fx - 1, dest_tr, reaper.TrackFX_GetCount(dest_tr), true)
end
end
----------------------------------------------------------
main()
|
|
|
10-30-2023, 09:23 AM
|
#5
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,593
|
Why just not load it directly in slot xy?
Code:
filename = 'Limiter.RfxChain' -- IF ITS ALREADY IN FXCHAINS FOLDER
for i = 1, reaper.CountSelectedTracks(0) do
local tr = reaper.GetSelectedTrack(0, i-1)
reaper.TrackFX_AddByName(tr, filename , false, -9999)
end
Or there is some need here that I've missed to do it specifically with chunk?
EDIT:ah probably because of the insert after selected fx
Last edited by Sexan; 10-30-2023 at 10:36 AM.
|
|
|
10-30-2023, 10:32 AM
|
#6
|
Human being with feelings
Join Date: May 2022
Posts: 17
|
Quote:
Originally Posted by smandrap
Code:
function main()
for i = 0, reaper.CountSelectedTracks(0) do
local tr = reaper.GetSelectedTrack(0, i)
if not tr then goto continue end
filename = reaper.GetResourcePath() .. '\\FXChains\\Limiter.RfxChain';
if reaper.file_exists(filename) then
f = io.open(filename, 'r')
if f then
local content = f:read('a')
f:close()
reaper.PreventUIRefresh(1)
reaper.InsertTrackAtIndex(reaper.CountTracks(0), false)
last_tr = reaper.GetTrack(0, reaper.CountTracks(0) - 1)
AddChunkToTrack(last_tr, content)
MoveFX(last_tr, tr)
reaper.DeleteTrack(last_tr)
reaper.PreventUIRefresh(-1)
end
end
::continue::
end
end
----------------------------------------------------------
function AddChunkToTrack(tr, chunk) -- add empty fx chain chunk if not exists
local _, chunk_ch = reaper.GetTrackStateChunk(tr, '', false)
if not chunk_ch:match('FXCHAIN') then chunk_ch = chunk_ch:sub(0, -3) ..
'<FXCHAIN\nSHOW 0\nLASTSEL 0\n DOCKED 0\n>\n>\n' end
if chunk then chunk_ch = chunk_ch:gsub('DOCKED %d', chunk) end
reaper.SetTrackStateChunk(tr, chunk_ch, false)
end
----------------------------------------------------------
function MoveFX(src_tr, dest_tr)
for src_fx = reaper.TrackFX_GetCount(src_tr), 1, -1 do
reaper.TrackFX_CopyToTrack(src_tr, src_fx - 1, dest_tr, reaper.TrackFX_GetCount(dest_tr), true)
end
end
----------------------------------------------------------
main()
|
I have no idea why, but this doesn't work for me
|
|
|
11-01-2023, 12:25 PM
|
#7
|
Human being with feelings
Join Date: May 2022
Posts: 17
|
Script "Add fx by name to selected track" by mpl after a small modification, it works and inserts selected plugin into first position.
I have no idea how to make it work on more selected tracks... only works on one track.
"-- @description Add fx by name to selected track
-- @version 1.1
-- @author me2beats
-- @changelog
-- + multiple fx
local r = reaper; local function nothing() end; local function bla() r.defer(nothing) end
local track = r.GetSelectedTrack(0,0)
if not track then bla() return end
local retval, fx_name = r.GetUserInputs("Add FX to track by name", 1, "FX name:", "")
if not retval then bla() return end
r.Undo_BeginBlock()
if not fx_name:match';' then r.TrackFX_AddByName(track, fx_name, 0, -1)
else
for name in fx_name:gmatch'(.-);' do r.TrackFX_AddByName(track, name, 0, -1) end
if fx_name:sub(-1) ~= ';' then r.TrackFX_AddByName(track, fx_name:match'.*;(.*)', 0, -1) end
end
r.Undo_EndBlock('Add fx by name to sel track', -1)
-- Add fx to track if not in chain / get index of fx in chain
local fx_index = reaper.TrackFX_AddByName(track, fx_name, 0, 1)
-- Move fx to first slot
reaper.TrackFX_CopyToTrack(track, fx_index, track, 0, true)"
|
|
|
11-01-2023, 12:40 PM
|
#8
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,593
|
Code:
local retval, fx_name = r.GetUserInputs("Add FX to track by name", 1, "FX name:", "")
if not retval then return end
r.Undo_BeginBlock()
for i = 1, r.CountSelectedTracks(0,0) do
local track = r.GetSelectedTrack(0,i-1)
if not fx_name:match(';')
then r.TrackFX_AddByName(track, fx_name, 0, -1)
else
for name in fx_name:gmatch('(.-);') do
r.TrackFX_AddByName(track, name, 0, -1) end
if fx_name:sub(-1) ~= ';' then
r.TrackFX_AddByName(track, fx_name:match'.*;(.*)', 0, -1)
end
end
-- Add fx to track if not in chain / get index of fx in chain
local fx_index = r.TrackFX_AddByName(track, fx_name, 0, 1)
-- Move fx to first slot
r.TrackFX_CopyToTrack(track, fx_index, track, 0, true)
end
r.Undo_EndBlock('Add fx by name to sel track', -1)
|
|
|
11-01-2023, 02:02 PM
|
#9
|
Human being with feelings
Join Date: May 2022
Posts: 17
|
Quote:
Originally Posted by Sexan
Code:
local retval, fx_name = r.GetUserInputs("Add FX to track by name", 1, "FX name:", "")
if not retval then return end
r.Undo_BeginBlock()
for i = 1, r.CountSelectedTracks(0,0) do
local track = r.GetSelectedTrack(0,i-1)
if not fx_name:match(';')
then r.TrackFX_AddByName(track, fx_name, 0, -1)
else
for name in fx_name:gmatch('(.-);') do
r.TrackFX_AddByName(track, name, 0, -1) end
if fx_name:sub(-1) ~= ';' then
r.TrackFX_AddByName(track, fx_name:match'.*;(.*)', 0, -1)
end
end
-- Add fx to track if not in chain / get index of fx in chain
local fx_index = r.TrackFX_AddByName(track, fx_name, 0, 1)
-- Move fx to first slot
r.TrackFX_CopyToTrack(track, fx_index, track, 0, true)
end
r.Undo_EndBlock('Add fx by name to sel track', -1)
|
Work perfectly! Thank you very much
|
|
|
11-02-2023, 10:54 AM
|
#10
|
Human being with feelings
Join Date: Oct 2023
Posts: 8
|
Quote:
Originally Posted by Jonson N.
local retval, fx_name = r.GetUserInputs("Add FX to track by name", 1, "FX name:", "")
if not retval then return end
r.Undo_BeginBlock()
for i = 1, r.CountSelectedTracks(0,0) do
local track = r.GetSelectedTrack(0,i-1)
if not fx_name:match(';')
then r.TrackFX_AddByName(track, fx_name, 0, -1)
else
for name in fx_name:gmatch('(.-);') do
r.TrackFX_AddByName(track, name, 0, -1) end
if fx_name:sub(-1) ~= ';' then
r.TrackFX_AddByName(track, fx_name:match'.*;(.*)', 0, -1)
end
end
-- Add fx to track if not in chain / get index of fx in chain
local fx_index = r.TrackFX_AddByName(track, fx_name, 0, 1)
-- Move fx to first slot
r.TrackFX_CopyToTrack(track, fx_index, track, 0, true)
end
r.Undo_EndBlock('Add fx by name to sel track', -1))
|
Sorry guys, I have no idea where to place the plugin/chain name in this script in order to use it. I'm quite new in this. Can someone help a bit ? Thank you very much
|
|
|
11-02-2023, 11:39 AM
|
#11
|
Human being with feelings
Join Date: Feb 2021
Location: Right here
Posts: 1,320
|
Quote:
Originally Posted by swissrecordings
Sorry guys, I have no idea where to place the plugin/chain name in this script in order to use it. I'm quite new in this. Can someone help a bit ? Thank you very much
|
This script asks for Fx name when you run it
|
|
|
11-02-2023, 03:33 PM
|
#12
|
Human being with feelings
Join Date: Oct 2023
Posts: 8
|
Quote:
Originally Posted by smandrap
This script asks for Fx name when you run it
|
Ok, thanks a lot.
No possibilities to this day to add some specific plugin or chain to the script ?
My aim would be to insert some midi specific chain at first slot, chain that would be midi linked to controllers when track is on focus (chain would include transpose, delay, etc...)
The only solution I could imagine in order to emulate some easy access to transposition and track's delay...(like studio one or cubase)
Thank you anyway.
|
|
|
11-02-2023, 03:48 PM
|
#13
|
Human being with feelings
Join Date: Feb 2021
Location: Right here
Posts: 1,320
|
Quote:
No possibilities to this day to add some specific plugin or chain to the script ?
|
PLUGIN:
Code:
local FX_NAME = 'reaeq' --Change This
for i = 0, reaper.CountSelectedTracks(0) - 1 do
local tr = reaper.GetSelectedTrack(0, i)
reaper.TrackFX_AddByName(tr, FX_NAME, false, -1000)
end
CHAIN:
First post of this thread
Quote:
emulate some easy access to transposition and track's delay...(like studio one or cubase)
|
Last edited by smandrap; 11-02-2023 at 03:56 PM.
|
|
|
11-03-2023, 02:38 AM
|
#14
|
Human being with feelings
Join Date: Oct 2023
Posts: 8
|
Quote:
Originally Posted by smandrap
PLUGIN:
Code:
local FX_NAME = 'reaeq' --Change This
for i = 0, reaper.CountSelectedTracks(0) - 1 do
local tr = reaper.GetSelectedTrack(0, i)
reaper.TrackFX_AddByName(tr, FX_NAME, false, -1000)
end
CHAIN:
First post of this thread
|
Thanks.
But it does not work that way.
Regarding track delay :
Within Reaper :
1 - open the routing window
2 - check the track delay box
3 - adjust parameter
4 - close routing window
Within Studio One :
1 - adjust parameter
Regarding track's transposition :
Within Reaper :
1 - select all items on the track
2 - manually adjust the pitch
or
Load JS transpose (cause Reacontrol does not work properly, it does not send notes off while changing semitones, leading to overflooded vsti's) on first slot, before the vsti, which in some cases can lead to crashes if the sequencer is running (in my case happened many times with VPS Avenger or U-he repro5)
Within Studio One :
1 - simply adjust parameter for the whole track
Just checked the bug section in order to report those crashes, however to my humble opinion those two basic features should be available in plain sight, as everybody has to deal with various midi instruments (attack times, octave changes...), it should not be a hassle.
Thank you anyway
Last edited by swissrecordings; 11-03-2023 at 05:15 AM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 10:02 AM.
|