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')