From bee52b65414359a6552c4efd6236827d9814317e Mon Sep 17 00:00:00 2001 From: onyx-and-iris Date: Sat, 12 Aug 2023 01:40:29 +0100 Subject: [PATCH] rename some of the internal classes RecorderMode class added to Recorder RunMacrobuttons() and CloseMacrobuttons() added to Special (Command) --- lib/binding.ps1 | 2 +- lib/bus.ps1 | 26 +++++++++++----------- lib/command.ps1 | 9 ++++++++ lib/inst.ps1 | 2 +- lib/recorder.ps1 | 52 ++++++++++++++++++++++++++++++-------------- lib/strip.ps1 | 36 +++++++++++++++--------------- tests/pre-commit.ps1 | 1 + 7 files changed, 79 insertions(+), 49 deletions(-) diff --git a/lib/binding.ps1 b/lib/binding.ps1 index ad23456..83fe3cf 100644 --- a/lib/binding.ps1 +++ b/lib/binding.ps1 @@ -1,6 +1,6 @@ function Setup_DLL { try { - $vb_path = Get_VBPath + $vb_path = Get_VMPath if ([string]::IsNullOrWhiteSpace($vb_path)) { throw [VMRemoteError]::new("couldn't get Voicemeeter path") diff --git a/lib/bus.ps1 b/lib/bus.ps1 index ba2c9f0..8bd6704 100644 --- a/lib/bus.ps1 +++ b/lib/bus.ps1 @@ -40,9 +40,9 @@ class Bus : IBus { AddStringMembers -PARAMS @('label') AddFloatMembers -PARAMS @('gain', 'returnreverb', 'returndelay', 'returnfx1', 'returnfx2') - $this.mode = [Mode]::new($index, $remote) - $this.eq = [Eq]::new($index, $remote) - $this.levels = [Levels]::new($index, $remote) + $this.mode = [BusMode]::new($index, $remote) + $this.eq = [BusEq]::new($index, $remote) + $this.levels = [BusLevels]::new($index, $remote) } [void] FadeTo ([single]$target, [int]$time) { @@ -54,11 +54,11 @@ class Bus : IBus { } } -class Levels : IBus { +class BusLevels : IBus { [int]$init [int]$offset - Levels ([int]$index, [Object]$remote) : base ($index, $remote) { + BusLevels ([int]$index, [Object]$remote) : base ($index, $remote) { $this.init = $index * 8 $this.offset = 8 } @@ -68,7 +68,7 @@ class Levels : IBus { return [math]::Round(20 * [math]::Log10($val), 1) } else { - return -200.0 + return - 200.0 } } @@ -85,10 +85,10 @@ class Levels : IBus { } } -class Mode : IBus { +class BusMode : IBus { [System.Collections.ArrayList]$modes - Mode ([int]$index, [Object]$remote) : base ($index, $remote) { + BusMode ([int]$index, [Object]$remote) : base ($index, $remote) { $this.modes = @( 'normal', 'amix', 'bmix', 'repeat', 'composite', 'tvmix', 'upmix21', 'upmix41', 'upmix61', 'centeronly', 'lfeonly', 'rearonly' @@ -111,8 +111,8 @@ class Mode : IBus { } } -class Eq : IBus { - Eq ([int]$index, [Object]$remote) : base ($index, $remote) { +class BusEq : IBus { + BusEq ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('on', 'ab') } @@ -125,12 +125,12 @@ class PhysicalBus : Bus { [Object]$device PhysicalBus ([int]$index, [Object]$remote) : base ($index, $remote) { - $this.device = [Device]::new($index, $remote) + $this.device = [BusDevice]::new($index, $remote) } } -class Device : IBus { - Device ([int]$index, [Object]$remote) : base ($index, $remote) { +class BusDevice : IBus { + BusDevice ([int]$index, [Object]$remote) : base ($index, $remote) { } [string] identifier () { diff --git a/lib/command.ps1 b/lib/command.ps1 index 8067d78..6df83c9 100644 --- a/lib/command.ps1 +++ b/lib/command.ps1 @@ -1,4 +1,5 @@ . $PSScriptRoot\meta.ps1 +. $PSScriptRoot\inst.ps1 class Special { Special () { @@ -26,6 +27,14 @@ class Special { } } + [void] RunMacrobuttons() { + Start-Process -FilePath $(Join-Path -Path $(Get_VMPath) -ChildPath "VoicemeeterMacroButtons.exe") + } + + [void] CloseMacrobuttons() { + Stop-Process -Name "VoicemeeterMacroButtons" + } + hidden $_hide = $($this | Add-Member ScriptProperty 'hide' ` { $this._hide = $this.Setter('show', $false) diff --git a/lib/inst.ps1 b/lib/inst.ps1 index d9a69a4..93f0e5b 100644 --- a/lib/inst.ps1 +++ b/lib/inst.ps1 @@ -1,4 +1,4 @@ -function Get_VBPath { +function Get_VMPath { $reg_path = "Registry::HKEY_LOCAL_MACHINE\Software" + ` (& { if ([Environment]::Is64BitOperatingSystem) { "\WOW6432Node" } else { "" } }) + ` "\Microsoft\Windows\CurrentVersion\Uninstall" diff --git a/lib/recorder.ps1 b/lib/recorder.ps1 index a1fa76a..661b623 100644 --- a/lib/recorder.ps1 +++ b/lib/recorder.ps1 @@ -1,21 +1,10 @@ . $PSScriptRoot\meta.ps1 -class Recorder { +class IRecorder { [Object]$remote - Recorder ([Object]$remote) { + IRecorder ([Object]$remote) { $this.remote = $remote - - AddActionMembers -PARAMS @('play', 'stop', 'pause', 'replay', 'record', 'ff', 'rew') - AddChannelMembers - } - - [string] identifier () { - return "Recorder" - } - - [string] ToString() { - return $this.GetType().Name } [single] Getter ($param) { @@ -29,15 +18,36 @@ class Recorder { else { Param_Set -PARAM "$($this.identifier()).$param" -Value $val } + } +} + +class Recorder : IRecorder { + [Object]$remote + [Object]$mode + + Recorder ([Object]$remote) : base ($remote) { + $this.remote = $remote + $this.mode = [RecorderMode]::new($remote) + + AddActionMembers -PARAMS @('play', 'stop', 'pause', 'replay', 'record', 'ff', 'rew') + AddChannelMembers + } + + [string] identifier () { + return "Recorder" + } + + [string] ToString() { + return $this.GetType().Name } hidden $_loop = $($this | Add-Member ScriptProperty 'loop' ` { - return Write-Warning ("ERROR: $($this.identifier()).mode.loop is write only") + [bool]$this.mode.loop } ` { - param([bool]$arg) - $this._loop = $this.Setter('mode.loop', $arg) + param($arg) + $this.mode.loop = $arg } ) @@ -46,6 +56,16 @@ class Recorder { } } +class RecorderMode : IRecorder { + RecorderMode ([Object]$remote) : base ($remote) { + AddBoolMembers -PARAMS @('loop') + } + + [string] identifier () { + return "Recorder.Mode" + } +} + function Make_Recorder ([Object]$remote) { return [Recorder]::new($remote) } diff --git a/lib/strip.ps1 b/lib/strip.ps1 index 3158855..398e0d3 100644 --- a/lib/strip.ps1 +++ b/lib/strip.ps1 @@ -38,7 +38,7 @@ class Strip : IStrip { AddChannelMembers AddGainlayerMembers - $this.levels = [Levels]::new($index, $remote) + $this.levels = [StripLevels]::new($index, $remote) } [string] ToString() { @@ -54,11 +54,11 @@ class Strip : IStrip { } } -class Levels : IStrip { +class StripLevels : IStrip { [int]$init [int]$offset - Levels ([int]$index, [Object]$remote) : base ($index, $remote) { + StripLevels ([int]$index, [Object]$remote) : base ($index, $remote) { $p_in = $remote.kind.p_in if ($index -lt $p_in) { $this.init = $index * 2 @@ -112,16 +112,16 @@ class PhysicalStrip : Strip { AddFloatMembers -PARAMS @('reverb', 'delay', 'fx1', 'fx2') AddBoolMembers -PARAMS @('postreverb', 'postdelay', 'postfx1', 'postfx2') - $this.comp = [Comp]::new($index, $remote) - $this.gate = [Gate]::new($index, $remote) - $this.denoiser = [Denoiser]::new($index, $remote) - $this.eq = [Eq]::new($index, $remote) - $this.device = [Device]::new($index, $remote) + $this.comp = [StripComp]::new($index, $remote) + $this.gate = [StripGate]::new($index, $remote) + $this.denoiser = [StripDenoiser]::new($index, $remote) + $this.eq = [StripEq]::new($index, $remote) + $this.device = [StripDevice]::new($index, $remote) } } -class Comp : IStrip { - Comp ([int]$index, [Object]$remote) : base ($index, $remote) { +class StripComp : IStrip { + StripComp ([int]$index, [Object]$remote) : base ($index, $remote) { AddFloatMembers -PARAMS @('gainin', 'ratio', 'threshold', 'attack', 'release', 'knee', 'gainout') AddBoolMembers -PARAMS @('makeup') } @@ -141,8 +141,8 @@ class Comp : IStrip { ) } -class Gate : IStrip { - Gate ([int]$index, [Object]$remote) : base ($index, $remote) { +class StripGate : IStrip { + StripGate ([int]$index, [Object]$remote) : base ($index, $remote) { AddFloatMembers -PARAMS @('threshold', 'damping', 'bpsidechain', 'attack', 'hold', 'release') } @@ -161,8 +161,8 @@ class Gate : IStrip { ) } -class Denoiser : IStrip { - Denoiser ([int]$index, [Object]$remote) : base ($index, $remote) { +class StripDenoiser : IStrip { + StripDenoiser ([int]$index, [Object]$remote) : base ($index, $remote) { } [string] identifier () { @@ -180,8 +180,8 @@ class Denoiser : IStrip { ) } -class Eq : IStrip { - Eq ([int]$index, [Object]$remote) : base ($index, $remote) { +class StripEq : IStrip { + StripEq ([int]$index, [Object]$remote) : base ($index, $remote) { AddBoolMembers -PARAMS @('on', 'ab') } @@ -190,8 +190,8 @@ class Eq : IStrip { } } -class Device : IStrip { - Device ([int]$index, [Object]$remote) : base ($index, $remote) { +class StripDevice : IStrip { + StripDevice ([int]$index, [Object]$remote) : base ($index, $remote) { } [string] identifier () { diff --git a/tests/pre-commit.ps1 b/tests/pre-commit.ps1 index fe4365c..f652f9c 100644 --- a/tests/pre-commit.ps1 +++ b/tests/pre-commit.ps1 @@ -34,6 +34,7 @@ Function ParseLog { function main() { try { $vmr = Connect-Voicemeeter -Kind $kind + $vmr.command.RunMacrobuttons() # ensure macrobuttons is running before we begin Write-Host "Running tests for $vmr" # test boundaries by kind