Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Exclusive solo, mute, rec-arm via middle mouse click on track buttons (background) v1.0 #1488

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
-- @description Exclusive solo, mute, rec-arm via middle mouse click on track buttons (background)
-- @author daodan
-- @version 1.0
-- @link Forum thread https://forum.cockos.com/showthread.php?t=297698
-- @about
-- # Exclusive solo, mute, rec-arm via middle mouse click on track buttons (background)
--
-- While script running you can middle mouse click on solo, mute, rec-arm track buttons to perform exclusive solo, mute, rec-arm on this track.\
-- Replicates default behaviour of ctrl+alt+left click on solo, mute buttons and alt+left click on rec-arm button.

function Checks()
if reaper.APIExists("JS_ReaScriptAPI_Version") == false then
reaper.ShowMessageBox("Please, install js_ReaScriptAPI extension","Checks failed",0)
return
end
return 1
end

function SetButtonState(set)
local is_new_value, filename, sec, cmd, mode, resolution, val = reaper.get_action_context()
reaper.SetToggleCommandState(sec, cmd, set or 0)
reaper.RefreshToolbar2(sec, cmd)
end

local mousePressed = 0
local function main()
local mouse = reaper.JS_Mouse_GetState(-1)
local modifMouse = 64 --64 for middle mouse, +8 for shift, +32: Windows (Windows), +16 Alt... See gfx VARIABLES > gfx.mouse_cap
if mouse & modifMouse == modifMouse then --check for middle click
local x, y = reaper.GetMousePosition()
local track, info = reaper.GetThingFromPoint(x, y)
if mousePressed==0 then
mousePressed = 1
--solo--
if info == 'tcp.solo' or info == 'mcp.solo' then
reaper.PreventUIRefresh(1)
reaper.Main_OnCommand(40340,0) -- unsolo all tracks
if reaper.IsTrackSelected(track) == true then
selTracksCount = reaper.CountSelectedTracks( 0 )
for seltrackidx=0, selTracksCount-1 do
track = reaper.GetSelectedTrack( 0, seltrackidx )
reaper.SetMediaTrackInfo_Value(track, 'I_SOLO', 2)
end
else
reaper.SetMediaTrackInfo_Value(track, 'I_SOLO', 2)
end
reaper.PreventUIRefresh(-1)
--mute--
elseif info == 'tcp.mute' or info == 'mcp.mute' then
reaper.PreventUIRefresh(1)
reaper.Main_OnCommand(40339,0) -- unmute all tracks
if reaper.IsTrackSelected(track) == true then
selTracksCount = reaper.CountSelectedTracks( 0 )
for seltrackidx=0, selTracksCount-1 do
track = reaper.GetSelectedTrack( 0, seltrackidx )
reaper.SetMediaTrackInfo_Value(track, 'B_MUTE', 1)
end
else
reaper.SetMediaTrackInfo_Value(track, 'B_MUTE', 1)
end
reaper.PreventUIRefresh(-1)
--recarm--
elseif info == 'tcp.recarm' or info == 'mcp.recarm' then
reaper.PreventUIRefresh(1)
reaper.Main_OnCommand(40491,0) -- unarm all tracks for recording
if reaper.IsTrackSelected(track) == true then
selTracksCount = reaper.CountSelectedTracks( 0 )
for seltrackidx=0, selTracksCount-1 do
track = reaper.GetSelectedTrack( 0, seltrackidx )
reaper.SetMediaTrackInfo_Value(track, 'I_RECARM', 1)
end
else
reaper.SetMediaTrackInfo_Value(track, 'I_RECARM', 1)
end
reaper.PreventUIRefresh(-1)
end
end
else
mousePressed = 0
end
reaper.defer(main)
end
if not Checks() then return end
SetButtonState(1)
main()
reaper.atexit(SetButtonState)
Loading