// Toggle mute all

// First analyse the number of muted tracks

for track 1 $nbTracks
	getTrackVolume volume $track
	if $volume < 0.05
		variable nbMutedTrack $nbMutedTrack + 1
		variable mutedTrackList $mutedTrackList & $track & ;
	else
		variable unmutedTrackList $unmutedTrackList & $track & ;		
	endIf
endFor

//print nbMutedTrack : $nbMutedTrack
//print mutedTrackList : $mutedTrackList
//print unmutedTrackList : $unmutedTrackList

if $nbMutedTrack/$nbTracks > 0.5
	// There is a majority of track that are muted, we unmute them
	forEach track $mutedTrackList
		shortcutByID 5095 + $track // Toggle Soft Mute for track
	endForEach
else
	// There is a majority of track that are unmuted, we mute them
	forEach track $unmutedTrackList
		shortcutByID 5095 + $track // Toggle Soft Mute for track
	endForEach
endIf

