Compare commits

..

No commits in common. "4d54e0a15fa73fda68b639d233068515e7f4d284" and "bd0779add2d6acf87b1eb3aff1f8d3770fb71b12" have entirely different histories.

9 changed files with 192 additions and 82 deletions

View File

@ -9,9 +9,7 @@ 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 ## [Unreleased] These changes have not been added to PSGallery yet
### Added - [ ]
- IRemote base class
## [3.3.0] - 2024-06-29 ## [3.3.0] - 2024-06-29

View File

@ -2,7 +2,6 @@
. $PSScriptRoot\meta.ps1 . $PSScriptRoot\meta.ps1
. $PSScriptRoot\base.ps1 . $PSScriptRoot\base.ps1
. $PSScriptRoot\kinds.ps1 . $PSScriptRoot\kinds.ps1
. $PSScriptRoot\iremote.ps1
. $PSScriptRoot\strip.ps1 . $PSScriptRoot\strip.ps1
. $PSScriptRoot\bus.ps1 . $PSScriptRoot\bus.ps1
. $PSScriptRoot\macrobuttons.ps1 . $PSScriptRoot\macrobuttons.ps1

View File

@ -1,4 +1,40 @@
class Bus : IRemote { 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 {
[Object]$mode [Object]$mode
[Object]$eq [Object]$eq
[Object]$levels [Object]$levels
@ -13,8 +49,8 @@ class Bus : IRemote {
$this.levels = [BusLevels]::new($index, $remote) $this.levels = [BusLevels]::new($index, $remote)
} }
[string] identifier () { [string] ToString() {
return 'Bus[' + $this.index + ']' return $this.GetType().Name + $this.index
} }
[void] FadeTo ([single]$target, [int]$time) { [void] FadeTo ([single]$target, [int]$time) {
@ -26,7 +62,7 @@ class Bus : IRemote {
} }
} }
class BusLevels : IRemote { class BusLevels : IBus {
[int]$init [int]$init
[int]$offset [int]$offset
@ -57,7 +93,7 @@ class BusLevels : IRemote {
} }
} }
class BusMode : IRemote { class BusMode : IBus {
[System.Collections.ArrayList]$modes [System.Collections.ArrayList]$modes
BusMode ([int]$index, [Object]$remote) : base ($index, $remote) { BusMode ([int]$index, [Object]$remote) : base ($index, $remote) {
@ -83,7 +119,7 @@ class BusMode : IRemote {
} }
} }
class BusEq : IRemote { class BusEq : IBus {
BusEq ([int]$index, [Object]$remote) : base ($index, $remote) { BusEq ([int]$index, [Object]$remote) : base ($index, $remote) {
AddBoolMembers -PARAMS @('on', 'ab') AddBoolMembers -PARAMS @('on', 'ab')
} }
@ -101,7 +137,7 @@ class PhysicalBus : Bus {
} }
} }
class BusDevice : IRemote { class BusDevice : IBus {
BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
} }

View File

