minor rework

This commit is contained in:
onyx-and-iris 2022-12-17 15:41:02 +00:00
parent 6468270fd0
commit cd7508b823

View File

@ -12,23 +12,22 @@ Import-Module ..\..\lib\Voicemeeter.psm1
$VerbosePreference = "Continue" $VerbosePreference = "Continue"
try { try {
$vmr = Get-RemotePotato $vmr = Connect-Voicemeeter -Kind "potato"
$buses = @($vmr.bus[1], $vmr.bus[2], $vmr.bus[4], $vmr.bus[6]) $buses = @($vmr.bus[1], $vmr.bus[2], $vmr.bus[4], $vmr.bus[6])
$unmutedIndex = $null $unmutedIndex = $null
# 1) # 1)
$buses | ForEach-Object { foreach ($bus in $buses) {
$bus = $_
# 2) # 2)
if (-not $bus.mute) { if (-not $bus.mute) {
"bus " + $bus.index + " is unmuted... muting it" | Write-Host "bus $($bus.index) is unmuted... muting it" | Write-Host
$unmutedIndex = $buses.IndexOf($bus) $unmutedIndex = $buses.IndexOf($bus)
$bus.mute = $true $bus.mute = $true
# 3) # 3)
if ($buses[++$unmutedIndex]) { if ($buses[++$unmutedIndex]) {
"unmuting bus " + $buses[$unmutedIndex].index | Write-Host "unmuting bus $($buses[$unmutedIndex].index)" | Write-Host
$buses[$unmutedIndex].mute = $false $buses[$unmutedIndex].mute = $false
break break
} }
@ -36,7 +35,10 @@ try {
} }
} }
# 4) # 4)
if ($null -eq $unmutedIndex) { $buses[0].mute = $false } if ($null -eq $unmutedIndex) {
"unmuting bus " + $buses[0].index | Write-Host $buses[0].mute = $false
"unmuting bus $($buses[0].index)" | Write-Host
} }
finally { $vmr.Logout() }
}
finally { Disconnect-Voicemeeter }