From ee85d5ffd8b4c8c2a4e941305e34d75bf3b72a18 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Wed, 26 Nov 2025 17:23:01 -0500 Subject: [PATCH 1/4] decouple device - basic A2 device supported - asio only added to bus[0].device --- lib/Voicemeeter.psm1 | 1 + lib/bus.ps1 | 72 +++----------------------------------- lib/device.ps1 | 83 ++++++++++++++++++++++++++++++++++++++++++++ lib/strip.ps1 | 67 ----------------------------------- 4 files changed, 89 insertions(+), 134 deletions(-) create mode 100644 lib/device.ps1 diff --git a/lib/Voicemeeter.psm1 b/lib/Voicemeeter.psm1 index 4c24d3e..42b0762 100644 --- a/lib/Voicemeeter.psm1 +++ b/lib/Voicemeeter.psm1 @@ -4,6 +4,7 @@ . $PSScriptRoot\kinds.ps1 . $PSScriptRoot\iremote.ps1 . $PSScriptRoot\arraymember.ps1 +. $PSScriptRoot\device.ps1 . $PSScriptRoot\strip.ps1 . $PSScriptRoot\bus.ps1 . $PSScriptRoot\macrobuttons.ps1 diff --git a/lib/bus.ps1 b/lib/bus.ps1 index d59cdee..542b352 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -101,75 +101,13 @@ class PhysicalBus : Bus { } } -class BusDevice : IRemote { - BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { - } - - [string] identifier () { - return 'Bus[' + $this.index + '].Device' - } - - hidden $_name = $($this | Add-Member ScriptProperty 'name' ` - { - $this.Getter_String('name') - } ` - { - return Write-Warning ("ERROR: $($this.identifier()).name is read only") - } - ) - - hidden $_sr = $($this | Add-Member ScriptProperty 'sr' ` - { - $this.Getter('sr') - } ` - { - return Write-Warning ("ERROR: $($this.identifier()).sr is read only") - } - ) - - hidden $_wdm = $($this | Add-Member ScriptProperty 'wdm' ` - { - return Write-Warning ("ERROR: $($this.identifier()).wdm is write only") - } ` - { - param($arg) - return $this.Setter('wdm', $arg) - } - ) - - hidden $_ks = $($this | Add-Member ScriptProperty 'ks' ` - { - return Write-Warning ("ERROR: $($this.identifier()).ks is write only") - } ` - { - param($arg) - return $this.Setter('ks', $arg) - } - ) - - hidden $_mme = $($this | Add-Member ScriptProperty 'mme' ` - { - return Write-Warning ("ERROR: $($this.identifier()).mme is write only") - } ` - { - param($arg) - return $this.Setter('mme', $arg) - } - ) - - hidden $_asio = $($this | Add-Member ScriptProperty 'asio' ` - { - return Write-Warning ("ERROR: $($this.identifier()).asio is write only") - } ` - { - param($arg) - return $this.Setter('asio', $arg) - } - ) -} - class VirtualBus : Bus { + [Object]$device + VirtualBus ([int]$index, [Object]$remote) : base ($index, $remote) { + if ($this.remote.kind.name -eq 'basic') { + $this.device = [BusDevice]::new($index, $remote) + } } } diff --git a/lib/device.ps1 b/lib/device.ps1 new file mode 100644 index 0000000..5f5525c --- /dev/null +++ b/lib/device.ps1 @@ -0,0 +1,83 @@ +class Device : IRemote { + Device ([int]$index, [Object]$remote) : base ($index, $remote) { + } + + hidden $_name = $($this | Add-Member ScriptProperty 'name' ` + { + $this.Getter_String('name') + } ` + { + return Write-Warning ("ERROR: $($this.identifier()).name is read only") + } + ) + + hidden $_sr = $($this | Add-Member ScriptProperty 'sr' ` + { + $this.Getter('sr') + } ` + { + return Write-Warning ("ERROR: $($this.identifier()).sr is read only") + } + ) + + hidden $_wdm = $($this | Add-Member ScriptProperty 'wdm' ` + { + return Write-Warning ("ERROR: $($this.identifier()).wdm is write only") + } ` + { + param($arg) + return $this.Setter('wdm', $arg) + } + ) + + hidden $_ks = $($this | Add-Member ScriptProperty 'ks' ` + { + return Write-Warning ("ERROR: $($this.identifier()).ks is write only") + } ` + { + param($arg) + return $this.Setter('ks', $arg) + } + ) + + hidden $_mme = $($this | Add-Member ScriptProperty 'mme' ` + { + return Write-Warning ("ERROR: $($this.identifier()).mme is write only") + } ` + { + param($arg) + return $this.Setter('mme', $arg) + } + ) +} + +class BusDevice : Device { + BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { + if ($this.index -eq 0) { + $this.AddASIO() + } + } + + [string] identifier () { + return 'Bus[' + $this.index + '].Device' + } + + hidden [void] AddASIO () { + Add-Member -InputObject $this -MemberType ScriptProperty -Name 'asio' ` + -Value { + return Write-Warning ("ERROR: $($this.identifier()).asio is write only") + } -SecondValue { + param($arg) + return $this.Setter('asio', $arg) + } -Force + } +} + +class StripDevice : Device { + StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { + } + + [string] identifier () { + return 'Strip[' + $this.index + '].Device' + } +} \ No newline at end of file diff --git a/lib/strip.ps1 b/lib/strip.ps1 index 2c0821e..63b7dd3 100644 --- a/lib/strip.ps1 +++ b/lib/strip.ps1 @@ -162,73 +162,6 @@ class StripEq : IRemote { } } -class StripDevice : IRemote { - StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { - } - - [string] identifier () { - return 'Strip[' + $this.index + '].Device' - } - - hidden $_name = $($this | Add-Member ScriptProperty 'name' ` - { - $this.Getter_String('name') - } ` - { - return Write-Warning ("ERROR: $($this.identifier()).name is read only") - } - ) - - hidden $_sr = $($this | Add-Member ScriptProperty 'sr' ` - { - $this.Getter('sr') - } ` - { - return Write-Warning ("ERROR: $($this.identifier()).sr is read only") - } - ) - - hidden $_wdm = $($this | Add-Member ScriptProperty 'wdm' ` - { - return Write-Warning ("ERROR: $($this.identifier()).wdm is write only") - } ` - { - param($arg) - return $this.Setter('wdm', $arg) - } - ) - - hidden $_ks = $($this | Add-Member ScriptProperty 'ks' ` - { - return Write-Warning ("ERROR: $($this.identifier()).ks is write only") - } ` - { - param($arg) - return $this.Setter('ks', $arg) - } - ) - - hidden $_mme = $($this | Add-Member ScriptProperty 'mme' ` - { - return Write-Warning ("ERROR: $($this.identifier()).mme is write only") - } ` - { - param($arg) - return $this.Setter('mme', $arg) - } - ) - - hidden $_asio = $($this | Add-Member ScriptProperty 'asio' ` - { - return Write-Warning ("ERROR: $($this.identifier()).asio is write only") - } ` - { - param($arg) - return $this.Setter('asio', $arg) - } - ) -} - class VirtualStrip : Strip { VirtualStrip ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('mc') From 1e4a2da8219de3469b26e4d34b15bd40510b98c2 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Wed, 26 Nov 2025 17:54:06 -0500 Subject: [PATCH 2/4] update tests pester tests pass for all kinds - cast device.sr to int --- lib/device.ps1 | 2 +- tests/higher.Tests.ps1 | 144 +++++++++++++++++++++++++++++++++++------ tests/run.ps1 | 1 + 3 files changed, 127 insertions(+), 20 deletions(-) diff --git a/lib/device.ps1 b/lib/device.ps1 index 5f5525c..aa24c8c 100644 --- a/lib/device.ps1 +++ b/lib/device.ps1 @@ -13,7 +13,7 @@ class Device : IRemote { hidden $_sr = $($this | Add-Member ScriptProperty 'sr' ` { - $this.Getter('sr') + [int]$this.Getter('sr') } ` { return Write-Warning ("ERROR: $($this.identifier()).sr is read only") diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index aa825ae..3f2dda0 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -251,39 +251,67 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } - Describe 'Int Tests' -ForEach @( - @{ Index = $phys_in }, @{ Index = $virt_in } - ) { - Context 'Strip, one physical, one virtual' -Skip:$ifBasic -ForEach @( - @{ Value = 3; Expected = 3 } - @{ Value = -6; Expected = -6 } + Describe 'Int Tests' { + Context 'Strip, one physical, one virtual' -ForEach @( + @{ Index = $phys_in }, @{ Index = $virt_in } ) { - It "Should set Strip[$index].Limit to 3" { + It "Should set and get Strip[$index].Limit" -Skip:$ifBasic -ForEach @( + @{ Value = 3; Expected = 3 } + @{ Value = -6; Expected = -6 } + ) { $vmr.strip[$index].limit = $value $vmr.strip[$index].limit | Should -Be $expected } } - Context 'Vban outstream' { - Context 'sr' -ForEach @( + Context 'Strip, physical only' -ForEach @( + @{ Index = $phys_in } + ) { + Context 'Device' { + It "Should get Strip[$index].Device.sr" { + $vmr.strip[$index].device.sr | Should -BeOfType [int] + } + } + } + + Context 'Bus, physical only' -ForEach @( + @{ Index = $phys_out } + ) { + Context 'Device' { + It "Should get Bus[$index].Device.sr" { + $vmr.bus[$index].device.sr | Should -BeOfType [int] + } + } + } + + Context 'Bus, virtual only' -ForEach @( + @{ Index = $virt_out } + ) { + Context 'Device' -Skip:$ifNotBasic { + It "Should get Bus[$index].Device.sr" { + $vmr.bus[$index].device.sr | Should -BeOfType [int] + } + } + } + + Context 'Vban outstream' -ForEach @( + @{ Index = $vban_out } + ) { + It "Should set vban.outstream[$index].sr to $value" -ForEach @( @{ Value = 44100; Expected = 44100 } @{ Value = 48000; Expected = 48000 } ) { - It "Should set vban.outstream[$index].sr to $value" { - $vmr.vban.outstream[$index].sr = $value - $vmr.vban.outstream[$index].sr | Should -Be $expected - } + $vmr.vban.outstream[$index].sr = $value + $vmr.vban.outstream[$index].sr | Should -Be $expected } - Context 'channel' -ForEach @( + It 'Should set vban.outstream[0].channel to 1' -ForEach @( @{ Value = 1; Expected = 1 } @{ Value = 2; Expected = 2 } ) { - It 'Should set vban.outstream[0].channel to 1' { - $vmr.vban.outstream[$index].channel = $value - $vmr.vban.outstream[$index].channel | Should -Be $expected - } - } + $vmr.vban.outstream[$index].channel = $value + $vmr.vban.outstream[$index].channel | Should -Be $expected + } } Context 'Patch' { @@ -341,6 +369,32 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } + Context 'Strip, physical only' -ForEach @( + @{ Index = $phys_in } + ) { + Context 'Device' -ForEach @( + @{ Value = 'testInput' }, @{ Value = '' } + ) { + It "Should set Strip[$index].Device.wdm" { + $vmr.strip[$index].device.wdm = $value + Start-Sleep -Milliseconds 800 + $vmr.strip[$index].device.name | Should -Be $value + } + + It "Should set Strip[$index].Device.ks" { + $vmr.strip[$index].device.ks = $value + Start-Sleep -Milliseconds 800 + $vmr.strip[$index].device.name | Should -Be $value + } + + It "Should set Strip[$index].Device.mme" { + $vmr.strip[$index].device.mme = $value + Start-Sleep -Milliseconds 800 + $vmr.strip[$index].device.name | Should -Be $value + } + } + } + Context 'Bus, one physical, one virtual' -ForEach @( @{ Index = $phys_out }, @{ Index = $virt_out } ) { @@ -353,6 +407,58 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { } } + Context 'Bus, physical only' -ForEach @( + @{ Index = $phys_out } + ) { + Context 'Device' -ForEach @( + @{ Value = 'testOutput' }, @{ Value = '' } + ) { + It "Should set Bus[$index].Device.wdm" { + $vmr.bus[$index].device.wdm = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.ks" { + $vmr.bus[$index].device.ks = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.mme" { + $vmr.bus[$index].device.mme = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + } + } + + Context 'Bus, virtual only' -ForEach @( + @{ Index = $virt_out } + ) { + Context 'Device' -Skip:$ifNotBasic -ForEach @( + @{ Value = 'testOutput' }, @{ Value = '' } + ) { + It "Should set Bus[$index].Device.wdm" { + $vmr.bus[$index].device.wdm = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.ks" { + $vmr.bus[$index].device.ks = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + + It "Should set Bus[$index].Device.mme" { + $vmr.bus[$index].device.mme = $value + Start-Sleep -Milliseconds 800 + $vmr.bus[$index].device.name | Should -Be $value + } + } + } + Describe 'Vban' -ForEach @( @{ Index = $vban_in } ) { diff --git a/tests/run.ps1 b/tests/run.ps1 index e6fa0a6..e592d91 100644 --- a/tests/run.ps1 +++ b/tests/run.ps1 @@ -21,6 +21,7 @@ function main() { # skip conditions by kind $ifBasic = $vmr.kind.name -eq 'basic' + $ifNotBasic = $vmr.kind.name -ne 'basic' $ifNotPotato = $vmr.kind.name -ne 'potato' Invoke-Pester -Tag $tag -PassThru | Out-Null From 820b897e84b0ad54001706d3c2ed3f04e2728d4d Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Wed, 26 Nov 2025 18:04:37 -0500 Subject: [PATCH 3/4] update docs Manual tests pass - device.asio --- CHANGELOG.md | 1 + README.md | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 95abcc3..0cde41a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Before any major/minor/patch is released all test units will be run to verify th - ArrayMember classes for array-like properties - Patch class - Option class +- Device classes ## [3.3.0] - 2024-06-29 diff --git a/README.md b/README.md index 12223c6..694399b 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,7 @@ $vmr.bus[0].device.name name, sr are defined as read only. wdm, ks, mme, asio are defined as write only. +asio only defined for Bus[0].Device #### eq From 3f7bef56c1b0d096fb0bb48f521caab6591950fd Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Thu, 27 Nov 2025 06:09:55 -0500 Subject: [PATCH 4/4] strip, bus device move stripdevice and busdevice back to strip & bus --- lib/bus.ps1 | 22 ++++++++++++++++++++++ lib/device.ps1 | 31 ------------------------------- lib/strip.ps1 | 9 +++++++++ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lib/bus.ps1 b/lib/bus.ps1 index 542b352..bd0ac15 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -111,6 +111,28 @@ class VirtualBus : Bus { } } +class BusDevice : Device { + BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { + if ($this.index -eq 0) { + $this.AddASIO() + } + } + + [string] identifier () { + return 'Bus[' + $this.index + '].Device' + } + + hidden [void] AddASIO () { + Add-Member -InputObject $this -MemberType ScriptProperty -Name 'asio' ` + -Value { + return Write-Warning ("ERROR: $($this.identifier()).asio is write only") + } -SecondValue { + param($arg) + return $this.Setter('asio', $arg) + } -Force + } +} + function Make_Buses ([Object]$remote) { [System.Collections.ArrayList]$bus = @() 0..$($remote.kind.p_out + $remote.kind.v_out - 1) | ForEach-Object { diff --git a/lib/device.ps1 b/lib/device.ps1 index aa24c8c..df8feb3 100644 --- a/lib/device.ps1 +++ b/lib/device.ps1 @@ -49,35 +49,4 @@ class Device : IRemote { return $this.Setter('mme', $arg) } ) -} - -class BusDevice : Device { - BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { - if ($this.index -eq 0) { - $this.AddASIO() - } - } - - [string] identifier () { - return 'Bus[' + $this.index + '].Device' - } - - hidden [void] AddASIO () { - Add-Member -InputObject $this -MemberType ScriptProperty -Name 'asio' ` - -Value { - return Write-Warning ("ERROR: $($this.identifier()).asio is write only") - } -SecondValue { - param($arg) - return $this.Setter('asio', $arg) - } -Force - } -} - -class StripDevice : Device { - StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { - } - - [string] identifier () { - return 'Strip[' + $this.index + '].Device' - } } \ No newline at end of file diff --git a/lib/strip.ps1 b/lib/strip.ps1 index 63b7dd3..ef16163 100644 --- a/lib/strip.ps1 +++ b/lib/strip.ps1 @@ -162,6 +162,15 @@ class StripEq : IRemote { } } +class StripDevice : Device { + StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { + } + + [string] identifier () { + return 'Strip[' + $this.index + '].Device' + } +} + class VirtualStrip : Strip { VirtualStrip ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('mc')