2022-10-27 21:21:10 +01:00
|
|
|
<#
|
|
|
|
1) Loop through an array of bus objects.
|
|
|
|
2) Mute first unmuted bus
|
|
|
|
3) If next bus in array exists, unmute it, otherwise clear unmuted variable.
|
|
|
|
4) If every bus in array is muted, unmute the first bus specified in array.
|
|
|
|
|
|
|
|
Credits go to @bobsupercow
|
|
|
|
#>
|
|
|
|
|
2022-12-16 17:16:02 +00:00
|
|
|
Import-Module ..\..\lib\Voicemeeter.psm1
|
2022-10-27 21:21:10 +01:00
|
|
|
|
2022-12-17 02:11:00 +00:00
|
|
|
$VerbosePreference = "Continue"
|
|
|
|
|
2022-10-27 21:21:10 +01:00
|
|
|
try {
|
2022-12-17 15:41:02 +00:00
|
|
|
$vmr = Connect-Voicemeeter -Kind "potato"
|
2022-10-27 21:21:10 +01:00
|
|
|
|
|
|
|
$buses = @($vmr.bus[1], $vmr.bus[2], $vmr.bus[4], $vmr.bus[6])
|
|
|
|
$unmutedIndex = $null
|
|
|
|
|
|
|
|
# 1)
|
2022-12-17 15:41:02 +00:00
|
|
|
foreach ($bus in $buses) {
|
2022-10-27 21:21:10 +01:00
|
|
|
# 2)
|
|
|
|
if (-not $bus.mute) {
|
2022-12-17 15:41:02 +00:00
|
|
|
"bus $($bus.index) is unmuted... muting it" | Write-Host
|
2022-10-27 21:21:10 +01:00
|
|
|
$unmutedIndex = $buses.IndexOf($bus)
|
|
|
|
$bus.mute = $true
|
|
|
|
|
|
|
|
# 3)
|
2022-12-17 15:41:02 +00:00
|
|
|
if ($buses[++$unmutedIndex]) {
|
|
|
|
"unmuting bus $($buses[$unmutedIndex].index)" | Write-Host
|
2022-10-27 21:21:10 +01:00
|
|
|
$buses[$unmutedIndex].mute = $false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
else { Clear-Variable unmutedIndex }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
# 4)
|
2022-12-17 15:41:02 +00:00
|
|
|
if ($null -eq $unmutedIndex) {
|
|
|
|
$buses[0].mute = $false
|
|
|
|
"unmuting bus $($buses[0].index)" | Write-Host
|
|
|
|
}
|
|
|
|
|
2022-10-27 21:21:10 +01:00
|
|
|
}
|
2022-12-17 15:41:02 +00:00
|
|
|
finally { Disconnect-Voicemeeter }
|