Old 06-09-2021, 02:35 PM   #2561
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Posts: 596
Default Request - toggle mute hardware out of selected tracks

This is a very long post, my answer is at the bottom, however problems remain... only muting hw output. See EDIT6
Also - did not get to toggle master parent yet.

I use an x32, want to do virtual sound checks with it and reaper.
No problem.
Then I want to mix in the box, need to
1. toggle mute off for hardware outs of selected tracks then
2. toggle master parent on for selected tracks.

Checked reapack - Nofish has a mute first n hardware outs on tracks that are currently recording, but that is closest.

Not sure where to start.

Thanks.
Here is a start at muting hardware output, but it only does the send

Code:
-- Lua script to toggle mute
-- TRACK SEND 1 on selected tracks

local send_target = 0 -- send 1, as send counts start at 0 in Reaper 
-- is this the hardware output if I set it to 1

function toggle_send_mute()
    local tr_count = reaper.CountSelectedTracks(0)
    if tr_count == 0 then
        return
    end
    reaper.Undo_BeginBlock()
    for i=1, tr_count do
        local tr = reaper.GetSelectedTrack(0, i-1)
        if tr ~= nil then
            -- count hardware outs (this is needed to get the correct send index)
            local tr_num_hw_outs = reaper.GetTrackNumSends(tr, 1)
            reaper.ToggleTrackSendUIMute(tr, tr_num_hw_outs + send_target)
        end
    end
    local undo_string = "Toggle send mute "..tostring(send_target+1)
    reaper.Undo_EndBlock(undo_string, -1)
end

reaper.defer(toggle_send_mute)
Found this here https://forum.cockos.com/showthread.php?t=174049
It will mute and unmute send 1, which is very close.
How do I make it toggle mute on a hw output?

EDIT
REAPER API says this below - what do I need to change?
Code:
boolean reaper.ToggleTrackSendUIMute(MediaTrack track, integer send_idx)

send_idx<0 for receives, >=0 for hw ouputs, >=nb_of_hw_ouputs for sends.
Also - is there a way to print value of var so I can view it?

EDIT2
This works, at least for 1 track, how to make it less convoluted and why does it work so I can edit it?
Code:
-- Lua script to toggle mute
-- TRACK SEND 1 on selected tracks

local send_target = -1 -- send 1, as send counts start at 0 in Reaper 
-- is this the hardware output if I set it to 1

function toggle_send_mute()
    local tr_count = reaper.CountSelectedTracks(0)
    if tr_count == 0 then
        return
    end
    reaper.Undo_BeginBlock()
    for i=1, tr_count do
        local tr = reaper.GetSelectedTrack(0, i-1)
        if tr ~= nil then
            -- count hardware outs (this is needed to get the correct send index)
            local tr_num_hw_outs = reaper.GetTrackNumSends(tr, 1)--1
            reaper.ToggleTrackSendUIMute(tr, tr_num_hw_outs + send_target)
        end
    end
    local undo_string = "Toggle send mute "..tostring(send_target+1)
    reaper.Undo_EndBlock(undo_string, -1)
end

reaper.defer(toggle_send_mute)

--
All I changed was the send_target var.


EDIT3
If I have 2 hw outs and I set the send_target =-2 it toggles the mute of hw out 2.
With 2 hw outs and send_target = -1 it mutes hw out 1.

What is going on?

EDIT4
Code:
reaper.ToggleTrackSendUIMute(tr, tr_num_hw_outs + send_target)
The value passed for 2 hw outputs and send_target = -1 would be 1 wouldn't it?
Yes it would and I just confirmed, if I set send_target = -3 with 2 hw outs, I get a receive mute. Wow!
I think I got it.

How to do some math?
I would like to make sure that I am always working with hw_outs.
So I need a calculation that makes sure it will be hw output 1
EDIT5
Code:
-- Lua script TOGGLE MUTE HARDWARE output 1 on selected tracks

--[[
The number of hw outs makes all the difference
*send_idx<0 for receives, >=0 for hw ouputs, >=nb_of_hw_ouputs for sends.
If hw outs are 1 and send_target = -1 the result is zero

--]]
local send_target = 0 -- just to set a value for the var, send counts start at 0 in Reaper 

