update to multi_set, changelog, readme

Now using a nested hash for mult_set

added macrobutton commands to multi_set

updated example changelog and readme to reflect changes

minor version bumped
This commit is contained in:
onyx-and-iris 2021-05-03 12:33:43 +01:00
parent 770b9cf663
commit cbfd7a30f7
4 changed files with 73 additions and 75 deletions

View File

@ -7,11 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Before any minor/major patch is released all test units will be run to verify they pass. Before any minor/major patch is released all test units will be run to verify they pass.
## [Unreleased] ## [Unreleased]
- [x] Add gain, comp, limit to Strips - [ ]
- [x] Update tests to reflect changes
- [x] Add logging + summary for tests ## [1.4] - 2021-05-03
- [x] Add info to README about powershellget, nuget and psgallery ### Added
- [x] Support other types of params in multi_set - Add gain, comp, limit to Strips
- Update tests to reflect changes
- Add logging + summary for tests
- Add info to README about powershellget, nuget and psgallery
- Support other types of params in multi_set
### Changed
- Multi_Set now accepts nested hash
## [1.3] - 2021-04-30 ## [1.3] - 2021-04-30
### Added ### Added

View File

@ -75,7 +75,7 @@ parameter that does not exist for that version of Voicemeeter the wrapper will
throw an error. So make sure what you are settings actually exists. throw an error. So make sure what you are settings actually exists.
### Multiple parameters ### Multiple parameters
Set many strip/bus parameters at once, for Example Set many strip/bus/macrobutton parameters at once, for Example
```powershell ```powershell
Import-Module Voicemeeter Import-Module Voicemeeter
@ -83,12 +83,12 @@ try {
$vmr = Get-RemoteBanana $vmr = Get-RemoteBanana
$hash = @{ $hash = @{
"Strip[0].Mute" = $true strip_0 = @{mute = $true; mono = $true};
"Strip[1].Mute" = $true strip_2 = @{mute = $true; mono = $true};
"Strip[2].Mute" = $false bus_1 = @{mute = $true; mono = $true};
"Strip[0].Mono" = $true
"Strip[1].Mono" = $false mb_34 = @{state = $true};
"Strip[2].Mono" = $true mb_12 = @{trigger = $false};
} }
$vmr.Set_Multi($hash) $vmr.Set_Multi($hash)

View File

@ -4,39 +4,31 @@ try {
$vmr = Get-RemoteBanana $vmr = Get-RemoteBanana
$hash = @{ $hash = @{
"Strip[0].Mute" = $true strip_0 = @{mute = $true; mono = $true};
"Strip[1].Mute" = $true strip_1 = @{mute = $true; mono = $true};
"Strip[2].Mute" = $false strip_2 = @{mute = $true; mono = $true};
"Strip[0].Mono" = $true bus_0 = @{mute = $true; mono = $true};
"Strip[1].Mono" = $false bus_1 = @{mute = $true; mono = $true};
"Strip[2].Mono" = $true bus_2 = @{mute = $true; mono = $true};
mb_0 = @{state = $true};
mb_1 = @{stateonly = $true};
mb_2 = @{trigger = $true}
} }
$vmr.Set_Multi($hash) $vmr.Set_Multi($hash)
$hash = @{ $hash = @{
"Strip[0].Mute" = $false strip_0 = @{mute = $false; mono = $false};
"Strip[1].Mute" = $false strip_1 = @{mute = $false; mono = $false};
"Strip[2].Mute" = $false strip_2 = @{mute = $false; mono = $false};
"Strip[0].Mono" = $true bus_0 = @{mute = $false; mono = $false};
"Strip[1].Mono" = $true bus_1 = @{mute = $false; mono = $false};
"Strip[2].Mono" = $false bus_2 = @{mute = $false; mono = $false};
}
$vmr.Set_Multi($hash) mb_0 = @{state = $false};
mb_1 = @{stateonly = $false};
$hash = @{ mb_2 = @{trigger = $false}
"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) $vmr.Set_Multi($hash)

View File

@ -47,36 +47,43 @@ 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
$cmd_channel = [String]::new(512)
$cmd_mb = @(
,@()
)
ForEach ($line in $params) {
if($line.Trim() -Match "(^\w+)\[(\d)\].(\w+)\s+(\w+)") {
if($Matches[4] -eq "True") { $val = 1 } else { $val = 0 }
[String]$cmd_channel += "$($Matches[1])[$($Matches[2])].$($Matches[3])=$val;"
}
elseif($line.Trim() -Match "mb_(\d+).(\w+)\s+(\w+)") {
$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) $cmd_strip = [String]::new(512)
$cmd_bus = [String]::new(512)
$textInfo = (Get-Culture).TextInfo
ForEach($key in $HASH.keys) {
$identifier = $key.Split("_")[0]
$num = $key.Split("_")[1]
$val = if($HASH.Item($key).values -eq "True") {1} else {0}
if($identifier -eq "strip") {
ForEach($k in $HASH.Item($key).keys) {
$param = $textInfo.ToTitleCase($k)
$cmd_strip += "Strip[$num].$param=$val;"
}
}
elseif($identifier -eq "bus") {
ForEach($k in $HASH.Item($key).keys) {
$param = $textInfo.ToTitleCase($k)
$cmd_bus += "Bus[$num].$param=$val;"
}
}
elseif($identifier -eq "mb") {
ForEach($k in $HASH.Item($key).keys) {
if($k -eq "state") { $mode = 1 }
elseif($k -eq "stateonly") { $mode = 2 }
elseif($k -eq "trigger") { $mode = 3 }
$val = if($HASH.Item($key).values -eq "True") {1} else {0}
MB_Set -ID $num -SET $val -MODE $mode
}
} }
} }
[HashTable]$cmds = @{} @($cmd_bus, $cmd_strip) | ForEach-Object {
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($cmds["channel"]) $retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameters($_.Substring(1))
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) } if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
} }
catch [CAPIError] { catch [CAPIError] {
@ -84,14 +91,6 @@ Function Param_Set_Multi {
} }
} }
} }
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 {
param( param(