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.
## [Unreleased]
- [x] Add gain, comp, limit to Strips
- [x] Update tests to reflect changes
- [x] Add logging + summary for tests
- [x] Add info to README about powershellget, nuget and psgallery
- [x] Support other types of params in multi_set
- [ ]
## [1.4] - 2021-05-03
### Added
- 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
### 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.
### Multiple parameters
Set many strip/bus parameters at once, for Example
Set many strip/bus/macrobutton parameters at once, for Example
```powershell
Import-Module Voicemeeter
@ -83,12 +83,12 @@ try {
$vmr = Get-RemoteBanana
$hash = @{
"Strip[0].Mute" = $true
"Strip[1].Mute" = $true
"Strip[2].Mute" = $false
"Strip[0].Mono" = $true
"Strip[1].Mono" = $false
"Strip[2].Mono" = $true
strip_0 = @{mute = $true; mono = $true};
strip_2 = @{mute = $true; mono = $true};
bus_1 = @{mute = $true; mono = $true};
mb_34 = @{state = $true};
mb_12 = @{trigger = $false};
}
$vmr.Set_Multi($hash)

View File

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

View File

@ -47,48 +47,47 @@ Function Param_Set_Multi {
)
Start-Sleep -m 50
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)
[HashTable]$cmds = @{}
if(![string]::IsNullOrEmpty($cmd_channel)) { $cmds["channel"] = $cmd_channel }
if($cmd_mb.count -gt 0) { $cmds["mb"] = $cmd_mb }
$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($cmds.ContainsKey("channel")) {
$cmds["channel"] = $cmds["channel"] -replace '[^a-z0-9.\[\]=;]+'
if(![string]::IsNullOrEmpty($cmds["channel"])) {
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameters($cmds["channel"])
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
if($identifier -eq "strip") {
ForEach($k in $HASH.Item($key).keys) {
$param = $textInfo.ToTitleCase($k)
$cmd_strip += "Strip[$num].$param=$val;"
}
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
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
}
}
}
if($cmds.ContainsKey("mb")) {
$cmds["mb"] | ForEach-Object {
if($_.count -gt 0) {
MB_Set -ID $_[0] -SET $_[1] -MODE $_[2]
}
@($cmd_bus, $cmd_strip) | ForEach-Object {
try {
$retval = [Int][Voicemeeter.Remote]::VBVMR_SetParameters($_.Substring(1))
if($retval) { Throw [CAPIError]::new($retval, $MyInvocation.MyCommand) }
}
catch [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
}
}
}