function toggle_send_mute()
    local tr_count = reaper.CountSelectedTracks(0)
    if tr_count == 0 then
        return
    end
    reaper.Undo_BeginBlock()
    for i=1, tr_count do
        local tr = reaper.GetSelectedTrack(0, i-1)
        if tr ~= nil then
            -- count hardware outs (this is needed to get the correct send index)
            local tr_num_hw_outs = reaper.GetTrackNumSends(tr, 1)
            -- set send_target equal to numbers of hw outs
            local send_target = tr_num_hw_outs
            -- subtract the above vars to always get 0, which is the first hw output
            reaper.ToggleTrackSendUIMute(tr, tr_num_hw_outs - send_target)-- if >=0,then hw_out
        end
    end
    local undo_string = "Toggle send mute "..tostring(send_target+1)
    reaper.Undo_EndBlock(undo_string, -1)
end

reaper.defer(toggle_send_mute)
Now to look at toggling master parent send on when hw_out 1 is muted.
Perhaps tomorrow.

EDIT6
Script does not differentiate - if no hw input, it will mute first send.
If track A has a hw out and B does not, it will mute the first send on B.
Not ideal, at all...
I might need some advanced logic to solve that.
__________________
KeyMce/GenMce - pc keyboard/midi to Mackie control emulation (built with ahk). Also - an ahk script to build your own midi programs.

Last edited by flipotto; 06-09-2021 at 08:28 PM. Reason: problem solving
flipotto is offline   Reply With Quote
Old 06-10-2021, 08:08 AM   #2562
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 10,561
Default

Do you want to toggle all hardware outs for selected tracks or only the first one?
This should (hopefully) work for all:

Code:
-- Toggle mute hardware outputs for selected tracks
function main()
  for i = 0, reaper.CountSelectedTracks(0)-1  do
    local tr =  reaper.GetSelectedTrack(0, i)
    local numHWouts = reaper.GetTrackNumSends(tr, 1)
    for j = 0, numHWouts-1 do
      -- exclusive OR current state with 1 -> toggle
      reaper.SetTrackSendInfo_Value(tr, 1, j, "B_MUTE", reaper.GetTrackSendInfo_Value(tr, 1, j, "B_MUTE")~1)
    end -- loop through HW outs 
  end -- loop through selected tracks
end -- main()

main()
-- https://forum.cockos.com/showpost.php?p=2090533&postcount=27
reaper.Undo_OnStateChangeEx("Toggle mute hardware outputs for selected tracks", 1, -1)
For toggling master/parent send you can use
SetMediaTrackInfo_Value with B_MAINSEND.

Last edited by nofish; 06-10-2021 at 08:23 AM.
nofish is offline   Reply With Quote
Old 06-10-2021, 12:00 PM   #2563
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Posts: 596
Default

Quote:
Originally Posted by nofish View Post
Do you want to toggle all hardware outs for selected tracks or only the first one?
This should (hopefully) work for all:

Code:
-- Toggle mute hardware outputs for selected tracks
function main()
  for i = 0, reaper.CountSelectedTracks(0)-1  do
    local tr =  reaper.GetSelectedTrack(0, i)
    local numHWouts = reaper.GetTrackNumSends(tr, 1)
    for j = 0, numHWouts-1 do
      -- exclusive OR current state with 1 -> toggle
      reaper.SetTrackSendInfo_Value(tr, 1, j, "B_MUTE", reaper.GetTrackSendInfo_Value(tr, 1, j, "B_MUTE")~1)
    end -- loop through HW outs 
  end -- loop through selected tracks
end -- main()

main()
-- https://forum.cockos.com/showpost.php?p=2090533&postcount=27
reaper.Undo_OnStateChangeEx("Toggle mute hardware outputs for selected tracks", 1, -1)
For toggling master/parent send you can use
SetMediaTrackInfo_Value with B_MAINSEND.

Your code is much cleaner, thanks!
I did add first selecting tracks that have hardware outputs, then toggle mute, I guess I need unselect also...

Only mute the first HW output.
I'll need to toggle the mp send on when hw out 1 IS muted and off when the hw is NOT muted to get all the way finished.
I will study your code and try to figure out what is going on...

I ended up here (see below)
Code:
--[[
 * ReaScript Name: Toggle Mute Hardware Output 1 for Selected Tracks
 * Author: Flipotto
 * Licence: GPL v3
 * REAPER: 5.0 - unsure of version
 * Version: .92
--]]

-- Modified from https://forum.cockos.com/showpost.php?p=1651864&postcount=4 
-- by airon

-- copied directly me2beats "select all tracks with hardware output"

--[[
The number of hw outs makes all the difference
This version will select tracks with hw outs, only, then 
automatically mute hw out 1

reaper.ToggleTrackSendUIMute parameter conditions
*send_idx<0 for receives, >=0 for hw ouputs, >=nb_of_hw_ouputs for sends.
If hw outs are 1 and send_target = -1 the result is zero

--]]

--------Select Track with HW outs---------
function Seltracks_withHWouts()
end

