Old 05-24-2019, 10:33 AM   #1
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default Q: How to change all HW outs to pre-fader?

EDIT:

These three scripts can be found in ReaPack now:
  • Set hardware outputs of selected tracks to post-fader
  • Set hardware outputs of selected tracks to pre-fader (post-fx)
  • Set hardware outputs of selected tracks to pre-fader (pre-fx)
-----------------------------------------------

Original post:

I posted this in another subforum and got a script from J Reverb.

His original idea was to create pre-fader sends, but I want to change already existing ones.

So here is his original script.

I cut it down to this:

Code:
--I_SENDMODE : returns int *, 0=post-fader, 1=pre-fx, 2=post-fx (deprecated), 3=post-fx
----------------------------------------------------   
sendmode=1
----------------------------------------------------
local cnt_trks = reaper.CountSelectedTracks(0)  
    for i = 0, cnt_trks - 1 do
        local sel_track = reaper.GetSelectedTrack(0, i)
        
       hw_out_code=1024
--I_SRCCHAN : returns int *, index,&1024=mono, -1 for none
--I_DSTCHAN : returns int *, index, &1024=mono, otherwise stereo pair, hwout:&512=rearoute 
    reaper.SetTrackSendInfo_Value(sel_track, 1, 0, "I_SENDMODE", sendmode)
    
end           

---------------------------------------------------
It nearly does everything I need. The only missing thing is that it only affects the first HW out on the selected track. Instead I would like it to affect all HW outs. Is this possible?

I know that it has to do with the "0" in this line:
Code:
reaper.SetTrackSendInfo_Value(sel_track, 1, 0, "I_SENDMODE", sendmode)
But... how can I tell an integer to use various numbers? This goes beyond my common sense. As you can see I have got no idea of scripting at all!

Do I need to use "GetTrackNumSends" and make a loop for all sends? I wish I knew how to do that, haha!

Last edited by timothys_monster; 05-27-2019 at 08:37 PM.
timothys_monster is offline   Reply With Quote
Old 05-24-2019, 12:40 PM   #2
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default

Since I have no idea how to do it from scratch I just try editing other people's scripts.

So I took cfillion's "cfillion_Remove hardware outputs of selected tracks.lua" since it seems to affect all hardware outs.

After editing it like this, it also only changes the first hardware out, though

Code:
local self = ({reaper.get_action_context()})[2]:match('([^/\\_]+).lua$')
local UNDO_STATE_TRACKCFG = 1
local HARDWARE_OUT = 1 -- > 0

local seltracks = reaper.CountSelectedTracks()
if seltracks < 1 then return reaper.defer(function() end) end

reaper.Undo_BeginBlock()

for ti=0, seltracks-1 do
  local track = reaper.GetSelectedTrack(0, ti)
  for si=0, reaper.GetTrackNumSends(track, HARDWARE_OUT)-1 do
    reaper.SetTrackSendInfo_Value(track, 1, 0, "I_SENDMODE", 1)
  end
end

reaper.Undo_EndBlock(self, UNDO_STATE_TRACKCFG)
timothys_monster is offline   Reply With Quote
Old 05-25-2019, 11:45 AM   #3
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default

Anyone got any ideas on how to do this?
timothys_monster is offline   Reply With Quote
Old 05-25-2019, 02:05 PM   #4
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

In the inner loop where you loop through the track sends

Code:
for si=0, reaper.GetTrackNumSends(track, HARDWARE_OUT)-1 do
  reaper.SetTrackSendInfo_Value(track, 1, 0, "I_SENDMODE", 1)
end
you have si as the incrementing variable but you don't use it for send index.
The function signature for SetTrackSendInfo_Value() is:

Code:
 reaper.SetTrackSendInfo_Value( tr, category, sendidx, parmname, newvalue )
so it should be like this (untested):

Code:
reaper.SetTrackSendInfo_Value(track, 1, si, "I_SENDMODE", 1)

Last edited by nofish; 05-25-2019 at 02:44 PM.
nofish is offline   Reply With Quote
Old 05-25-2019, 04:35 PM   #5
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default

Thaaaank you, nofish!

That was it. So easy!

Awesome, now to include it in ReaPack would I definitely need a GitHub account or could someone else upload it?

Maybe I should ask cfillion to add it to his repository, since it is basically his script...
timothys_monster is offline   Reply With Quote
Old 05-26-2019, 08:33 AM   #6
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

You're welcome.

In case you want to add it to ReaPack yourself, cfillion has made web based upload tools, no GitHub account necessary I think.

https://reapack.com/upload

edit:
Nah, sorry, it says "A GitHub account is required."
nofish is offline   Reply With Quote
Old 05-26-2019, 10:57 AM   #7
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Fwiw, I've added to my Ultraschall-Api dozens of functions who deal with routing and hwout-management in a more comfortable way.
https://mespotin.uber.space/Ultrasch...1_Introduction

Maybe helpful for you in the future
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 05-27-2019, 09:31 AM   #8
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default

Amazing! I should have looked it up first...

You created a CountTrackHWOuts, that's awesome. I could have needed it. But who knows, maybe some day I will actually start to code
timothys_monster is offline   Reply With Quote
Old 05-27-2019, 09:36 AM   #9
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Nice funfact: they are faster than Reaper's original functions, when applying changes to multiple HWOuts/Sends
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is online now   Reply With Quote
Old 05-27-2019, 09:42 AM   #10
timothys_monster
Human being with feelings
 
timothys_monster's Avatar
 
Join Date: Jan 2012
Location: Germany
Posts: 1,130
Default

Seeing all these, do you think it might be possible to make a toggle script that could add HW Outs as pre-fx or post-fx sends?

I mean by activating the script and just clicking the desired channel in the routing matrix?
timothys_monster is offline   Reply With Quote
Old 08-23-2019, 01:57 AM   #11
wfd
Human being with feelings
 
Join Date: Nov 2016
Posts: 37
Default Change send/rcv for selected tracks -NOT hardware?

Hi, I came across this thread as I am trying to achieve the same goal i.e
Set Sends/Rcv of selected tracks to post-fader
Set Sends/Rcv of selected tracks to pre-fader (post-fx)
Set Sends/Rcv of selected tracks to pre-fader (pre-fx)

BUT-- Not for the hardware sends.

Does anyone know of way to achieve this?

It's frustrating to have to change each send/rcv one by one.

Many thanks
wfd is offline   Reply With Quote
Old 11-22-2019, 03:41 AM   #12
b0se
Human being with feelings
 
b0se's Avatar
 
Join Date: Jan 2019
Location: UK
Posts: 938
Default

Quote:
Originally Posted by mespotine View Post
Fwiw, I've added to my Ultraschall-Api dozens of functions who deal with routing and hwout-management in a more comfortable way.
https://mespotin.uber.space/Ultrasch...1_Introduction

Maybe helpful for you in the future
Sorry to hijack you fellas, can I ask a quick question?

I'm trying to add a hardware out (3: Output 3 / Output 4) to the selected track in lua and it's all above my skill level. Trying to learn from this thread but it's all a bit much.

Could either of you help? :¬)

Edit: Done it. In case it helps someone else:

https://forum.cockos.com/showpost.ph...postcount=1898

Last edited by b0se; 11-22-2019 at 06:04 AM.
b0se 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 03:42 AM.


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