local undo = "Set tracks symmetrically and add to unused group"
track_g = 0
stm_n = 1
counttracks = reaper.CountTracks(0)
count_selected_tracks = reaper.CountSelectedTracks(0)
if count_selected_tracks == 2 then
reaper.Undo_BeginBlock()
if reaper.GetToggleCommandState(40771) == 0 then
reaper.Main_OnCommand(40771, 0) -- Enable track grouping
end
for i = 1, counttracks do
local function error()
reaper.MB("One or both of selected tracks is already in group" , "Error", 0)
end
local track = reaper.GetTrack(0, i - 1)
local track_sel = reaper.IsTrackSelected(track)
stm = reaper.GetSetTrackGroupMembership(track, "VOLUME_MASTER", 0, 0)
if stm >= stm_n then
stm_n = stm*2
end
if track_sel == true and stm ~= 0 then
track_g = 2
error()
break
end
if track_sel == true and track_g == 0 then
reaper.SetMediaTrackInfo_Value(track, "D_PAN", -1)
reaper.GetSetTrackGroupMembership(track, "PAN_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "PAN_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "VOLUME_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "VOLUME_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "MUTE_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "MUTE_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "SOLO_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "SOLO_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "PAN_REVERSE", stm_n, stm_n )
track_g = 1
elseif track_sel == true and track_g == 1 then
reaper.SetMediaTrackInfo_Value(track, "D_PAN", 1)
reaper.GetSetTrackGroupMembership(track, "PAN_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "PAN_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "VOLUME_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "VOLUME_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "MUTE_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "MUTE_SLAVE", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "SOLO_MASTER", stm_n, stm_n )
reaper.GetSetTrackGroupMembership(track, "SOLO_SLAVE", stm_n, stm_n )
end
end
reaper.Undo_EndBlock(undo, -1)
end