mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 13:20:47 +00:00
Update goto_nextbus.ps1
reorganize comments. run boolean test on buses array to test for existence of value. set unmute explicitly if all buses are muted (for readability).
This commit is contained in:
parent
2775d64e47
commit
f50f5aa40c
@ -5,10 +5,11 @@
|
|||||||
Credits go to @bobsupercow
|
Credits go to @bobsupercow
|
||||||
#>
|
#>
|
||||||
|
|
||||||
# 1) Loop through an array of buses. Toggle mute for first unmuted bus
|
# 1) Loop through an array of buses.
|
||||||
# 2) If next bus in array exists, unmute it
|
# 2) Mute first unmuted bus
|
||||||
# 3) else unmute the first bus specified in array.
|
# 3) If next bus in array exists, unmute it
|
||||||
# 4) If every bus in array is muted, unmute the first bus specified in array.
|
# 4) else unmute the first bus specified in array.
|
||||||
|
# 5) If every bus in array is muted, unmute the first bus specified in array.
|
||||||
|
|
||||||
Import-Module Voicemeeter
|
Import-Module Voicemeeter
|
||||||
|
|
||||||
@ -19,24 +20,23 @@ try {
|
|||||||
$unmutedIndex = $null
|
$unmutedIndex = $null
|
||||||
[int32[]]$buses = @(1,2,4,6)
|
[int32[]]$buses = @(1,2,4,6)
|
||||||
|
|
||||||
|
# 1)
|
||||||
0..($buses.Length -1) | ForEach-Object {
|
0..($buses.Length -1) | ForEach-Object {
|
||||||
# 1)
|
# 2)
|
||||||
if (-not $vmr.bus[$buses[$_]].mute){
|
if ( -not $vmr.bus[$buses[$_]].mute ){
|
||||||
$unmutedIndex = $_
|
$unmutedIndex = $_
|
||||||
$vmr.bus[$buses[$unmutedIndex]].mute = $true
|
$vmr.bus[$buses[$unmutedIndex]].mute = $true
|
||||||
|
|
||||||
# 2)
|
# 3)
|
||||||
if ($unmutedIndex -lt ($buses.Length -1)){
|
if ( $buses[++$unmutedIndex] ){
|
||||||
$vmr.bus[$buses[++$unmutedIndex]].mute = $false
|
$vmr.bus[$buses[$unmutedIndex]].mute = $false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
# 3)
|
# 4)
|
||||||
else {
|
else { $vmr.bus[$buses[0]].mute = $false }
|
||||||
$vmr.bus[$buses[0]].mute = $false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# 4)
|
# 5)
|
||||||
if ($null -eq $unmutedIndex) { $vmr.bus[$buses[0]].mute = -not $vmr.bus[$buses[0]].mute }
|
if ( $null -eq $unmutedIndex ) { $vmr.bus[$buses[0]].mute = $false }
|
||||||
|
|
||||||
} finally { $vmr.Logout() }
|
} finally { $vmr.Logout() }
|
||||||
|
Loading…
Reference in New Issue
Block a user