Old 08-14-2015, 08:45 PM   #1
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,956
Default How to add fx to track via ReaScript?

Hi.
I did some experiments with track chunks, but still didn`t get it.
When I insert a plugin, state chunk returns this:
PHP Code:
<VST "VST: ReaTune (Cockos)" reatune.dll 0 "" 1919251566
bnRlcu5e7f4EAAAAAQAAAAAAAAACAAAAAAAAAAQAAAAAAAAACAAAAAAAAAACAAAAAQAAAAAAAAACAAAAAAAAAGgAAAABAAAAAAAQAAAAAAAAAAAAHgAAALgBAAAAAAAA
/w8AAPoAAAAyAAAAMgAAAAAAAAAAAAAAAAAAAAAAgEIAAEBBAAAAAAAAIEIBAAAAAQAAAAAACAABAAAAAAAAAAAAAAAAAAAAeQIAAMABAAAAAAAAAAAQAAAA

Questions:
1. Is there any way to get dll file name from reaper internal name?
2. Where to get or how to convert something to this beatiful data?

Last edited by mpl; 08-14-2015 at 10:09 PM.
mpl is offline   Reply With Quote
Old 08-14-2015, 11:19 PM   #2
SmajjL
Human being with feelings
 
Join Date: Nov 2013
Location: IKEA
Posts: 2,751
Default

Hey! Maby not what you are asking for but just in case, and maby you find anything useful in it.

Track FX selector (spk77)
https://stash.reaper.fm/v/21543/Track...20selector.zip
__________________
_Ohh.))::_Linux_::((.Xoxo_

SmajjL is offline   Reply With Quote
Old 08-14-2015, 11:28 PM   #3
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,248
Default

There's already basically a script for this, but maybe you want something else? I love it because it floats the plugin if it's already on the track or inserts it if it's not. Very handy.

Code:
//by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "SPAN";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 1);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);
You just change the plugin name in quotes to match whatever you might have renamed it.
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-15-2015, 12:50 AM   #4
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

TrackFX_GetByName has an option to insert an FX:

Code:
Lua: integer reaper.TrackFX_GetByName(MediaTrack track, string fxname, boolean instantiate)

Get the index of the first track FX insert that matches fxname. If the FX is not in the chain and instantiate is true, it will be inserted. See TrackFX_GetInstrument, TrackFX_GetEQ.
spk77 is offline   Reply With Quote
Old 08-15-2015, 01:10 AM   #5
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,248
Default

Hmm, so, that script I'm using is only one line with Lua?
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-15-2015, 01:11 AM   #6
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

This function would be nice:
Code:
reaper.TrackFX_Insert(MediaTrack track, string fxname, integer index)

...and maybe
Code:
reaper.TrackFX_Remove(MediaTrack track, integer index)
spk77 is offline   Reply With Quote
Old 08-15-2015, 01:20 AM   #7
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by foxAsteria View Post
Hmm, so, that script I'm using is only one line with Lua?
It would be about the same length in Lua

Ixix's/Elan Hickler's script does all this:
  • If named plugin not found and create is True, add it to track FX chain
  • If track FX chain is hidden, float the plugin.
  • If track FX chain is open, switch focus to the plugin if it isn't selected
spk77 is offline   Reply With Quote
Old 08-15-2015, 01:21 AM   #8
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,248
Default

Oh, ok. It also works if the Master Track is selected, but I can't recall who added that part now...
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-15-2015, 01:33 AM   #9
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by foxAsteria View Post
Oh, ok. It also works if the Master Track is selected, but I can't recall who added that part now...
That might be me

Here's the thread:
http://forum.cockos.com/showthread.php?t=141539
(A script to float a specific plug-in GUI from a selected track)
spk77 is offline   Reply With Quote
Old 08-15-2015, 01:34 AM   #10
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,248
Default

LOL, well then thanks and thanks again. Was planning to get more into the scripting business, but you guys have already solved most of the problems I wanted to...
__________________
foxyyymusic
foxAsteria is offline   Reply With Quote
Old 08-15-2015, 06:27 PM   #11
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,956
Default

spk77, just tested it. TrackFX_GetByName doesn`t work when there is already same name fx on track (as commented, actually).

