From 2404bfb50f7e8534813bd5ad7bdc0ff12d3503c5 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 14:39:10 -0500 Subject: [PATCH 01/11] create iremote.ps1 --- lib/Voicemeeter.psm1 | 1 + lib/iremote.ps1 | 49 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 lib/iremote.ps1 diff --git a/lib/Voicemeeter.psm1 b/lib/Voicemeeter.psm1 index 10b30f3..7002acb 100644 --- a/lib/Voicemeeter.psm1 +++ b/lib/Voicemeeter.psm1 @@ -2,6 +2,7 @@ . $PSScriptRoot\meta.ps1 . $PSScriptRoot\base.ps1 . $PSScriptRoot\kinds.ps1 +. $PSScriptRoot\iremote.ps1 . $PSScriptRoot\strip.ps1 . $PSScriptRoot\bus.ps1 . $PSScriptRoot\macrobuttons.ps1 diff --git a/lib/iremote.ps1 b/lib/iremote.ps1 new file mode 100644 index 0000000..735dcb9 --- /dev/null +++ b/lib/iremote.ps1 @@ -0,0 +1,49 @@ +class IRemote { + [int]$index + [Object]$remote + + IRemote ([Object]$remote) { + $this.remote = $remote + } + + IRemote ([int]$index, [Object]$remote) { + $this.index = $index + $this.remote = $remote + } + + [single] Getter ($param) { + $this.ToString() + " Getter: $($this.Cmd($param))" | Write-Debug + return $this.remote.Getter($this.Cmd($param)) + } + + [string] Getter_String ($param) { + $this.ToString() + " Getter_String: $($this.Cmd($param))" | Write-Debug + return $this.remote.Getter_String($this.Cmd($param)) + } + + [void] Setter ($param, $val) { + $this.ToString() + " Setter: $($this.Cmd($param))=$val" | Write-Debug + if ($val -is [Boolean]) { + $this.remote.Setter($this.Cmd($param), $(if ($val) { 1 } else { 0 })) + } + else { + $this.remote.Setter($this.Cmd($param), $val) + } + } + + [string] Cmd ($param) { + if ([string]::IsNullOrEmpty($param)) { + return $this.identifier() + } + return "$($this.identifier()).$param" + } + + # Must be overridden by derived classes + [string] identifier () { + throw [System.NotImplementedException]::new("$($this.GetType().Name) must override identifier()") + } + + [string] ToString() { + return $this.GetType().Name + } +} \ No newline at end of file From 9a2529c6176449bdc2511b7208e94e18a5aef442 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:25:40 -0500 Subject: [PATCH 02/11] module path in tests change module path so we can run from /tests/ --- tests/run.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/run.ps1 b/tests/run.ps1 index 8c4b5fd..e6eafba 100644 --- a/tests/run.ps1 +++ b/tests/run.ps1 @@ -1,6 +1,6 @@ [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Target = "variablename")] Param([String]$tag, [string]$kind = 'potato') -Import-Module .\lib\Voicemeeter.psm1 +Import-Module (Join-Path (Split-Path $PSScriptRoot -Parent) 'lib\Voicemeeter.psm1') -Force function main() { From b0a6bf7b63e32f42f416ebe032fc470be26cdbf2 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:32:27 -0500 Subject: [PATCH 03/11] nullable index make index nullable so ToString can append the index for indexed objects --- lib/iremote.ps1 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/iremote.ps1 b/lib/iremote.ps1 index 735dcb9..e49ae25 100644 --- a/lib/iremote.ps1 +++ b/lib/iremote.ps1 @@ -1,5 +1,5 @@ class IRemote { - [int]$index + [Nullable[int]]$index [Object]$remote IRemote ([Object]$remote) { @@ -44,6 +44,9 @@ class IRemote { } [string] ToString() { + if ($this.index.HasValue) { + return $this.GetType().Name + $this.index + } return $this.GetType().Name } } \ No newline at end of file From 09d8bd48eb3659a2a81e8c16bbd669b5b4edc520 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:35:00 -0500 Subject: [PATCH 04/11] bus implement iremote --- lib/bus.ps1 | 50 +++++++------------------------------------------- 1 file changed, 7 insertions(+), 43 deletions(-) diff --git a/lib/bus.ps1 b/lib/bus.ps1 index d6dba01..d59cdee 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -1,40 +1,4 @@ -class IBus { - [int]$index - [Object]$remote - - IBus ([int]$index, [Object]$remote) { - $this.index = $index - $this.remote = $remote - } - - [string] identifier () { - return 'Bus[' + $this.index + ']' - } - - [single] Getter ($param) { - $this.ToString() + " Getter: $($this.Cmd($param))" | Write-Debug - return $this.remote.Getter($this.Cmd($param)) - } - - [string] Getter_String ($param) { - $this.ToString() + " Getter_String: $($this.Cmd($param))" | Write-Debug - return $this.remote.Getter_String($this.Cmd($param)) - } - - [void] Setter ($param, $val) { - $this.ToString() + " Setter: $($this.Cmd($param))=$val" | Write-Debug - $this.remote.Setter($this.Cmd($param), $val) - } - - [string] Cmd ($param) { - if ([string]::IsNullOrEmpty($param)) { - return $this.identifier() - } - return "$($this.identifier()).$param" - } -} - -class Bus : IBus { +class Bus : IRemote { [Object]$mode [Object]$eq [Object]$levels @@ -49,8 +13,8 @@ class Bus : IBus { $this.levels = [BusLevels]::new($index, $remote) } - [string] ToString() { - return $this.GetType().Name + $this.index + [string] identifier () { + return 'Bus[' + $this.index + ']' } [void] FadeTo ([single]$target, [int]$time) { @@ -62,7 +26,7 @@ class Bus : IBus { } } -class BusLevels : IBus { +class BusLevels : IRemote { [int]$init [int]$offset @@ -93,7 +57,7 @@ class BusLevels : IBus { } } -class BusMode : IBus { +class BusMode : IRemote { [System.Collections.ArrayList]$modes BusMode ([int]$index, [Object]$remote) : base ($index, $remote) { @@ -119,7 +83,7 @@ class BusMode : IBus { } } -class BusEq : IBus { +class BusEq : IRemote { BusEq ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('on', 'ab') } @@ -137,7 +101,7 @@ class PhysicalBus : Bus { } } -class BusDevice : IBus { +class BusDevice : IRemote { BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { } From eeb30925fa543ff798ffa726e043e5f887f3687c Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:40:15 -0500 Subject: [PATCH 05/11] command implement iremote --- lib/command.ps1 | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/lib/command.ps1 b/lib/command.ps1 index 891fc38..94192c1 100644 --- a/lib/command.ps1 +++ b/lib/command.ps1 @@ -1,33 +1,12 @@ -class Special { - [Object]$remote - +class Special : IRemote { Special ([Object]$remote) { AddActionMembers -PARAMS @('restart', 'shutdown', 'show') - - $this.remote = $remote } [string] identifier () { return 'Command' } - [string] ToString() { - return $this.GetType().Name - } - - [single] Getter ($param) { - return $this.remote.Getter("$($this.identifier()).$param") - } - - [void] Setter ($param, $val) { - if ($val -is [Boolean]) { - $this.remote.Setter("$($this.identifier()).$param", $(if ($val) { 1 } else { 0 })) - } - else { - $this.remote.Setter("$($this.identifier()).$param", $val) - } - } - [void] RunMacrobuttons() { 'Launching the MacroButtons app' | Write-Verbose Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath 'VoicemeeterMacroButtons.exe') From b372cf8087060f0e77001afd27946127a93d7183 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 15:59:39 -0500 Subject: [PATCH 06/11] Update command.ps1 forgot to pass to base --- lib/command.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/command.ps1 b/lib/command.ps1 index 94192c1..4f1e3c3 100644 --- a/lib/command.ps1 +++ b/lib/command.ps1 @@ -1,5 +1,5 @@ class Special : IRemote { - Special ([Object]$remote) { + Special ([Object]$remote) : base ($remote) { AddActionMembers -PARAMS @('restart', 'shutdown', 'show') } From a6f7d8efe0b8db3e4d60533c7683e9cb288c8034 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:04:42 -0500 Subject: [PATCH 07/11] recorder implement iremote --- lib/recorder.ps1 | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/lib/recorder.ps1 b/lib/recorder.ps1 index e87cd27..c8d95dd 100644 --- a/lib/recorder.ps1 +++ b/lib/recorder.ps1 @@ -1,35 +1,4 @@ -class IRecorder { - [Object]$remote - - IRecorder ([Object]$remote) { - $this.remote = $remote - } - - [single] Getter ($param) { - $this.Cmd($param) | Write-Debug - return $this.remote.Getter($this.Cmd($param)) - } - - [void] Setter ($param, $val) { - "$($this.Cmd($param))=$val" | Write-Debug - if ($val -is [Boolean]) { - $this.remote.Setter($this.Cmd($param), $(if ($val) { 1 } else { 0 })) - } - else { - $this.remote.Setter($this.Cmd($param), $val) - } - } - - [string] Cmd ($param) { - if ([string]::IsNullOrEmpty($param)) { - return $this.identifier() - } - return "$($this.identifier()).$param" - } -} - -class Recorder : IRecorder { - [Object]$remote +class Recorder : IRemote { [Object]$mode [System.Collections.ArrayList]$armstrip [System.Collections.ArrayList]$armbus @@ -54,10 +23,6 @@ class Recorder : IRecorder { return 'Recorder' } - [string] ToString() { - return $this.GetType().Name - } - hidden $_loop = $($this | Add-Member ScriptProperty 'loop' ` { [bool]$this.mode.loop @@ -160,7 +125,7 @@ class Recorder : IRecorder { } } -class RecorderMode : IRecorder { +class RecorderMode : IRemote { RecorderMode ([Object]$remote) : base ($remote) { AddBoolMembers -PARAMS @('recbus', 'playonload', 'loop', 'multitrack') } @@ -170,11 +135,8 @@ class RecorderMode : IRecorder { } } -class RecorderArm : IRecorder { - [int]$index - - RecorderArm ([int]$index, [Object]$remote) : base ($remote) { - $this.index = $index +class RecorderArm : IRemote { + RecorderArm ([int]$index, [Object]$remote) : base ($index, $remote) { } Set ([bool]$val) { From 62d9e89b5f45120455480f81f43201b9c9ec9b84 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:33:04 -0500 Subject: [PATCH 08/11] strip implement iremote --- lib/strip.ps1 | 54 +++++++++------------------------------------------ 1 file changed, 9 insertions(+), 45 deletions(-) diff --git a/lib/strip.ps1 b/lib/strip.ps1 index 52e75de..2c0821e 100644 --- a/lib/strip.ps1 +++ b/lib/strip.ps1 @@ -1,40 +1,4 @@ -class IStrip { - [int]$index - [Object]$remote - - IStrip ([int]$index, [Object]$remote) { - $this.index = $index - $this.remote = $remote - } - - [string] identifier () { - return 'Strip[' + $this.index + ']' - } - - [single] Getter ($param) { - $this.Cmd($param) | Write-Debug - return $this.remote.Getter($this.Cmd($param)) - } - - [string] Getter_String ($param) { - $this.Cmd($param) | Write-Debug - return $this.remote.Getter_String($this.Cmd($param)) - } - - [void] Setter ($param, $val) { - "$($this.Cmd($param))=$val" | Write-Debug - $this.remote.Setter($this.Cmd($param), $val) - } - - [string] Cmd ($param) { - if ([string]::IsNullOrEmpty($param)) { - return $this.identifier() - } - return "$($this.identifier()).$param" - } -} - -class Strip : IStrip { +class Strip : IRemote { [Object]$levels Strip ([int]$index, [Object]$remote) : base ($index, $remote) { @@ -49,8 +13,8 @@ class Strip : IStrip { $this.levels = [StripLevels]::new($index, $remote) } - [string] ToString() { - return $this.GetType().Name + $this.index + [string] identifier () { + return 'Strip[' + $this.index + ']' } [void] FadeTo ([single]$target, [int]$time) { @@ -62,7 +26,7 @@ class Strip : IStrip { } } -class StripLevels : IStrip { +class StripLevels : IRemote { [int]$init [int]$offset @@ -128,7 +92,7 @@ class PhysicalStrip : Strip { } } -class StripComp : IStrip { +class StripComp : IRemote { StripComp ([int]$index, [Object]$remote) : base ($index, $remote) { AddFloatMembers -PARAMS @('gainin', 'ratio', 'threshold', 'attack', 'release', 'knee', 'gainout') AddBoolMembers -PARAMS @('makeup') @@ -149,7 +113,7 @@ class StripComp : IStrip { ) } -class StripGate : IStrip { +class StripGate : IRemote { StripGate ([int]$index, [Object]$remote) : base ($index, $remote) { AddFloatMembers -PARAMS @('threshold', 'damping', 'bpsidechain', 'attack', 'hold', 'release') } @@ -169,7 +133,7 @@ class StripGate : IStrip { ) } -class StripDenoiser : IStrip { +class StripDenoiser : IRemote { StripDenoiser ([int]$index, [Object]$remote) : base ($index, $remote) { } @@ -188,7 +152,7 @@ class StripDenoiser : IStrip { ) } -class StripEq : IStrip { +class StripEq : IRemote { StripEq ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('on', 'ab') } @@ -198,7 +162,7 @@ class StripEq : IStrip { } } -class StripDevice : IStrip { +class StripDevice : IRemote { StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { } From 78f7fc80d4f607f4c175d12e0a8bcae3d105f9f3 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:39:44 -0500 Subject: [PATCH 09/11] vban implement iremote --- lib/vban.ps1 | 40 +++------------------------------------- 1 file changed, 3 insertions(+), 37 deletions(-) diff --git a/lib/vban.ps1 b/lib/vban.ps1 index 60ce9ef..ed6fb55 100644 --- a/lib/vban.ps1 +++ b/lib/vban.ps1 @@ -1,11 +1,7 @@ -class IVban { - [int32]$index - [Object]$remote +class Vban : IRemote { [string]$direction - - IVban ([int]$index, [Object]$remote, [string]$direction) { - $this.index = $index - $this.remote = $remote + + Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote) { $this.direction = $direction } @@ -13,36 +9,6 @@ class IVban { return 'vban.' + $this.direction + 'stream[' + $this.index + ']' } - [single] Getter ($param) { - return $this.remote.Getter($this.Cmd($param)) - } - - [string] Getter_String ($param) { - $this.Cmd($param) | Write-Debug - return $this.remote.Getter_String($this.Cmd($param)) - } - - [void] Setter ($param, $val) { - "$($this.Cmd($param))=$val" | Write-Debug - $this.remote.Setter($this.Cmd($param), $val) - } - - [string] Cmd ($param) { - if ([string]::IsNullOrEmpty($param)) { - return $this.identifier() - } - return "$($this.identifier()).$param" - } -} - -class Vban : IVban { - Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote, $direction) { - } - - [string] ToString() { - return $this.GetType().Name + $this.index - } - hidden $_on = $($this | Add-Member ScriptProperty 'on' ` { $this.Getter('on') From e5137b842bccb601dfd588fea911cd0728d881fb Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 16:44:16 -0500 Subject: [PATCH 10/11] Update CHANGELOG.md --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25bfbae..6cfe68d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,9 @@ Before any major/minor/patch is released all test units will be run to verify th ## [Unreleased] These changes have not been added to PSGallery yet -- [ ] +### Added + +- IRemote base class ## [3.3.0] - 2024-06-29 From 5fc5680c75e26350be8440322c055e786aece7a9 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Tue, 25 Nov 2025 21:29:45 -0500 Subject: [PATCH 11/11] fix ToString --- lib/iremote.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/iremote.ps1 b/lib/iremote.ps1 index e49ae25..31a4d95 100644 --- a/lib/iremote.ps1 +++ b/lib/iremote.ps1 @@ -44,7 +44,7 @@ class IRemote { } [string] ToString() { - if ($this.index.HasValue) { + if ($null -ne $this.index) { return $this.GetType().Name + $this.index } return $this.GetType().Name