From 42b17a72393713639ee41eac9713b0d48eebc391 Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 17 Dec 2022 15:40:07 +0000 Subject: [PATCH] mode class added to Bus. removed busmodemember meta functions. --- lib/bus.ps1 | 71 +++++++++++++++++++++++++++++++++++++++++++++++++--- lib/meta.ps1 | 17 ------------- 2 files changed, 68 insertions(+), 20 deletions(-) diff --git a/lib/bus.ps1 b/lib/bus.ps1 index a2719d2..cebcfcc 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -31,6 +31,7 @@ class IBus { } class Bus : IBus { + [Object]$mode [Object]$eq # Constructor @@ -39,9 +40,7 @@ class Bus : IBus { AddStringMembers -PARAMS @('label') AddFloatMembers -PARAMS @('gain', 'returnreverb', 'returndelay', 'returnfx1', 'returnfx2') - AddBusModeMembers -PARAMS @('normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21') - AddBusModeMembers -PARAMS @('upmix41', 'upmix61', 'centeronly', 'lfeonly', 'rearonly') - + $this.mode = [Mode]::new($index, $remote) $this.eq = [Eq]::new($index, $remote) } @@ -54,6 +53,32 @@ class Bus : IBus { } } +class Mode : IBus { + [System.Collections.ArrayList]$modes + + Mode ([int]$index, [Object]$remote) : base ($index, $remote) { + $this.modes = @( + 'normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21', 'upmix41', 'upmix61', + 'centeronly', 'lfeonly', 'rearonly' + ) + + AddBoolMembers -PARAMS $this.modes + } + + [string] identifier () { + return "Bus[" + $this.index + "].mode" + } + + [string] Get () { + foreach ($mode in $this.modes) { + if ($this.$mode) { + break + } + } + return $mode + } +} + class Eq : IBus { Eq ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('on', 'ab') @@ -97,6 +122,46 @@ class Device : IBus { 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 { diff --git a/lib/meta.ps1 b/lib/meta.ps1 index 79bef2f..ee4f598 100644 --- a/lib/meta.ps1 +++ b/lib/meta.ps1 @@ -104,23 +104,6 @@ function AddGainlayerMembers () { } } -function AddBusModeMembers () { - param( - [String[]]$PARAMS - ) - [hashtable]$Signatures = @{} - foreach ($param in $PARAMS) { - # Define getter - $Signatures["Getter"] = "[bool]`$this.Getter('mode.{0}')" -f $param - # Define setter - $Signatures["Setter"] = "param ( [Single]`$arg )`n`$this.Setter('mode.{0}', `$arg)" ` - -f $param - $param = "mode_{0}" -f $param - - Addmember - } -} - function Addmember { $AddMemberParams = @{ Name = $param