reaper.Main_OnCommand(40297, 0) -- unselect all tracks
t_cnt = reaper.CountTracks(0)
if t_cnt > 0 then
  
  script_title = "select all sends"
  reaper.Undo_BeginBlock()
  
  for t = 0, t_cnt-1 do
    tr = reaper.GetTrack(0,t)
    if reaper.GetTrackNumSends(tr, 1) > 0 then
      reaper.SetMediaTrackInfo_Value(tr, 'I_SELECTED', 1)
    end
  end
  
  reaper.Undo_EndBlock(script_title, -1)
else
  reaper.defer(Seltracks_withHWouts)
end
-----------

local send_target = 0 -- just to set a value for the var, send counts start at 0 in Reaper 

--------- toggle mute on first HW output ----------
function toggle_send_mute()
    local tr_count = reaper.CountSelectedTracks(0)
    if tr_count == 0 then
        return
    end
    reaper.Undo_BeginBlock()
    for i=1, tr_count do
        local tr = reaper.GetSelectedTrack(0, i-1)
        if tr ~= nil then
            -- count hardware outs (this is needed to get the correct send index)
            local tr_num_hw_outs = reaper.GetTrackNumSends(tr, 1)
            -- if tr_num_hw_outs == nil or tr_num_hw_outs == 0 then end
            -- set send_target equal to numbers of hw outs
            local send_target = tr_num_hw_outs
            -- subtract the above vars to always get 0, which is the first hw output
           
            reaper.ToggleTrackSendUIMute(tr, tr_num_hw_outs - send_target)-- if >=0,then hw_out
        end
    end
    local undo_string = "Toggle send mute "..tostring(send_target+1)
    reaper.Undo_EndBlock(undo_string, -1)
end
--------------

reaper.defer(toggle_send_mute)
how do I run an sws action?
toggle master/parent send on selected tracks
id = _SWS_TOGMPSEND
__________________
KeyMce/GenMce - pc keyboard/midi to Mackie control emulation (built with ahk). Also - an ahk script to build your own midi programs.

Last edited by flipotto; 06-10-2021 at 12:22 PM.
flipotto is offline   Reply With Quote
Old 06-10-2021, 12:37 PM   #2564
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 10,561
Default

Quote:
Originally Posted by flipotto View Post
how do I run an sws action?
toggle master/parent send on selected tracks
id = _SWS_TOGMPSEND
Code:
id = reaper.NamedCommandLookup("_SWS_TOGMPSEND")
reaper.Main_OnCommand(id, 0)
or in one line:
Code:
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_TOGMPSEND"), 0)
edit:
modification of previous script, would this do what you want?
Code:
-- Toggle mute first hardware out and master/parent send for selected tracks
function main()
  for i = 0, reaper.CountSelectedTracks(0)-1  do
    local tr =  reaper.GetSelectedTrack(0, i)
    if reaper.GetTrackNumSends(tr, 1) > 0 then
      local HWout1_muteState = reaper.GetTrackSendInfo_Value(tr, 1, 0, "B_MUTE")
      -- toggle mute first HW out
      -- exclusive OR current state with 1 -> toggle
      reaper.SetTrackSendInfo_Value(tr, 1, 0, "B_MUTE", HWout1_muteState~1)
      -- set master/parent send on if first HW out is muted (off) and vice versa
      reaper.SetMediaTrackInfo_Value(tr, "B_MAINSEND", HWout1_muteState~1) 
    end
  end -- loop through selected tracks
end -- main()

main()
-- https://forum.cockos.com/showpost.php?p=2090533&postcount=27
reaper.Undo_OnStateChangeEx("Toggle mute first hardware out and master/parent send for sel. tracks", 1, -1)

Last edited by nofish; 06-10-2021 at 01:29 PM.
nofish is offline   Reply With Quote
Old 06-11-2021, 01:16 AM   #2565
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Posts: 596
Default

Quote:
Originally Posted by nofish View Post
[code]
or in one line:
Code:
reaper.Main_OnCommand(reaper.NamedCommandLookup("_SWS_TOGMPSEND"), 0)
Thanks, that did the trick! But no longer needed/used!