@ -1,12 +1,33 @@
class Special : IRemote { class Special {
Special ([Object]$remote) : base ($remote) { [Object]$remote
Special ([Object]$remote) {
AddActionMembers -PARAMS @('restart', 'shutdown', 'show') AddActionMembers -PARAMS @('restart', 'shutdown', 'show')
$this.remote = $remote
} }
[string] identifier () { [string] identifier () {
return 'Command' 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() { [void] RunMacrobuttons() {
'Launching the MacroButtons app' | Write-Verbose 'Launching the MacroButtons app' | Write-Verbose
Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath 'VoicemeeterMacroButtons.exe') Start-Process -FilePath $(Join-Path -Path $this.remote.vmpath -ChildPath 'VoicemeeterMacroButtons.exe')

View File

@ -1,52 +0,0 @@
class IRemote {
[Nullable[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() {
if ($null -ne $this.index) {
return $this.GetType().Name + $this.index
}
return $this.GetType().Name
}
}

View File

@ -1,4 +1,35 @@
class Recorder : IRemote { 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
[Object]$mode [Object]$mode
[System.Collections.ArrayList]$armstrip [System.Collections.ArrayList]$armstrip
[System.Collections.ArrayList]$armbus [System.Collections.ArrayList]$armbus
@ -23,6 +54,10 @@ class Recorder : IRemote {
return 'Recorder' return 'Recorder'
} }
[string] ToString() {
return $this.GetType().Name
}
hidden $_loop = $($this | Add-Member ScriptProperty 'loop' ` hidden $_loop = $($this | Add-Member ScriptProperty 'loop' `
{ {
[bool]$this.mode.loop [bool]$this.mode.loop
@ -125,7 +160,7 @@ class Recorder : IRemote {
} }
} }
class RecorderMode : IRemote { class RecorderMode : IRecorder {
RecorderMode ([Object]$remote) : base ($remote) { RecorderMode ([Object]$remote) : base ($remote) {
AddBoolMembers -PARAMS @('recbus', 'playonload', 'loop', 'multitrack') AddBoolMembers -PARAMS @('recbus', 'playonload', 'loop', 'multitrack')
} }
@ -135,8 +170,11 @@ class RecorderMode : IRemote {
} }
} }
class RecorderArm : IRemote { class RecorderArm : IRecorder {
RecorderArm ([int]$index, [Object]$remote) : base ($index, $remote) { [int]$index
RecorderArm ([int]$index, [Object]$remote) : base ($remote) {
$this.index = $index
} }
Set ([bool]$val) { Set ([bool]$val) {

View File

@ -1,4 +1,40 @@
class Strip : IRemote { 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 {
[Object]$levels [Object]$levels
Strip ([int]$index, [Object]$remote) : base ($index, $remote) { Strip ([int]$index, [Object]$remote) : base ($index, $remote) {
@ -13,8 +49,8 @@ class Strip : IRemote {
$this.levels = [StripLevels]::new($index, $remote) $this.levels = [StripLevels]::new($index, $remote)
} }
[string] identifier () { [string] ToString() {
return 'Strip[' + $this.index + ']' return $this.GetType().Name + $this.index
} }
[void] FadeTo ([single]$target, [int]$time) { [void] FadeTo ([single]$target, [int]$time) {
@ -26,7 +62,7 @@ class Strip : IRemote {
} }
} }
class StripLevels : IRemote { class StripLevels : IStrip {
[int]$init [int]$init
[int]$offset [int]$offset
@ -92,7 +128,7 @@ class PhysicalStrip : Strip {
} }
} }
class StripComp : IRemote { class StripComp : IStrip {
StripComp ([int]$index, [Object]$remote) : base ($index, $remote) { StripComp ([int]$index, [Object]$remote) : base ($index, $remote) {
AddFloatMembers -PARAMS @('gainin', 'ratio', 'threshold', 'attack', 'release', 'knee', 'gainout') AddFloatMembers -PARAMS @('gainin', 'ratio', 'threshold', 'attack', 'release', 'knee', 'gainout')
AddBoolMembers -PARAMS @('makeup') AddBoolMembers -PARAMS @('makeup')
@ -113,7 +149,7 @@ class StripComp : IRemote {
) )
} }
class StripGate : IRemote { class StripGate : IStrip {
StripGate ([int]$index, [Object]$remote) : base ($index, $remote) { StripGate ([int]$index, [Object]$remote) : base ($index, $remote) {
AddFloatMembers -PARAMS @('threshold', 'damping', 'bpsidechain', 'attack', 'hold', 'release') AddFloatMembers -PARAMS @('threshold', 'damping', 'bpsidechain', 'attack', 'hold', 'release')
} }
@ -133,7 +169,7 @@ class StripGate : IRemote {
) )
} }
class StripDenoiser : IRemote { class StripDenoiser : IStrip {
StripDenoiser ([int]$index, [Object]$remote) : base ($index, $remote) { StripDenoiser ([int]$index, [Object]$remote) : base ($index, $remote) {
} }
@ -152,7 +188,7 @@ class StripDenoiser : IRemote {
) )
} }
class StripEq : IRemote { class StripEq : IStrip {
StripEq ([int]$index, [Object]$remote) : base ($index, $remote) { StripEq ([int]$index, [Object]$remote) : base ($index, $remote) {
AddBoolMembers -PARAMS @('on', 'ab') AddBoolMembers -PARAMS @('on', 'ab')
} }
@ -162,7 +198,7 @@ class StripEq : IRemote {
} }
} }
class StripDevice : IRemote { class StripDevice : IStrip {
StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
} }

View File

@ -1,7 +1,11 @@
class Vban : IRemote { class IVban {
[int32]$index
[Object]$remote
[string]$direction [string]$direction
Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote) { IVban ([int]$index, [Object]$remote, [string]$direction) {
$this.index = $index
$this.remote = $remote
$this.direction = $direction $this.direction = $direction
} }
@ -9,6 +13,36 @@ class Vban : IRemote {
return 'vban.' + $this.direction + 'stream[' + $this.index + ']' 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' ` hidden $_on = $($this | Add-Member ScriptProperty 'on' `
{ {
$this.Getter('on') $this.Getter('on')

View File

@ -1,6 +1,6 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Target = "variablename")] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Target = "variablename")]
Param([String]$tag, [string]$kind = 'potato') Param([String]$tag, [string]$kind = 'potato')
Import-Module (Join-Path (Split-Path $PSScriptRoot -Parent) 'lib\Voicemeeter.psm1') -Force Import-Module .\lib\Voicemeeter.psm1
function main() { function main() {