add cmdletbinding to examples for debug, verbose flags

add verbose,debug flags to launch scripts
This commit is contained in:
onyx-and-iris 2023-08-16 16:38:00 +01:00
parent 9b3d9f2250
commit bc6162cf16
4 changed files with 26 additions and 20 deletions

14
.vscode/launch.json vendored
View File

@ -16,7 +16,9 @@
"\"!strip[0].mute\",",
"\"strip[0].mute\",",
"\"bus[2].eq.on=1\",",
"\"command.lock=1\""
"\"command.lock=1\"",
"-Verbose",
"-Debug"
],
"createTemporaryIntegratedConsole": true
},
@ -26,7 +28,10 @@
"request": "launch",
"cwd": "${workspaceRoot}/examples/nextbus",
"script": "${workspaceFolder}/examples/nextbus/GoTo-NextBus.ps1",
"args": [],
"args": [
"-Verbose",
"-Debug"
],
"createTemporaryIntegratedConsole": true
},
{
@ -35,7 +40,10 @@
"request": "launch",
"cwd": "${workspaceRoot}/examples/obs",
"script": "${workspaceFolder}/examples/obs/Vm-Obs-Sync.ps1",
"args": [],
"args": [
"-Verbose",
"-Debug"
],
"createTemporaryIntegratedConsole": true
},
{

View File

@ -1,14 +1,12 @@
[cmdletbinding()]
param(
[switch]$interactive,
[switch]$output,
[String]$kind = "banana",
[String[]]$script = @()
)
Import-Module ..\..\lib\Voicemeeter.psm1
$VerbosePreference = "Continue"
function get-value {
param([object]$vmr, [string]$line)
try {
@ -24,16 +22,16 @@ function msgHandler {
param([object]$vmr, [string]$line)
$line + " passed to handler" | Write-Debug
if ($line[0] -eq "!") {
if ($output) { "Toggling " + $line.substring(1) | Write-Host }
"Toggling " + $line.substring(1) | Write-Debug
$retval = get-value -vmr $vmr -line $line.substring(1)
$vmr.Setter($line.substring(1), 1 - $retval)
}
elseif ($line.Contains("=")) {
if ($output) { "Setting $line" | Write-Host }
"Setting $line" | Write-Debug
$vmr.SendText($line)
}
else {
if ($output) { "Getting $line" | Write-Host }
"Getting $line" | Write-Debug
$retval = get-value -vmr $vmr -line $line
$line + " = " + $retval | Write-Host
}

View File

@ -7,27 +7,30 @@
Credits go to @bobsupercow
#>
Import-Module ..\..\lib\Voicemeeter.psm1
[cmdletbinding()]
param()
$VerbosePreference = "Continue"
Import-Module ..\..\lib\Voicemeeter.psm1
try {
$vmr = Connect-Voicemeeter -Kind "potato"
$buses = @($vmr.bus[1], $vmr.bus[2], $vmr.bus[4], $vmr.bus[6])
"Buses in selection: $($buses)"
$unmutedIndex = $null
# 1)
"Cycling through bus selection to check for first unmuted Bus..." | Write-Host
foreach ($bus in $buses) {
# 2)
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)
$bus.mute = $true
# 3)
if ($buses[++$unmutedIndex]) {
"unmuting bus $($buses[$unmutedIndex].index)" | Write-Host
"Unmuting Bus $($buses[$unmutedIndex].index)" | Write-Host
$buses[$unmutedIndex].mute = $false
break
}
@ -37,7 +40,7 @@ try {
# 4)
if ($null -eq $unmutedIndex) {
$buses[0].mute = $false
"unmuting bus $($buses[0].index)" | Write-Host
"Unmuting Bus $($buses[0].index)" | Write-Host
}
}

View File

@ -1,8 +1,9 @@
[cmdletbinding()]
param()
Import-Module ..\..\lib\Voicemeeter.psm1
Import-Module obs-powershell
$VerbosePreference = "Continue"
function CurrentProgramSceneChanged {
param([System.Object]$data)
Write-Host "Switched to scene", $data.sceneName
@ -10,19 +11,15 @@ function CurrentProgramSceneChanged {
switch ($data.sceneName) {
"START" {
$vmr.strip[0].mute = !$vmr.strip[0].mute
"Toggling Strip 0 mute"
}
"BRB" {
$vmr.strip[0].gain = -8.3
"Setting Strip 0 gain to -8.3"
}
"END" {
$vmr.strip[0].mono = $true
"Setting Strip 0 mono to `$true"
}
"LIVE" {
$vmr.strip[0].color_x = 0.3
"Setting Strip 0 color_x to 0.3"
}
default { "Expected START, BRB, END or LIVE scene" | Write-Warning; return }
}