mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-12-05 05:07:47 +00:00
Merge pull request #7 from pblivingston/iremote
Add IRemote abstract base class.
This commit is contained in:
commit
4d54e0a15f
@ -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
|
## [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
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
. $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
|
||||||
|
|||||||
50
lib/bus.ps1
50
lib/bus.ps1
@ -1,40 +1,4 @@
|
|||||||
class IBus {
|
class Bus : IRemote {
|
||||||
[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
|
||||||
@ -49,8 +13,8 @@ class Bus : IBus {
|
|||||||
$this.levels = [BusLevels]::new($index, $remote)
|
$this.levels = [BusLevels]::new($index, $remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] ToString() {
|
[string] identifier () {
|
||||||
return $this.GetType().Name + $this.index
|
return 'Bus[' + $this.index + ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] FadeTo ([single]$target, [int]$time) {
|
[void] FadeTo ([single]$target, [int]$time) {
|
||||||
@ -62,7 +26,7 @@ class Bus : IBus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BusLevels : IBus {
|
class BusLevels : IRemote {
|
||||||
[int]$init
|
[int]$init
|
||||||
[int]$offset
|
[int]$offset
|
||||||
|
|
||||||
@ -93,7 +57,7 @@ class BusLevels : IBus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BusMode : IBus {
|
class BusMode : IRemote {
|
||||||
[System.Collections.ArrayList]$modes
|
[System.Collections.ArrayList]$modes
|
||||||
|
|
||||||
BusMode ([int]$index, [Object]$remote) : base ($index, $remote) {
|
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) {
|
BusEq ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
AddBoolMembers -PARAMS @('on', 'ab')
|
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) {
|
BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,33 +1,12 @@
|
|||||||
class Special {
|
class Special : IRemote {
|
||||||
[Object]$remote
|
Special ([Object]$remote) : base ($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')
|
||||||
|
|||||||
52
lib/iremote.ps1
Normal file
52
lib/iremote.ps1
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,35 +1,4 @@
|
|||||||
class IRecorder {
|
class Recorder : IRemote {
|
||||||
[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
|
||||||
@ -54,10 +23,6 @@ class Recorder : IRecorder {
|
|||||||
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
|
||||||
@ -160,7 +125,7 @@ class Recorder : IRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecorderMode : IRecorder {
|
class RecorderMode : IRemote {
|
||||||
RecorderMode ([Object]$remote) : base ($remote) {
|
RecorderMode ([Object]$remote) : base ($remote) {
|
||||||
AddBoolMembers -PARAMS @('recbus', 'playonload', 'loop', 'multitrack')
|
AddBoolMembers -PARAMS @('recbus', 'playonload', 'loop', 'multitrack')
|
||||||
}
|
}
|
||||||
@ -170,11 +135,8 @@ class RecorderMode : IRecorder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecorderArm : IRecorder {
|
class RecorderArm : IRemote {
|
||||||
[int]$index
|
RecorderArm ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
|
|
||||||
RecorderArm ([int]$index, [Object]$remote) : base ($remote) {
|
|
||||||
$this.index = $index
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Set ([bool]$val) {
|
Set ([bool]$val) {
|
||||||
|
|||||||
@ -1,40 +1,4 @@
|
|||||||
class IStrip {
|
class Strip : IRemote {
|
||||||
[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) {
|
||||||
@ -49,8 +13,8 @@ class Strip : IStrip {
|
|||||||
$this.levels = [StripLevels]::new($index, $remote)
|
$this.levels = [StripLevels]::new($index, $remote)
|
||||||
}
|
}
|
||||||
|
|
||||||
[string] ToString() {
|
[string] identifier () {
|
||||||
return $this.GetType().Name + $this.index
|
return 'Strip[' + $this.index + ']'
|
||||||
}
|
}
|
||||||
|
|
||||||
[void] FadeTo ([single]$target, [int]$time) {
|
[void] FadeTo ([single]$target, [int]$time) {
|
||||||
@ -62,7 +26,7 @@ class Strip : IStrip {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StripLevels : IStrip {
|
class StripLevels : IRemote {
|
||||||
[int]$init
|
[int]$init
|
||||||
[int]$offset
|
[int]$offset
|
||||||
|
|
||||||
@ -128,7 +92,7 @@ class PhysicalStrip : Strip {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StripComp : IStrip {
|
class StripComp : IRemote {
|
||||||
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')
|
||||||
@ -149,7 +113,7 @@ class StripComp : IStrip {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class StripGate : IStrip {
|
class StripGate : IRemote {
|
||||||
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')
|
||||||
}
|
}
|
||||||
@ -169,7 +133,7 @@ class StripGate : IStrip {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
class StripDenoiser : IStrip {
|
class StripDenoiser : IRemote {
|
||||||
StripDenoiser ([int]$index, [Object]$remote) : base ($index, $remote) {
|
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) {
|
StripEq ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
AddBoolMembers -PARAMS @('on', 'ab')
|
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) {
|
StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
40
lib/vban.ps1
40
lib/vban.ps1
@ -1,11 +1,7 @@
|
|||||||
class IVban {
|
class Vban : IRemote {
|
||||||
[int32]$index
|
|
||||||
[Object]$remote
|
|
||||||
[string]$direction
|
[string]$direction
|
||||||
|
|
||||||
IVban ([int]$index, [Object]$remote, [string]$direction) {
|
Vban ([int]$index, [Object]$remote, [string]$direction) : base ($index, $remote) {
|
||||||
$this.index = $index
|
|
||||||
$this.remote = $remote
|
|
||||||
$this.direction = $direction
|
$this.direction = $direction
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13,36 +9,6 @@ class IVban {
|
|||||||
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')
|
||||||
|
|||||||
@ -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 .\lib\Voicemeeter.psm1
|
Import-Module (Join-Path (Split-Path $PSScriptRoot -Parent) 'lib\Voicemeeter.psm1') -Force
|
||||||
|
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user