Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 03-16-2020, 07:35 PM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default 2 scripts: Copy track settings and Paste track settings to multiple tracks

Here are 2 scripts... It copies: Track settings (vol, pan, mute state etc), Sends and FX.

One is to copy a track. The other is to Paste the copied track settings to selected tracks. It will not rename the track... just change the settings.

Please test it out and let me know if it has any issues.




Copy track parameters and values

Code:
-- written by Thonex

-- COPY track data

function Msg (param)
  reaper.ShowConsoleMsg(tostring (param).."\n")
end


function Copy_Track_Vals ()
  reaper.ClearConsole()

  tr =  reaper.GetSelectedTrack( 0, 0 )
  
  stored_val = {}
  
  trk_info_val_id ={"B_MUTE", "B_PHASE", "IP_TRACKNUMBER", "I_SOLO", "I_FXEN",
                    "I_RECARM", "I_RECINPUT", "I_RECMODE", "I_RECMON", "I_RECMONITEMS",
                    "I_AUTOMODE", "I_NCHAN", "I_SELECTED,", "I_WNDH", "I_TCPH", "I_TCPY",
                    "I_MCPX", "I_MCPY", "I_MCPW", "I_MCPH", "I_FOLDERDEPTH", "I_FOLDERCOMPACT",
                    "I_MIDIHWOUT", "I_PERFFLAGS", "I_CUSTOMCOLOR", "I_HEIGHTOVERRIDE",
                    "B_HEIGHTLOCK", "D_VOL", "D_PAN", "D_WIDTH", "D_DUALPANL", "D_DUALPANR",
                    "I_PANMODE", "D_PANLAW", "P_ENV", "B_SHOWINMIXER", "B_SHOWINTCP",
                    "B_MAINSEND", "C_MAINSEND_OFFS", "B_FREEMODE", "C_BEATATTACHMODE",
                    "F_MCP_FXSEND_SCALE", "F_MCP_SENDRGN_SCALE", "I_PLAY_OFFSET_FLAG",
                    "D_PLAY_OFFSET"}--, "P_PARTRACK", "P_PROJECT"

  
  for i = 1, #trk_info_val_id do
    stored_val [i] = reaper.GetMediaTrackInfo_Value( tr, trk_info_val_id[i] )
   -- Msg(trk_info_val_id[i].. " = ".. stored_val [i])
  end
  val_table = table.concat(stored_val, ",")
  reaper.SetExtState("Copied Track Parameters", "Values", val_table, true)
  --Msg(reaper.GetExtState("Copied Track Parameters", "Values"))
  
  
  --if reaper.GetTrackNumSends( tr, 0 ) > 0 then
    copy_sends = reaper.NamedCommandLookup("_S&M_COPYSNDRCV3")
    reaper.Main_OnCommand( copy_sends,0 )
    reaper.SetExtState("Copied Track Parameters", "Sends", reaper.GetTrackNumSends( tr, 0 ), true)
 -- end
  --
  --if reaper.TrackFX_GetCount( tr ) > 0 then
    copy_fxs = reaper.NamedCommandLookup("_S&M_COPYFXCHAIN5")  
    reaper.Main_OnCommand( copy_fxs,0 )
    reaper.SetExtState("Copied Track Parameters", "FX", reaper.TrackFX_GetCount( tr ), true)
 -- end
end

Copy_Track_Vals ()
Paste track parameters and values

Code:
-- PASTE track data

function Msg (param)
  reaper.ShowConsoleMsg(tostring (param).."\n")
end



function GET_EXT_STATE() -- gets the values from the system

    local str = reaper.GetExtState("Copied Track Parameters", "Values") 
    
    if str and str ~= "" then
        vals = SPLIT_STRING(str, ",")
    end   
end