I want to write a script, which add fx even if it exists on track. ReaConsole also doesn`t do what, so I guess we still haven`t API for direct inserting.
mpl is offline   Reply With Quote
Old 08-16-2015, 12:31 AM   #12
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,956
Default

I did some tests with trackstatechunk and only two times I somehow add plugin to track, but I don`t get how. lol

So, I guess we can`t just add lines to state chunk.
SWS Resources use .rfxchain files to get this binary data, as I understood. Also when inserting Reaper generates GUID, Float position and WAK (I have no idea what is that), but if it works in sws resorces, seems to be there is no need to care about that.
mpl is offline   Reply With Quote
Old 08-16-2015, 02:31 AM   #13
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by mpl View Post
spk77, just tested it. TrackFX_GetByName doesn`t work when there is already same name fx on track (as commented, actually).

I want to write a script, which add fx even if it exists on track. ReaConsole also doesn`t do what, so I guess we still haven`t API for direct inserting.
That's right - we would need reaper.TrackFX_Insert(MediaTrack track, string fxname, integer index)
spk77 is offline   Reply With Quote
Old 05-27-2020, 02:20 PM   #14
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 76
Default

Hi MPL,
even though its an old thread, is the topic still relevant to you? I think I can help here ;-)
dimentorium is offline   Reply With Quote
Old 05-27-2020, 10:20 PM   #15
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,956
Default

No, I know TrackFx_AddbyName with instantiate value solves my issue (GetByname was deprecated). TrackFX_Remove also added to an API so it solves spk77 feature request too.
mpl is offline   Reply With Quote
Old 05-30-2020, 06:19 AM   #16
dimentorium
Human being with feelings
 
Join Date: Jan 2020
Posts: 76
Default

Ok, thanks for the info. stumbled upon your thread while looking for information on the track state chunk.

Currently I can parse, convert and change it. Also loading works for some plugins but its kind of unstable. But I am using Python to do all this
dimentorium is offline   Reply With Quote
Old 07-19-2022, 11:31 AM   #17
Rockum
Human being with feelings
 
Join Date: Apr 2009
Location: Nashville
Posts: 172
Default

Quote:
Originally Posted by foxAsteria View Post
There's already basically a script for this, but maybe you want something else? I love it because it floats the plugin if it's already on the track or inserts it if it's not. Very handy.

Code:
//by IXix (translated by Elan Hickler)

function ShowNamedPlugin(sPluginName, pTrack, create) local(iSel iPlugin) (
  /*
  If named plugin not found and create is True, add it to track FX chain
  If track FX chain is hidden, float the plugin.
  If track FX chain is open, switch focus to the plugin if it isn't selected
  */
  iPlugin =  TrackFX_GetByName(pTrack, sPluginName, create);
  iPlugin > -1 ? (
    iSel = TrackFX_GetChainVisible(pTrack);
    iSel == -1 ? (
      TrackFX_GetOpen(pTrack, iPlugin) ?
      TrackFX_Show(pTrack, iPlugin, 2):
      TrackFX_Show(pTrack, iPlugin, 3);
    ):
    iSel == -2 ? TrackFX_Show(pTrack, iPlugin, 1):
    iSel != iPlugin ? TrackFX_Show(pTrack, iPlugin, 1);
  );
);
sPluginName = "SPAN";
pProject = 0;

i = 0;
loop(CountSelectedTracks(pProject),
  pTrack = GetSelectedTrack(pProject, i);
  ShowNamedPlugin(sPluginName, pTrack, 1);
  i+=1;
);
IsTrackSelected(GetMasterTrack()) ? ShowNamedPlugin(sPluginName, GetMasterTrack(), 1);
You just change the plugin name in quotes to match whatever you might have renamed it.
Anyway to do this without floating newly added FX?
Rockum is offline   Reply With Quote
Old 07-24-2022, 07:03 PM   #18
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,248
Default

Quote:
Originally Posted by Rockum View Post
Anyway to do this without floating newly added FX?
Yes, but I couldn't tell you how. You can try googling TrackFX_Show to see what changing the values will do.
__________________
foxyyymusic
foxAsteria 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 08:31 PM.


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