Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Q&A, Tips, Tricks and Howto

Reply
 
Thread Tools Display Modes
Old 12-30-2021, 04:41 AM   #1
Junolab
Human being with feelings
 
Join Date: Jul 2020
Posts: 229
Default Keycommand to freeze x-number of plugins?

I'm using a Stream Deck for shortcuts in Reaper and wants to make a shortcut for freezing x-number of plugins from the selected track in stereo.

Something like:

- Freeze first plugin in selected track to stereo
- Freese the first 2 plugins in selected track to stereo
- Freese the first 3 plugins in selected track to stereo

And so on. Anyone who knows how?

Last edited by Junolab; 12-30-2021 at 05:52 AM. Reason: Changed from tracks to olugins
Junolab is offline   Reply With Quote
Old 12-30-2021, 05:39 AM   #2
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

I assume you mean in your question: "x-number of plugins".
If so, could you please correct your question ?


Thx and Kind regards.
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 12-30-2021, 05:52 AM   #3
Junolab
Human being with feelings
 
Join Date: Jul 2020
Posts: 229
Default

Quote:
Originally Posted by vanhaze View Post
I assume you mean in your question: "x-number of plugins".
If so, could you please correct your question ?


Thx and Kind regards.
Doh that's true. Done
Junolab is offline   Reply With Quote
Old 12-30-2021, 06:08 AM   #4
vanhaze
Human being with feelings
 
vanhaze's Avatar
 
Join Date: Jul 2012
Location: Netherlands
Posts: 5,247
Default

Thank you !


Now, to answer your question:
Maybe what you want is scriptable.
So i suggest putting your question in the scripting sub-forum:


https://forum.cockos.com/forumdisplay.php?f=3


Kind regards.
__________________
Macbook Pro INTEL | Reaper, always latest version | OSX Ventura | Presonus Studio 24c
My Reaper Tips&Tricks YouTube Channel: https://www.youtube.com/user/vanhaze2000/playlists
vanhaze is offline   Reply With Quote
Old 12-30-2021, 10:18 AM   #5
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

There are no native actions for these, but I've modified "Script: Archie_FX; Freeze track in stereo, to specified FX (user input).lua". Just replace "ENTER YOUR NUMBER HERE" with the number you need. You'll have to create as many scripts as you need different numbers. You can save this code to a file with lua extension and then in Actions->New action->Load Reascript. Or New Reascript will open a window where you will paste this code and change the value. After that save it. In both cases you'll need to assign the script to your shortcuts.
Code:
    local function no_undo();reaper.defer(function()end);end;
    local command_id,inf;
    command_id = 41223;
    inf = "stereo";
    local sel;
    local LastTouchedTrack = reaper.GetLastTouchedTrack();
    if LastTouchedTrack then;
        sel = reaper.GetMediaTrackInfo_Value(LastTouchedTrack,"I_SELECTED");
    end;
    if not LastTouchedTrack or sel == 0 then;
        reaper.MB("Track not selected","Woops",0);
        no_undo() return;
    end;
    local freezTrack = LastTouchedTrack;
    local FX_Count = reaper.TrackFX_GetCount(freezTrack);
    if FX_Count == 0 then;
        reaper.MB("No Fx in track","Woops",0);
        no_undo() return;
    end;
    local retval,str = reaper.GetTrackStateChunk(freezTrack,"",false);
    local numb = (tonumber(str:match("<FXCHAIN.-LASTSEL ([-]-%d+)"))or -1)+1;
    local FX_Count = reaper.TrackFX_GetCount(freezTrack);
    if FX_Count < numb then numb = FX_Count end;

    ::Repeat1::
    retvals_csv = ENTER YOUR NUMBER HERE;
    if not retvals_csv or retvals_csv < 1 or retvals_csv > FX_Count then;
        local MB = reaper.MB("ENG:\nIncorrect value\nValues must be between 1 and "..FX_Count,"ERROR",5);
        if MB == 2 then no_undo() return end;
        if MB == 4 then goto Repeat1 end;
    end;
    reaper.PreventUIRefresh(1);
    reaper.Undo_BeginBlock();
    reaper.InsertTrackAtIndex(0,false);
    local firstTrack = reaper.GetTrack(0,0);
    for i = reaper.TrackFX_GetCount(firstTrack)-1,0,-1 do;
        reaper.TrackFX_Delete(firstTrack,i);
    end;
    local fxCount = reaper.TrackFX_GetCount(freezTrack);
    for i = 1, (fxCount-retvals_csv) do;
        local fxCountM = reaper.TrackFX_GetCount(firstTrack);
        reaper.TrackFX_CopyToTrack(freezTrack,retvals_csv,firstTrack,fxCountM,true);
    end;
    reaper.Main_OnCommand(command_id,0);
    local FX_Count = reaper.TrackFX_GetCount(firstTrack);
    for i = 1, FX_Count do;
        local FX_GetCount = reaper.TrackFX_GetCount(freezTrack);
        reaper.TrackFX_CopyToTrack(firstTrack,0,freezTrack,FX_GetCount,true);
    end;
    reaper.DeleteTrack(firstTrack);
    reaper.Undo_EndBlock("Freeze track in "..inf..", up selected FX",-1);
    reaper.PreventUIRefresh(-1);