Yes your script does what I was after, however it does not select the tracks with hw outs automatically, which was a new need.
Yours does not have the problem I had of accidently toggling sends that are not hw outs, which is why I did the autoselect tracks with hw out.
Yours also does not flash the selection, which is annoying.
I need to study yours... it's very sleek!
Quote:
Originally Posted by nofish View Post
edit:
modification of previous script, would this do what you want?
Code:
-- Toggle mute first hardware out and master/parent send for selected tracks
function main()
  for i = 0, reaper.CountSelectedTracks(0)-1  do
    local tr =  reaper.GetSelectedTrack(0, i)
    if reaper.GetTrackNumSends(tr, 1) > 0 then
      local HWout1_muteState = reaper.GetTrackSendInfo_Value(tr, 1, 0, "B_MUTE")
      -- toggle mute first HW out
      -- exclusive OR current state with 1 -> toggle
      reaper.SetTrackSendInfo_Value(tr, 1, 0, "B_MUTE", HWout1_muteState~1)
      -- set master/parent send on if first HW out is muted (off) and vice versa
      reaper.SetMediaTrackInfo_Value(tr, "B_MAINSEND", HWout1_muteState~1) 
    end
  end -- loop through selected tracks
end -- main()

main()
-- https://forum.cockos.com/showpost.php?p=2090533&postcount=27
reaper.Undo_OnStateChangeEx("Toggle mute first hardware out and master/parent send for sel. tracks", 1, -1)
EDIT
Combining Nofish code above and me2beats "select all tracks with hw output".
Code:
--[[
 * ReaScript Name: Select Tracks with HW Outs toggle mute hw out 1 inversely toggle master parent send
 * Author: Flipotto - just combining other ppls work!
 * Licence: GPL v3
 * REAPER: 6.29 - unsure of older version compatibility
 * Version: .96

Why this script - X32 mixer to toggle between:
-virtual sound check mode(audio from each reaper track to x32 mixer channels for virt sound check)and 
-Reaper mix in the box - with only master out to x32

When script runs it should
- Automatically - Select Tracks with HW outputs
- Mute Hw output 1 for the selected tracks
- Toggle on Master parent send for selected tracks
- Unselect selected tracks

TODO - 
Send osc message to X32 to toggle between record and play routing mode not sure this is possible...

-- Nofish code - Thanks much! much better without flashing the selection!
-- copied directly me2beats "select all tracks with hardware output"
--]]
-- Toggle mute first hardware out and master/parent send for selected tracks
function main()
  
  -- copied directly me2beats "select all tracks with hardware output"
  reaper.Main_OnCommand(40297, 0) -- unselect all tracks
  t_cnt = reaper.CountTracks(0)
  if t_cnt > 0 then
    
    script_title = "select all sends"
    reaper.Undo_BeginBlock()
    
    for t = 0, t_cnt-1 do
      tr = reaper.GetTrack(0,t)
      if reaper.GetTrackNumSends(tr, 1) > 0 then
        reaper.SetMediaTrackInfo_Value(tr, 'I_SELECTED', 1)
      end
    end
    
    reaper.Undo_EndBlock(script_title, -1)
  else
    reaper.defer(nothing)
  end -- end select tracks with hw outs
   
  -- Nofish code to toggle hw outs
  for i = 0, reaper.CountSelectedTracks(0)-1  do
    local tr =  reaper.GetSelectedTrack(0, i)
    if reaper.GetTrackNumSends(tr, 1) > 0 then
      local HWout1_muteState = reaper.GetTrackSendInfo_Value(tr, 1, 0, "B_MUTE")
      -- toggle mute first HW out
      -- exclusive OR current state with 1 -> toggle
      reaper.SetTrackSendInfo_Value(tr, 1, 0, "B_MUTE", HWout1_muteState~1)
      -- set master/parent send on if first HW out is muted (off) and vice versa
      reaper.SetMediaTrackInfo_Value(tr, "B_MAINSEND", HWout1_muteState~1) 
    end
  end -- loop through selected tracks
  reaper.Main_OnCommand(40297, 0) -- unselect all tracks 
end -- main()

main()
-- https://forum.cockos.com/showpost.php?p=2090533&postcount=27
reaper.Undo_OnStateChangeEx("Toggle mute first hardware out and master/parent send for sel. tracks", 1, -1)
__________________
KeyMce/GenMce - pc keyboard/midi to Mackie control emulation (built with ahk). Also - an ahk script to build your own midi programs.

Last edited by flipotto; 06-11-2021 at 04:38 AM.
flipotto is offline   Reply With Quote
Old 06-11-2021, 01:06 PM   #2566
flipotto
Human being with feelings
 
flipotto's Avatar
 
Join Date: Feb 2007
Posts: 596
Default Script send osc message to x32 mixer?

Is there a way to send an osc message from a script to a hardware mixer?
__________________
KeyMce/GenMce - pc keyboard/midi to Mackie control emulation (built with ahk). Also - an ahk script to build your own midi programs.
flipotto is offline   Reply With Quote
Old 06-11-2021, 07:57 PM   #2567
lowellben
Human being with feelings
 
