mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-01-18 13:20:47 +00:00
add support for mb params in multi_set
Add support for mb params in multi_set. Updated changelog to document addition
This commit is contained in:
parent
63a56c7a72
commit
770b9cf663
@ -11,6 +11,7 @@ Before any minor/major patch is released all test units will be run to verify th
|
|||||||
- [x] Update tests to reflect changes
|
- [x] Update tests to reflect changes
|
||||||
- [x] Add logging + summary for tests
|
- [x] Add logging + summary for tests
|
||||||
- [x] Add info to README about powershellget, nuget and psgallery
|
- [x] Add info to README about powershellget, nuget and psgallery
|
||||||
|
- [x] Support other types of params in multi_set
|
||||||
|
|
||||||
## [1.3] - 2021-04-30
|
## [1.3] - 2021-04-30
|
||||||
### Added
|
### Added
|
||||||
|
16
example.ps1
16
example.ps1
@ -24,5 +24,21 @@ try {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$vmr.Set_Multi($hash)
|
$vmr.Set_Multi($hash)
|
||||||
|
|
||||||
|
$hash = @{
|
||||||
|
"mb_0.state" = $true
|
||||||
|
"mb_1.state" = $true
|
||||||
|
"mb_2.state" = $true
|
||||||
|
}
|
||||||
|
|
||||||
|
$vmr.Set_Multi($hash)
|
||||||
|
|
||||||
|
$hash = @{
|
||||||
|
"mb_0.state" = $false
|
||||||
|
"mb_1.state" = $false
|
||||||
|
"mb_2.state" = $false
|
||||||
|
}
|
||||||
|
|
||||||
|
$vmr.Set_Multi($hash)
|
||||||
}
|
}
|
||||||
finally { $vmr.Logout() }
|
finally { $vmr.Logout() }
|
40
lib/base.ps1
40
lib/base.ps1
@ -47,24 +47,50 @@ Function Param_Set_Multi {
|
|||||||
)
|
)
|
||||||
Start-Sleep -m 50
|
Start-Sleep -m 50
|
||||||
while(M_Dirty) { Start-Sleep -m 1 }
|
while(M_Dirty) { Start-Sleep -m 1 }
|
||||||
|
|
||||||
[string[]]$params = ($HASH | out-string -stream) -ne '' | Select-Object -Skip 2
|
[string[]]$params = ($HASH | out-string -stream) -ne '' | Select-Object -Skip 2
|
||||||
[String]$cmd = [String]::new(512)
|
$cmd_channel = [String]::new(512)
|
||||||
|
$cmd_mb = @(
|
||||||
|
,@()
|
||||||
|
)
|
||||||
ForEach ($line in $params) {
|
ForEach ($line in $params) {
|
||||||
if($line.Trim() -Match "(^\w+)\[(\d)\].(\w+)\s+(\w+)") {
|
if($line.Trim() -Match "(^\w+)\[(\d)\].(\w+)\s+(\w+)") {
|
||||||
if($Matches[4] -eq "True") { $val = [String]1 } else { $val = [String]0 }
|
if($Matches[4] -eq "True") { $val = 1 } else { $val = 0 }
|
||||||
$cmd += "$($Matches[1])[$($Matches[2])].$($Matches[3])=$val;"
|
[String]$cmd_channel += "$($Matches[1])[$($Matches[2])].$($Matches[3])=$val;"
|
||||||
}
|
}
|
||||||
}
|
elseif($line.Trim() -Match "mb_(\d+).(\w+)\s+(\w+)") {
|
||||||
[String]$cmd = $cmd.SubString(1)
|
$id = $Matches[1]
|
||||||
|
if($Matches[2] -eq "state") { $mode = 1 }
|
||||||
|
elseif($Matches[2] -eq "stateonly") { $mode = 2 }
|
||||||
|
elseif($Matches[2] -eq "trigger") { $mode = 3 }
|
||||||
|
if($Matches[3] -eq "True") { $val = 1 } else { $val = 0 }
|
||||||
|
|
||||||
|
$cmd_mb += , @($id, $val, $mode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HashTable]$cmds = @{}
|
||||||
|
if(![string]::IsNullOrEmpty($cmd_channel)) { $cmds["channel"] = $cmd_channel }
|
||||||
|
if($cmd_mb.count -gt 0) { $cmds["mb"] = $cmd_mb }
|
||||||
|
|
||||||
|
if($cmds.ContainsKey("channel")) {
|
||||||
|
$cmds["channel"] = $cmds["channel"] -replace '[^a-z0-9.\[\]=;]+'
|
||||||
|
if(![string]::IsNullOrEmpty($cmds["channel"])) {
|
||||||
try {
|
try {
|
||||||
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameters($cmd)
|
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameters($cmds["channel"])
|
||||||
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
|
||||||
}
|
}
|
||||||
catch [CAPIError] {
|
catch [CAPIError] {
|
||||||
Write-Warning $_.Exception.ErrorMessage()
|
Write-Warning $_.Exception.ErrorMessage()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($cmds.ContainsKey("mb")) {
|
||||||
|
$cmds["mb"] | ForEach-Object {
|
||||||
|
if($_.count -gt 0) {
|
||||||
|
MB_Set -ID $_[0] -SET $_[1] -MODE $_[2]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Param_Set_String {
|
Function Param_Set_String {
|
||||||
|
Loading…
Reference in New Issue
Block a user