vitalker is online now   Reply With Quote
Old 12-30-2021, 02:13 PM   #6
Junolab
Human being with feelings
 
Join Date: Jul 2020
Posts: 229
Default

Quote:
Originally Posted by vitalker View Post
There are no native actions for these, but I've modified "Script: Archie_FX; Freeze track in stereo, to specified FX (user input).lua". Just replace "ENTER YOUR NUMBER HERE" with the number you need. You'll have to create as many scripts as you need different numbers. You can save this code to a file with lua extension and then in Actions->New action->Load Reascript. Or New Reascript will open a window where you will paste this code and change the value. After that save it. In both cases you'll need to assign the script to your shortcuts.
Code:
    local function no_undo();reaper.defer(function()end);end;
    local command_id,inf;
    command_id = 41223;
    inf = "stereo";
    local sel;
    local LastTouchedTrack = reaper.GetLastTouchedTrack();
    if LastTouchedTrack then;
        sel = reaper.GetMediaTrackInfo_Value(LastTouchedTrack,"I_SELECTED");
    end;
    if not LastTouchedTrack or sel == 0 then;
        reaper.MB("Track not selected","Woops",0);
        no_undo() return;
    end;
    local freezTrack = LastTouchedTrack;
    local FX_Count = reaper.TrackFX_GetCount(freezTrack);
    if FX_Count == 0 then;
        reaper.MB("No Fx in track","Woops",0);
        no_undo() return;
    end;
    local retval,str = reaper.GetTrackStateChunk(freezTrack,"",false);
    local numb = (tonumber(str:match("<FXCHAIN.-LASTSEL ([-]-%d+)"))or -1)+1;
    local FX_Count = reaper.TrackFX_GetCount(freezTrack);
    if FX_Count < numb then numb = FX_Count end;

    ::Repeat1::
    retvals_csv = ENTER YOUR NUMBER HERE;
    if not retvals_csv or retvals_csv < 1 or retvals_csv > FX_Count then;
        local MB = reaper.MB("ENG:\nIncorrect value\nValues must be between 1 and "..FX_Count,"ERROR",5);
        if MB == 2 then no_undo() return end;
        if MB == 4 then goto Repeat1 end;
    end;
    reaper.PreventUIRefresh(1);
    reaper.Undo_BeginBlock();
    reaper.InsertTrackAtIndex(0,false);
    local firstTrack = reaper.GetTrack(0,0);
    for i = reaper.TrackFX_GetCount(firstTrack)-1,0,-1 do;
        reaper.TrackFX_Delete(firstTrack,i);
    end;
    local fxCount = reaper.TrackFX_GetCount(freezTrack);
    for i = 1, (fxCount-retvals_csv) do;
        local fxCountM = reaper.TrackFX_GetCount(firstTrack);
        reaper.TrackFX_CopyToTrack(freezTrack,retvals_csv,firstTrack,fxCountM,true);
    end;
    reaper.Main_OnCommand(command_id,0);
    local FX_Count = reaper.TrackFX_GetCount(firstTrack);
    for i = 1, FX_Count do;
        local FX_GetCount = reaper.TrackFX_GetCount(freezTrack);
        reaper.TrackFX_CopyToTrack(firstTrack,0,freezTrack,FX_GetCount,true);
    end;
    reaper.DeleteTrack(firstTrack);
    reaper.Undo_EndBlock("Freeze track in "..inf..", up selected FX",-1);
    reaper.PreventUIRefresh(-1);
