Merge pull request #13 from pblivingston/decouple-device

Decouple device
This commit is contained in:
Onyx and Iris 2025-11-27 12:31:51 +00:00 committed by GitHub
commit 07028478cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 201 additions and 137 deletions

View File

@ -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 - ArrayMember classes for array-like properties
- Patch class - Patch class
- Option class - Option class
- Device classes
## [3.3.0] - 2024-06-29 ## [3.3.0] - 2024-06-29

View File

@ -312,6 +312,7 @@ $vmr.bus[0].device.name
name, sr are defined as read only. name, sr are defined as read only.
wdm, ks, mme, asio are defined as write only. wdm, ks, mme, asio are defined as write only.
asio only defined for Bus[0].Device
#### eq #### eq

View File

@ -4,6 +4,7 @@
. $PSScriptRoot\kinds.ps1 . $PSScriptRoot\kinds.ps1
. $PSScriptRoot\iremote.ps1 . $PSScriptRoot\iremote.ps1
. $PSScriptRoot\arraymember.ps1 . $PSScriptRoot\arraymember.ps1
. $PSScriptRoot\device.ps1
. $PSScriptRoot\strip.ps1 . $PSScriptRoot\strip.ps1
. $PSScriptRoot\bus.ps1 . $PSScriptRoot\bus.ps1
. $PSScriptRoot\macrobuttons.ps1 . $PSScriptRoot\macrobuttons.ps1

View File

@ -101,75 +101,35 @@ class PhysicalBus : Bus {
} }
} }
class BusDevice : IRemote { 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)
}
}
}
class BusDevice : Device {
BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
if ($this.index -eq 0) {
$this.AddASIO()
}
} }
[string] identifier () { [string] identifier () {
return 'Bus[' + $this.index + '].Device' return 'Bus[' + $this.index + '].Device'
} }
hidden $_name = $($this | Add-Member ScriptProperty 'name' ` hidden [void] AddASIO () {
{ Add-Member -InputObject $this -MemberType ScriptProperty -Name 'asio' `
$this.Getter_String('name') -Value {
} `
{
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") return Write-Warning ("ERROR: $($this.identifier()).asio is write only")
} ` } -SecondValue {
{
param($arg) param($arg)
return $this.Setter('asio', $arg) return $this.Setter('asio', $arg)
} } -Force
)
}
class VirtualBus : Bus {
VirtualBus ([int]$index, [Object]$remote) : base ($index, $remote) {
} }
} }

52
lib/device.ps1 Normal file
View File

@ -0,0 +1,52 @@
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' `
{
[int]$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)
}
)
}

View File

@ -162,71 +162,13 @@ class StripEq : IRemote {
} }
} }
class StripDevice : IRemote { class StripDevice : Device {
StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
} }
[string] identifier () { [string] identifier () {
return 'Strip[' + $this.index + '].Device' 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 { class VirtualStrip : Strip {

View File

@ -251,38 +251,66 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
} }
} }
Describe 'Int Tests' -ForEach @( Describe 'Int Tests' {
@{ Index = $phys_in }, @{ Index = $virt_in } Context 'Strip, one physical, one virtual' -ForEach @(
) { @{ Index = $phys_in }, @{ Index = $virt_in }
Context 'Strip, one physical, one virtual' -Skip:$ifBasic -ForEach @(
@{ Value = 3; Expected = 3 }
@{ Value = -6; Expected = -6 }
) { ) {
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 = $value
$vmr.strip[$index].limit | Should -Be $expected $vmr.strip[$index].limit | Should -Be $expected
} }
} }
Context 'Vban outstream' { Context 'Strip, physical only' -ForEach @(
Context 'sr' -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 = 44100; Expected = 44100 }
@{ Value = 48000; Expected = 48000 } @{ Value = 48000; Expected = 48000 }
) { ) {
It "Should set vban.outstream[$index].sr to $value" { $vmr.vban.outstream[$index].sr = $value
$vmr.vban.outstream[$index].sr = $value $vmr.vban.outstream[$index].sr | Should -Be $expected
$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 = 1; Expected = 1 }
@{ Value = 2; Expected = 2 } @{ Value = 2; Expected = 2 }
) { ) {
It 'Should set vban.outstream[0].channel to 1' { $vmr.vban.outstream[$index].channel = $value
$vmr.vban.outstream[$index].channel = $value $vmr.vban.outstream[$index].channel | Should -Be $expected
$vmr.vban.outstream[$index].channel | Should -Be $expected
}
} }
} }
@ -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 @( Context 'Bus, one physical, one virtual' -ForEach @(
@{ Index = $phys_out }, @{ Index = $virt_out } @{ 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 @( Describe 'Vban' -ForEach @(
@{ Index = $vban_in } @{ Index = $vban_in }
) { ) {

View File

@ -21,6 +21,7 @@ function main() {
# skip conditions by kind # skip conditions by kind
$ifBasic = $vmr.kind.name -eq 'basic' $ifBasic = $vmr.kind.name -eq 'basic'
$ifNotBasic = $vmr.kind.name -ne 'basic'
$ifNotPotato = $vmr.kind.name -ne 'potato' $ifNotPotato = $vmr.kind.name -ne 'potato'
Invoke-Pester -Tag $tag -PassThru | Out-Null Invoke-Pester -Tag $tag -PassThru | Out-Null