mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-12-05 05:07:47 +00:00
Merge pull request #9 from pblivingston/patch-arraymembers
Patch and ArrayMember classes
This commit is contained in:
commit
16dd73231e
@ -12,6 +12,8 @@ Before any major/minor/patch is released all test units will be run to verify th
|
||||
### Added
|
||||
|
||||
- IRemote base class
|
||||
- ArrayMember classes for array-like properties
|
||||
- Patch class
|
||||
|
||||
## [3.3.0] - 2024-06-29
|
||||
|
||||
|
||||
23
README.md
23
README.md
@ -417,6 +417,29 @@ $vmr.command.Load("path/to/filename.xml")
|
||||
$vmr.command.RunMacrobuttons()
|
||||
```
|
||||
|
||||
### Patch
|
||||
|
||||
The following Patch commands are available:
|
||||
|
||||
- postFaderComposite: bool
|
||||
- postFxInsert: bool
|
||||
|
||||
The following Patch members have .Set($val) and .Get() available:
|
||||
|
||||
- asio[i]: int, from 0 to ASIO input channels
|
||||
- OutA2[i]-OutA5[i]: int, from 0 to ASIO output channels
|
||||
- composite[i]: int, from 0 to strip channels
|
||||
- insert[i]: bool
|
||||
|
||||
for example:
|
||||
|
||||
```powershell
|
||||
$vmr.patch.asio[3].set(2) # patches ASIO input channel 2 (2) to strip 2, channel 2 (3)
|
||||
$vmr.patch.OutA3[0].set(24) # patches bus A3, channel 1 (0) to ASIO output channel 24
|
||||
$vmr.patch.composite[5].set(0) # sets composite channel 6 (5) to default bus channel
|
||||
$vmr.patch.insert[4].get()
|
||||
```
|
||||
|
||||
### Recorder
|
||||
|
||||
The following commands are available:
|
||||
|
||||
@ -3,12 +3,14 @@
|
||||
. $PSScriptRoot\base.ps1
|
||||
. $PSScriptRoot\kinds.ps1
|
||||
. $PSScriptRoot\iremote.ps1
|
||||
. $PSScriptRoot\arraymember.ps1
|
||||
. $PSScriptRoot\strip.ps1
|
||||
. $PSScriptRoot\bus.ps1
|
||||
. $PSScriptRoot\macrobuttons.ps1
|
||||
. $PSScriptRoot\vban.ps1
|
||||
. $PSScriptRoot\command.ps1
|
||||
. $PSScriptRoot\recorder.ps1
|
||||
. $PSScriptRoot\patch.ps1
|
||||
. $PSScriptRoot\profiles.ps1
|
||||
|
||||
class Remote {
|
||||
@ -78,6 +80,7 @@ class RemoteBasic : Remote {
|
||||
[System.Collections.ArrayList]$button
|
||||
[PSCustomObject]$vban
|
||||
[Object]$command
|
||||
[Object]$patch
|
||||
|
||||
RemoteBasic () : base ('basic') {
|
||||
$this.strip = Make_Strips($this)
|
||||
@ -85,6 +88,7 @@ class RemoteBasic : Remote {
|
||||
$this.button = Make_Buttons
|
||||
$this.vban = Make_Vban($this)
|
||||
$this.command = Make_Command($this)
|
||||
$this.patch = Make_Patch($this)
|
||||
}
|
||||
}
|
||||
|
||||
@ -94,6 +98,7 @@ class RemoteBanana : Remote {
|
||||
[System.Collections.ArrayList]$button
|
||||
[PSCustomObject]$vban
|
||||
[Object]$command
|
||||
[Object]$patch
|
||||
[Object]$recorder
|
||||
|
||||
RemoteBanana () : base ('banana') {
|
||||
@ -102,6 +107,7 @@ class RemoteBanana : Remote {
|
||||
$this.button = Make_Buttons
|
||||
$this.vban = Make_Vban($this)
|
||||
$this.command = Make_Command($this)
|
||||
$this.patch = Make_Patch($this)
|
||||
$this.recorder = Make_Recorder($this)
|
||||
}
|
||||
}
|
||||
@ -112,6 +118,7 @@ class RemotePotato : Remote {
|
||||
[System.Collections.ArrayList]$button
|
||||
[PSCustomObject]$vban
|
||||
[Object]$command
|
||||
[Object]$patch
|
||||
[Object]$recorder
|
||||
|
||||
RemotePotato () : base ('potato') {
|
||||
@ -120,6 +127,7 @@ class RemotePotato : Remote {
|
||||
$this.button = Make_Buttons
|
||||
$this.vban = Make_Vban($this)
|
||||
$this.command = Make_Command($this)
|
||||
$this.patch = Make_Patch($this)
|
||||
$this.recorder = Make_Recorder($this)
|
||||
}
|
||||
}
|
||||
|
||||
64
lib/arraymember.ps1
Normal file
64
lib/arraymember.ps1
Normal file
@ -0,0 +1,64 @@
|
||||
class ArrayMember : IRemote {
|
||||
[string]$prefix
|
||||
[Object]$parent
|
||||
|
||||
ArrayMember (
|
||||
[int]$index, [string]$prefix, [Object]$parent
|
||||
) : base ($index, $parent.remote) {
|
||||
$this.prefix = $prefix
|
||||
$this.parent = $parent
|
||||
}
|
||||
|
||||
[string] identifier () {
|
||||
$parentId = $this.parent.identifier()
|
||||
return "{0}.{1}[{2}]" -f $parentId, $this.prefix, $this.index
|
||||
}
|
||||
|
||||
[void] Set ($val) {
|
||||
$this.Setter('', $val)
|
||||
}
|
||||
}
|
||||
|
||||
class BoolArrayMember : ArrayMember {
|
||||
BoolArrayMember (
|
||||
[int]$index, [string]$prefix, [Object]$parent
|
||||
) : base ($index, $prefix, $parent) {}
|
||||
|
||||
[bool] Get () {
|
||||
return [bool]$this.Getter('')
|
||||
}
|
||||
}
|
||||
|
||||
class IntArrayMember : ArrayMember {
|
||||
IntArrayMember (
|
||||
[int]$index, [string]$prefix, [Object]$parent
|
||||
) : base ($index, $prefix, $parent) {}
|
||||
|
||||
[int] Get () {
|
||||
return [int]$this.Getter('')
|
||||
}
|
||||
}
|
||||
|
||||
class FloatArrayMember : ArrayMember {
|
||||
[int]$decimals
|
||||
|
||||
FloatArrayMember (
|
||||
[int]$index, [string]$prefix, [Object]$parent, [int]$decimals = 1
|
||||
) : base ($index, $prefix, $parent) {
|
||||
$this.decimals = $decimals
|
||||
}
|
||||
|
||||
[double] Get () {
|
||||
return [math]::Round($this.Getter(''), $this.decimals)
|
||||
}
|
||||
}
|
||||
|
||||
class StringArrayMember : ArrayMember {
|
||||
StringArrayMember (
|
||||
[int]$index, [string]$prefix, [Object]$parent
|
||||
) : base ($index, $prefix, $parent) {}
|
||||
|
||||
[string] Get () {
|
||||
return [string]$this.Getter_String('')
|
||||
}
|
||||
}
|
||||
@ -1,33 +1,45 @@
|
||||
$KindMap = @{
|
||||
'basic' = @{
|
||||
'name' = 'basic'
|
||||
'p_in' = 2
|
||||
'v_in' = 1
|
||||
'p_out' = 1
|
||||
'v_out' = 1
|
||||
'vban_in' = 4
|
||||
'vban_out' = 4
|
||||
'name' = 'basic'
|
||||
'p_in' = 2
|
||||
'v_in' = 1
|
||||
'p_out' = 1
|
||||
'v_out' = 1
|
||||
'asio_in' = 4
|
||||
'asio_out' = 8
|
||||
'composite' = 0
|
||||
'insert' = 0
|
||||
'vban_in' = 4
|
||||
'vban_out' = 4
|
||||
};
|
||||
'banana' = @{
|
||||
'name' = 'banana'
|
||||
'p_in' = 3
|
||||
'v_in' = 2
|
||||
'p_out' = 3
|
||||
'v_out' = 2
|
||||
'vban_in' = 8
|
||||
'vban_out' = 8
|
||||
'name' = 'banana'
|
||||
'p_in' = 3
|
||||
'v_in' = 2
|
||||
'p_out' = 3
|
||||
'v_out' = 2
|
||||
'asio_in' = 6
|
||||
'asio_out' = 8
|
||||
'composite' = 8
|
||||
'insert' = 22
|
||||
'vban_in' = 8
|
||||
'vban_out' = 8
|
||||
};
|
||||
'potato' = @{
|
||||
'name' = 'potato'
|
||||
'p_in' = 5
|
||||
'v_in' = 3
|
||||
'p_out' = 5
|
||||
'v_out' = 3
|
||||
'vban_in' = 8
|
||||
'vban_out' = 8
|
||||
'name' = 'potato'
|
||||
'p_in' = 5
|
||||
'v_in' = 3
|
||||
'p_out' = 5
|
||||
'v_out' = 3
|
||||
'asio_in' = 10
|
||||
'asio_out' = 8
|
||||
'composite' = 8
|
||||
'insert' = 34
|
||||
'vban_in' = 8
|
||||
'vban_out' = 8
|
||||
};
|
||||
}
|
||||
|
||||
function GetKind ([string]$kindId) {
|
||||
$KindMap[$kindId]
|
||||
}
|
||||
}
|
||||
52
lib/patch.ps1
Normal file
52
lib/patch.ps1
Normal file
@ -0,0 +1,52 @@
|
||||
class Patch : IRemote {
|
||||
[System.Collections.ArrayList]$asio
|
||||
[System.Collections.ArrayList]$composite
|
||||
[System.Collections.ArrayList]$insert
|
||||
|
||||
Patch ([Object]$remote) : base ($remote) {
|
||||
AddBoolMembers -PARAMS @('postFaderComposite', 'postFxInsert')
|
||||
|
||||
$this.AddASIOOutMembers()
|
||||
|
||||
$this.asio = @()
|
||||
for ($i = 0; $i -lt $remote.kind.asio_in; $i++) {
|
||||
$this.asio.Add([IntArrayMember]::new($i, 'asio', $this))
|
||||
}
|
||||
|
||||
$this.composite = @()
|
||||
for ($i = 0; $i -lt $remote.kind.composite; $i++) {
|
||||
$this.composite.Add([IntArrayMember]::new($i, 'composite', $this))
|
||||
}
|
||||
|
||||
$this.insert = @()
|
||||
for ($i = 0; $i -lt $remote.kind.insert; $i++) {
|
||||
$this.insert.Add([BoolArrayMember]::new($i, 'insert', $this))
|
||||
}
|
||||
}
|
||||
|
||||
[string] identifier () {
|
||||
return 'Patch'
|
||||
}
|
||||
|
||||
hidden [void] AddASIOOutMembers () {
|
||||
$num_A = $this.remote.kind.p_out
|
||||
if ($this.remote.kind.name -eq 'basic') {
|
||||
$num_A += $this.remote.kind.v_out
|
||||
}
|
||||
$asio_out = $this.remote.kind.asio_out
|
||||
|
||||
if ($asio_out -le 0) { return }
|
||||
|
||||
for ($a = 2; $a -le $num_A; $a++) {
|
||||
[System.Collections.ArrayList]$members = @()
|
||||
for ($i = 0; $i -lt $asio_out; $i++) {
|
||||
$members.Add([IntArrayMember]::new($i, "OutA$a", $this))
|
||||
}
|
||||
Add-Member -InputObject $this -MemberType NoteProperty -Name "OutA$a" -Value $members -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Make_Patch ([Object]$remote) {
|
||||
return [Patch]::new($remote)
|
||||
}
|
||||
@ -110,6 +110,23 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
|
||||
$vmr.command.lock = $value
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Patch' {
|
||||
It 'Should set and get Patch.insert[$insert]' -Skip:$ifBasic {
|
||||
$vmr.patch.insert[$insert].set($value)
|
||||
$vmr.patch.insert[$insert].get() | Should -Be $value
|
||||
}
|
||||
|
||||
It 'Should set and get Patch.postfadercomposite' -Skip:$ifBasic {
|
||||
$vmr.patch.postfadercomposite = $value
|
||||
$vmr.patch.postfadercomposite | Should -Be $value
|
||||
}
|
||||
|
||||
It 'Should set and get Patch.postfxinsert' -Skip:$ifBasic {
|
||||
$vmr.patch.postfxinsert = $value
|
||||
$vmr.patch.postfxinsert | Should -Be $value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Float Tests' {
|
||||
@ -241,6 +258,15 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Context 'Patch' {
|
||||
It 'Should set and get Patch.composite[$composite]' -Skip:$ifBasic -ForEach @(
|
||||
@{ Value = 22 }, @{ Value = 6 }
|
||||
) {
|
||||
$vmr.patch.composite[$composite].set($value)
|
||||
$vmr.patch.composite[$composite].get() | Should -Be $value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'String Tests' {
|
||||
|
||||
@ -16,6 +16,8 @@ function main() {
|
||||
$virt_out = $vmr.kind.p_out + $vmr.kind.v_out - 1
|
||||
$vban_in = $vmr.kind.vban_in - 1
|
||||
$vban_out = $vmr.kind.vban_out - 1
|
||||
$insert = $vmr.kind.insert - 1
|
||||
$composite = $vmr.kind.composite - 1
|
||||
|
||||
# skip conditions by kind
|
||||
$ifBasic = $vmr.kind.name -eq 'basic'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user