trueCueCommandId = "_RS6eec5613bb183592c1b3ba37593ca60d07a088c6" trueCueCommandAction = tostring(reaper.NamedCommandLookup(trueCueCommandId))..",0" local function checkSoloChange (previousSoloedTracks) -- Define the names of our two important tracks local cueTrackName = "CUE TRACK" local masterTrackName = "MASTER TRACK" --Constants to make code more readable local SOLOED = 1 local NOT_SOLOED = 0 function tableLength(T) local count = 0 for _ in pairs(T) do count = count + 1 end return count end local function compare(array1, array2) if tableLength(array1) ~= tableLength(array2) then return false end for i,v in pairs(array1) do if v ~= array2[i] then return false end end return true end -- This function returns a track when passed a track name. Linear search. -- Returns nil if no track is found local function getTrackByName(inputName) local numTracks = reaper.CountTracks(0) for i = 0, numTracks - 1 do track = reaper.GetTrack(0, i) ret, trackName = reaper.GetTrackName(track) if trackName == inputName then return track end end return nil end -- This function returns an array of tracks that are solo'd -- This function DISCLUDES AND DISABLES solo'ing of "master", master, and cue tracks local function getSoloedTracks(cueTrack, masterTrack) local soloedTracks = {} -- Unsolo the true master track. local trueMasterTrack = reaper.GetMasterTrack() if reaper.GetMediaTrackInfo_Value(trueMasterTrack, "I_SOLO") == SOLOED then reaper.PreventUIRefresh(1) reaper.SetMediaTrackInfo_Value(trueMasterTrack, "I_SOLO", 0) reaper.PreventUIRefresh(-1) end local numTracks = reaper.CountTracks(0) for i = 0, numTracks - 1 do local track = reaper.GetTrack(0, i) local trackSoloValue = reaper.GetMediaTrackInfo_Value(track, "I_SOLO") -- Check if this track is soloed. If this is our "master" track or cue track, disable it. -- If it is just a regular track, add it to our list of soloed tracks if track == cueTrack or track == masterTrack then if trackSoloValue == SOLOED then reaper.PreventUIRefresh(1) reaper.SetMediaTrackInfo_Value(track, "I_SOLO", NOT_SOLOED) reaper.PreventUIRefresh(-1) trackSoloValue = NOT_SOLOED end end soloedTracks[i+1] = trackSoloValue end return soloedTracks end currentSoloedTracks = getSoloedTracks(getTrackByName(cueTrackName), getTrackByName(masterTrackName)) is_change = not(compare(previousSoloedTracks, currentSoloedTracks)) --previousSoloedTracks = currentSoloedTracks for k in pairs(previousSoloedTracks) do previousSoloedTracks[k] = nil end for i,v in ipairs(currentSoloedTracks) do previousSoloedTracks[i] = v end return is_change end -- local function main() -- test = {0, 0, 0, 0, 0, 0, 0, 0} -- reaper.ShowConsoleMsg(test[7].."\n") -- returnval = checkSoloChange(test) -- reaper.ShowConsoleMsg(test[7].."\n") -- -- end -- main() -- Import the ultraschall library dofile(reaper.GetResourcePath().."/UserPlugins/ultraschall_api.lua") ultraschall.EventManager_Stop() ultraschall.EventManager_Start() EventIdentifier = ultraschall.EventManager_AddEvent( "Run true_cue if solo changes", 0, 0, false, false, checkSoloChange, {trueCueCommandAction} )