lowellben's Avatar
 
Join Date: Aug 2010
Location: They put me in a home.
Posts: 3,385
Default

A Windows app would indeed work I am so grateful for your sharing this. I will test it and get back to you. Can I just copy this into a script or no?

Quote:
Originally Posted by Edgemeal View Post
Would a Windows app work? I've made a few apps that parse REAPER project info. You simply drag and drop project files/folders onto app, exe, or run the included ReaScript (after minor edit) for current project.

Example of text output,
Code:
Project: Gip Seas
-----------------
Master Track:
JS: "TBProAudio/EBUR128LMJSFX/Ed's Tiny_ebu_r128": Eds Mod

Track #1: Pre-Master
VST3: CA-2A (Cakewalk): I Like Cake!
JS: schwa/soft_clipper: This is a comment.

Track #2: Drums
VSTi: MT-PowerDrumKit (MANDA AUDIO) (16 out): Mixer volumes tweaked
VST: Sanford Reverb (Sanford Sound Design): Drum room 

etc, etc,..
Run exe from script,
Code:
-- Create project track FX comments text file
-- v1.01 - Edgemeal - June 07, 2021
-- Donate: https://www.paypal.me/Edgemeal

-- *** USER SETTING ***
local exe_path = [[M:\Track FX Comments.exe]] -- full path to Exe. 
-- ********************

local _, projfn = reaper.EnumProjects(-1, "")
if projfn ~= "" then
  projfn = ' "' .. projfn .. '"' -- prep proj path for exe command-line usage
  if reaper.file_exists(exe_path) then
    --reaper.ExecProcess(exe_path .. projfn, -1) -- Add project to app, let user run & close.
    reaper.ExecProcess(exe_path .. projfn .. ' "*"', -1) -- ' "*"' = Auto create text file and close exe.
  else
    reaper.MB("The file 'Track FX Comments.exe' was not found!", "ERROR", 0)
  end
else
  reaper.MB("Please load a project!", "No Project", 0)
end

reaper.defer(function () end)
__________________
47.8% of statistics are made up.
lowellben is offline   Reply With Quote
Old 06-11-2021, 08:19 PM   #2568
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 2,424
Default

Quote:
Originally Posted by lowellben View Post
A Windows app would indeed work I am so grateful for your sharing this. I will test it and get back to you. Can I just copy this into a script or no?
See readme in zip.
Attached Files
File Type: zip Track FX Comments v0.07.zip (26.3 KB, 4 views)
Edgemeal is offline   Reply With Quote
Old 06-12-2021, 06:43 AM   #2569
DanSwizer
Human being with feelings
 
DanSwizer's Avatar
 
Join Date: Sep 2019
Posts: 40
Default Script to enable this checkbox

Dear friends can you please help me to enable this check boxes by script?
DanSwizer is offline   Reply With Quote
Old Yesterday, 04:23 AM   #2570
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 2,424
Default

Quote:
Originally Posted by DanSwizer View Post
Dear friends can you please help me to enable this check boxes by script?
See post by nofish,
https://forum.cockos.com/showpost.ph...52&postcount=2

For "Snap cursor to edges of media items on any track", CURSOR is documented (8192), but I didn't see anything for SELECTION.

To enable cursor part try,
Code:
  reaper.SNM_SetIntConfigVar("projshowgrid", reaper.SNM_GetIntConfigVar("projshowgrid", -666)|8192)
Edgemeal is offline   Reply With Quote
Old Yesterday, 04:26 AM   #2571
DanSwizer
Human being with feelings
 
DanSwizer's Avatar
 
Join Date: Sep 2019
Posts: 40
Default

Quote:
Originally Posted by Edgemeal View Post
See post by nofish,
https://forum.cockos.com/showpost.ph...52&postcount=2

For "Snap cursor to edges of media items on any track", CURSOR is documented (8192), but I didn't see anything for SELECTION.

To enable cursor part try,
Code:
  reaper.SNM_SetIntConfigVar("projshowgrid", reaper.SNM_GetIntConfigVar("projshowgrid", -666)|8192)
Thank you a lot Man!
DanSwizer is offline   Reply With Quote
Old Yesterday, 09:15 AM   #2572
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 10,561
Default

For selection it's the 19th bit (2^18), so
Code:
 reaper.SNM_SetIntConfigVar("projshowgrid", reaper.SNM_GetIntConfigVar("projshowgrid", -666)|262144)
(used Meo-Ada Mespotine's Display-Altered-Config-Vars script, thanks)
nofish 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 07:22 AM.


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