function SPLIT_STRING(inputstr, sep) -- Splits string example:  vals = SPLIT_STRING(retvals_csv,",")
    if sep == nil then
            sep = "%s"
    end
    local t={}
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
            t[#t+1] = str                          
    end
    return t
end

function Paste_Track_Vals ()
  reaper.PreventUIRefresh(1)
  reaper.ClearConsole() 
  reaper.Undo_BeginBlock()
  
  
  
  local num_sel_tracks =  reaper.CountSelectedTracks( 0 )
  
  if num_sel_tracks == 0 then return end
  
  
  stored_val = {}

  
  GET_EXT_STATE() -- vals[] are the ext state array
 
  
  local trk_info_val_id ={"B_MUTE", "B_PHASE", "IP_TRACKNUMBER", "I_SOLO", "I_FXEN",
                    "I_RECARM", "I_RECINPUT", "I_RECMODE", "I_RECMON", "I_RECMONITEMS",
                    "I_AUTOMODE", "I_NCHAN", "I_SELECTED,", "I_WNDH", "I_TCPH", "I_TCPY",
                    "I_MCPX", "I_MCPY", "I_MCPW", "I_MCPH", "I_FOLDERDEPTH", "I_FOLDERCOMPACT",
                    "I_MIDIHWOUT", "I_PERFFLAGS", "I_CUSTOMCOLOR", "I_HEIGHTOVERRIDE",
                    "B_HEIGHTLOCK", "D_VOL", "D_PAN", "D_WIDTH", "D_DUALPANL", "D_DUALPANR",
                    "I_PANMODE", "D_PANLAW", "P_ENV", "B_SHOWINMIXER", "B_SHOWINTCP",
                    "B_MAINSEND", "C_MAINSEND_OFFS", "B_FREEMODE", "C_BEATATTACHMODE",
                    "F_MCP_FXSEND_SCALE", "F_MCP_SENDRGN_SCALE", "I_PLAY_OFFSET_FLAG",
                    "D_PLAY_OFFSET"}--, "P_PARTRACK", "P_PROJECT"
  
  
  for ii = 0, num_sel_tracks -1 do
    local tr =  reaper.GetSelectedTrack( 0, ii )
    for i = 1, #vals do
      --Msg(vals [i])
      reaper.SetMediaTrackInfo_Value( tr, trk_info_val_id[i],vals [i] )
    end
  end  
 
    
  if tonumber(reaper.GetExtState("Copied Track Parameters", "Sends")) > 0 then
    paste_sends = reaper.NamedCommandLookup("_S&M_PASTSNDRCV3")
    reaper.Main_OnCommand( paste_sends,0 )
  end
  
  if tonumber(reaper.GetExtState("Copied Track Parameters", "FX")) > 0 then
    paste_fxs = reaper.NamedCommandLookup( "_S&M_COPYFXCHAIN10")
    reaper.Main_OnCommand( paste_fxs,0 )
  end
  
  reaper.PreventUIRefresh(-1)
  reaper.UpdateArrange()
  reaper.Undo_EndBlock("Paste Track Parameters",-1) 
end

Paste_Track_Vals ()
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.

Last edited by Thonex; 03-16-2020 at 10:49 PM.
Thonex is offline   Reply With Quote
Old 03-16-2020, 10:05 PM   #2
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Updated Paste script to paste track settings to all selected tracks.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 03-17-2020, 03:24 AM   #3
DynamicK
Human being with feelings
 
Join Date: Nov 2017
Location: Gloucestershire, UK
Posts: 223
Default

Thanks Andrew.
DynamicK is offline   Reply With Quote
Old 03-17-2020, 04:51 AM   #4
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Thanks! Can be useful! A more advanced version could be one script that has a GUI where the user could check what settings would like to be copied, and could set from there the Copy From Track and the Copy To Track(s).
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 03-17-2020, 06:29 AM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

Indeed, a GUI version would be more flexible, even if you only want to preserve one original track value like color.


Using Lokasenna GUI with checkbox should be fine
X-Raym is offline   Reply With Quote
Old 03-17-2020, 07:03 AM   #6
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
Default

Can not sws snapshots do this as well?
TonE is offline   Reply With Quote
Old 03-17-2020, 10:20 AM   #7
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

@amagalma and @X-Raym,

Thanks... and that's a pretty good idea. Personally I just wanted something I could bind to a key command and not have to make checkbox selections. But I could see how that would be appealing. Now... to learn how to integrate Lokas' awesome GUI into a script :O

@TonE

Maybe... but I've never been able to understand what these snapshots do. Just now I tried to copy some settings and nothing happened. So clearly I don't know how to use them.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 03-17-2020, 10:56 AM   #8
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,032
Default

Oh with snapshots you can do almost anything you can imagine. At some point I tried some crazy idea, doing all kind of step, including undo's inbetween, and yes, in the end it was working exactly as I imagined initially.

Meaning: When combined with custom actions, you can do almost anything.

But it is always good having multiple similar solutions, better for the market. Thanks for sharing.
TonE is offline   Reply With Quote
Old 03-17-2020, 11:41 AM   #9
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by TonE View Post
Oh with snapshots you can do almost anything you can imagine. At some point I tried some crazy idea, doing all kind of step, including undo's inbetween, and yes, in the end it was working exactly as I imagined initially.

Meaning: When combined with custom actions, you can do almost anything.

But it is always good having multiple similar solutions, better for the market. Thanks for sharing.
I still have no clue what snapshot does LOL... but that's ok... I'm a little slow!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 03-17-2020, 03:00 PM   #10
akademie
Human being with feelings
 
Join Date: Mar 2007
Posts: 4,018
Default

Working great.
Thank you Thonex

P.S.: Would it be possible to add a 3rd script, that would save track copied parameters to a new lua script (would ask for filename...) as a kind of template?
I mean that one could then prepare few such templates (like -6dB/solo/left, other like 0dB/center, other 0dB/mute/right, etc. if you understand what I mean).
akademie is offline   Reply With Quote
Old 03-17-2020, 03:03 PM   #11
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by akademie View Post
Working great.
Thank you Thonex

P.S.: Would it be possible to add a 3rd script, that would save track copied parameters to a new lua script (would ask for filename...) as a kind of template?
I mean that one could then prepare few such templates (like -6dB/solo/left, other like 0dB/center, other 0dB/mute/right, etc. if you understand what I mean).
Very good idea.

I'm trying to learn the Lokas' GUI builder and injecting code into it. Maybe one day
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 10-15-2020, 06:09 AM   #12
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Thanks Thonex!
Edgemeal is offline   Reply With Quote
Old 10-16-2020, 09:13 PM   #13
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,008
Default

Quote:
Originally Posted by amagalma View Post
Thanks! Can be useful! A more advanced version could be one script that has a GUI where the user could check what settings would like to be copied, and could set from there the Copy From Track and the Copy To Track(s).
good idea amagalma

and good script Thonex
daniellumertz is offline   Reply With Quote
Old 10-16-2020, 11:35 PM   #14
todoublez
Human being with feelings
 
todoublez's Avatar
 
Join Date: Aug 2019
Location: beijing
Posts: 612
Default

Brilliant

Is it possible to apply tracks settings from track template ?
todoublez 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 06:17 AM.


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