Thanks!!! I've tried to run this, but nothing happens. It does complain though if a track haven't been selected:
Code:
  local function no_undo();reaper.defer(function()end);end;
   local command_id,inf;
   command_id = 41223;
   inf = "stereo";
   local sel;
   local LastTouchedTrack = reaper.GetLastTouchedTrack();
   if LastTouchedTrack then;
       sel = reaper.GetMediaTrackInfo_Value(LastTouchedTrack,"I_SELECTED");
   end;
   if not LastTouchedTrack or sel == 0 then;
       reaper.MB("Track not selected","Woops",0);
       no_undo() return;
   end;
   local freezTrack = LastTouchedTrack;
   local FX_Count = reaper.TrackFX_GetCount(freezTrack);
   if FX_Count == 0 then;
       reaper.MB("No Fx in track","Woops",0);
       no_undo() return;
   end;
   local retval,str = reaper.GetTrackStateChunk(freezTrack,"",false);
   local numb = (tonumber(str:match("<FXCHAIN.-LASTSEL ([-]-%d+)"))or -1)+1;
   local FX_Count = reaper.TrackFX_GetCount(freezTrack);
   if FX_Count < numb then numb = FX_Count end;

   ::Repeat1::
   retvals_csv = 2;
   if not retvals_csv or retvals_csv < 1 or retvals_csv > FX_Count then;
       local MB = reaper.MB("ENG:\nIncorrect value\nValues must be between 1 and "..FX_Count,"ERROR",5);
       if MB == 2 then no_undo() return end;
       if MB == 4 then goto Repeat1 end;
   end;
   reaper.PreventUIRefresh(1);
   reaper.Undo_BeginBlock();
   reaper.InsertTrackAtIndex(0,false);
   local firstTrack = reaper.GetTrack(0,0);
   for i = reaper.TrackFX_GetCount(firstTrack)-1,0,-1 do;
       reaper.TrackFX_Delete(firstTrack,i);
   end;
   local fxCount = reaper.TrackFX_GetCount(freezTrack);
   for i = 1, (fxCount-retvals_csv) do;
       local fxCountM = reaper.TrackFX_GetCount(firstTrack);
       reaper.TrackFX_CopyToTrack(freezTrack,retvals_csv,firstTrack,fxCountM,true);
   end;
   reaper.Main_OnCommand(command_id,0);
   local FX_Count = reaper.TrackFX_GetCount(firstTrack);
   for i = 1, FX_Count do;
       local FX_GetCount = reaper.TrackFX_GetCount(freezTrack);
       reaper.TrackFX_CopyToTrack(firstTrack,0,freezTrack,FX_GetCount,true);
   end;
   reaper.DeleteTrack(firstTrack);
   reaper.Undo_EndBlock("Freeze track in "..inf..", up selected FX",-1);
   reaper.PreventUIRefresh(-1);
Junolab is offline   Reply With Quote
Old 12-30-2021, 02:25 PM   #7
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Quote:
Originally Posted by Junolab View Post
Thanks!!! I've tried to run this, but nothing happens. It does complain though if a track haven't been selected:
That's ok. When you compiled the code, close the editor and run it from Actions. You also should select a track and have there some FX.
vitalker is online now   Reply With Quote
Old 12-30-2021, 02:42 PM   #8
Junolab
Human being with feelings
 
Join Date: Jul 2020
Posts: 229
Default

Quote:
Originally Posted by vitalker View Post
That's ok. When you compiled the code, close the editor and run it from Actions. You also should select a track and have there some FX.
I tried that, but it didn't work. You can see it here: https://mortenhjort.dk/uploads/2021/freeze.gif

Also tried to run it from the action list. :l
Junolab is offline   Reply With Quote
Old 12-30-2021, 04:17 PM   #9
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Quote:
Originally Posted by Junolab View Post
I tried that, but it didn't work. You can see it here: https://mortenhjort.dk/uploads/2021/freeze.gif

Also tried to run it from the action list. :l
Try this file. I didn't change anything here except replacing that phrase with 3. It works here. Just click New action->Load ReaScript. Then select your track with FX and Run the script. I don't see how you run the script on you GIF, nor I see your track's content.

freeze up to.lua
vitalker is online now   Reply With Quote
Old 12-31-2021, 05:18 AM   #10
Junolab
Human being with feelings
 
Join Date: Jul 2020
Posts: 229
Default

Quote:
Originally Posted by vitalker View Post
Try this file. I didn't change anything here except replacing that phrase with 3. It works here. Just click New action->Load ReaScript. Then select your track with FX and Run the script. I don't see how you run the script on you GIF, nor I see your track's content.

Attachment 47413
That worked brilliantly! Not sure what got wrong before. Thank you so much for your time and skills
Junolab is offline   Reply With Quote
Old 12-31-2021, 07:29 AM   #11
vitalker
Human being with feelings
 
vitalker's Avatar
 
Join Date: Dec 2012
Posts: 13,333
Default

Quote:
Originally Posted by Junolab View Post
That worked brilliantly! Not sure what got wrong before. Thank you so much for your time and skills
You're welcome. The original script is written by Archie. I just made it smaller and removed parts which are redundant.
vitalker is online now   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 02:04 AM.


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