Old 06-12-2018, 01:57 PM   #1
swiiscompos
Human being with feelings
 
swiiscompos's Avatar
 
Join Date: Mar 2011
Location: London
Posts: 1,211
Default Lua: Autoincrement audio send channels of selected tracks

Here is a script that auto-increments the audio sends for a selected track. It found it extremely handy when I created my orchestral template. It's a hack of js_Autoincrement audio send channels of selected tracks

Notice: track audio outputs and sends must already exist before the script is launched.

Code:
--[[
 * ReaScript Name:  Autoincrement audio send channels of selected tracks
 * Description:  Autoincrements the audio send channels of selected tracks.
 *               Particularly useful when routing an instrument track to already existing  
 *               (for example when creating orchestral templates)
 *               The audio outputs must exist before the script is launched
 *               The sends must already exist
 *               The script starts with a dialog box in which the user can select the following:
 *                  - The starting channel from which to increment.
 *                  - Whether to remove MIDI sends from the selected tracks, which makes the routing matrix easier to read.
 *               This script is a modified version of juliansader's js_Autoincrement midi send channels of selected tracks
 *              
 * Instructions:
 * 
 * Screenshot: 
 * Notes: 
 * Category: 
 * Author: juliansader
 * Licence: GPL v3
 * Forum Thread:
 * Forum Thread URL: http://forum.cockos.com/showthread.php?t=176878
 * Version: 1.1
 * REAPER: 5.20
 * Extensions:
]]

--[[
 Changelog:
 * v1.0
    + Initial Release
]]

-- USER AREA
-- Settings that the user can customize

-- End of USER AREA

---------------------------

-- Is there anything to do?
numSelTracks = reaper.CountSelectedTracks(0)
if (numSelTracks == 0) 
    then return(0) 
end

---------------------------------------------------------------------
-- Part 1: Get user inputs (channel from which to start incrementing)
---------------------------------------------------------------------

-- Repeat until we get usable inputs
repeat
    retval, userInputsCSV = reaper.GetUserInputs("Autoincrement audio send channels", 
                                                 2, 
                                                 "Starting channel (1-63),Remove midi sends? (y/n)", 
                                                 "1,y")
    if retval == false then
        return(0)
    else -- retval == true
        gotUserInputs = true -- temporary, will be changed to false if anything is wrong

        startChan, removeAudio = userInputsCSV:match("([^,]+),([^,]+)")
        
        startChan = tonumber(startChan)
        if startChan == nil or startChan < 1 or startChan > 16 then
            gotUserInputs = false
        end
        
        if removeAudio ~= "y" and removeAudio ~= "Y" and removeAudio ~= "n" and removeAudio ~= "N" then
            gotUserInputs = false 
        end
    end
until gotUserInputs == true


------------------------------------------------------
-- Now autoincrement all audio sends of selected track
------------------------------------------------------

chan = startChan
     selTrack = reaper.GetSelectedTrack(0, 0)
     
     -- Iterate through all internal track sends
     for sendIndex = 0, reaper.GetTrackNumSends(selTrack, 0)-1 do
          reaper.SetTrackSendInfo_Value(selTrack, 0, sendIndex, "I_SRCCHAN", sendIndex*2)
          
          -- Remove MIDI sends (I_MIDIFLAGS : -1 for none)
          if removeAudio == "y" or removeAudio == "Y" then
              reaper.SetTrackSendInfo_Value(selTrack, 0, sendIndex, "I_MIDIFLAGS", -1)
          end

         
     -- Increment channel
     if chan == 64 then chan = 1 else chan = chan + 1 end

end -- for trackIndex = 0, numSelTracks-1
Attached Files
File Type: lua Autoincrement audio send channels of selected track.lua (3.3 KB, 194 views)
swiiscompos is offline   Reply With Quote
Old 06-13-2018, 01:25 PM   #2
DynamicK
Human being with feelings
 
Join Date: Nov 2017
Location: Gloucestershire, UK
Posts: 223
Default

Thanks. Useful for Kontakt
DynamicK is offline   Reply With Quote
Old 06-17-2019, 10:27 AM   #3
daeavelwyn
Human being with feelings
 
daeavelwyn's Avatar
 
Join Date: Dec 2014
Posts: 600
Default

Swiiscompos: i love you man ! Thks !
daeavelwyn 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 11:17 AM.


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