From df86ad2175c3c3c4cf6be3ae7936cdc9189622e0 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Thu, 4 Dec 2025 00:12:37 -0500 Subject: [PATCH] prefix, filetype changed to write-only properties pester tests pass for all kinds --- CHANGELOG.md | 3 ++- README.md | 4 ++-- lib/recorder.ps1 | 44 +++++++++++++++++++++++++++--------------- tests/higher.Tests.ps1 | 8 ++++---- tests/run.ps1 | 4 ++-- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 462d961..a2e8e9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ AddActionMembers now adds ScriptMethods instead of ScriptProperties: - See Recorder section of README for details on using playback/record actions Deprecated Recorder.Loop removed: use Recorder.Mode.Loop +Recorder.FileType changed from method to write-only property ### Added @@ -35,7 +36,7 @@ Deprecated Recorder.Loop removed: use Recorder.Mode.Loop - Bus.Mode.Set($mode) - Recorder.Armedbus - Recorder.PreRecTime -- Recorder.Prefix($prefix) +- Recorder.Prefix - Recorder.Eject() references 'Command.Eject' - Recorder.State diff --git a/README.md b/README.md index 14b8668..8adc862 100644 --- a/README.md +++ b/README.md @@ -531,6 +531,8 @@ The following commands are available: - armedbus: int, from 0 to bus index - state: string, ('play', 'stop', 'record', 'pause') - prerectime: int, from 0 to 20 seconds +- prefix: string, write-only +- filetype: string, write-only, ('wav', 'aiff', 'bwf', 'mp3') - samplerate: int, (22050, 24000, 32000, 44100, 48000, 88200, 96000, 176400, 192000) - bitresolution: int, (8, 16, 24, 32) - channel: int, (2, 4, 6, 8) @@ -548,8 +550,6 @@ The following methods are available: - Eject() - Load($filepath): string - GoTo($timestring): string, must match the format 'hh:mm:ss' -- FileType($format): string, ('wav', 'aiff', 'bwf', 'mp3') -- Prefix($prefix): string example: diff --git a/lib/recorder.ps1 b/lib/recorder.ps1 index 1d688bd..b07c611 100644 --- a/lib/recorder.ps1 +++ b/lib/recorder.ps1 @@ -41,22 +41,6 @@ class Recorder : IRemote { $this.Setter('load', $filename) } - [void] Prefix ([string]$prefix) { - $this.Setter('prefix', $prefix) - } - - [void] FileType([string]$format) { - [int]$val = 0 - switch ($format) { - 'wav' { $val = 1 } - 'aiff' { $val = 2 } - 'bwf' { $val = 3 } - 'mp3' { $val = 100 } - default { "Filetype() got: $format, expected one of 'wav', 'aiff', 'bwf', 'mp3'" } - } - $this.Setter('filetype', $val) - } - [void] GoTo ([string]$timestring) { try { if ([datetime]::ParseExact($timestring, 'HH:mm:ss', $null)) { @@ -133,6 +117,34 @@ class Recorder : IRemote { } ) + hidden $_prefix = $($this | Add-Member ScriptProperty 'prefix' ` + { + return Write-Warning ("ERROR: $($this.identifier()).prefix is write only") + } ` + { + param([string]$arg) + $this._prefix = $this.Setter('prefix', $arg) + } + ) + + hidden $_filetype = $($this | Add-Member ScriptProperty 'filetype' ` + { + return Write-Warning ("ERROR: $($this.identifier()).filetype is write only") + } ` + { + param([string]$arg) + [int]$val = 0 + switch ($arg) { + 'wav' { $val = 1 } + 'aiff' { $val = 2 } + 'bwf' { $val = 3 } + 'mp3' { $val = 100 } + default { "Filetype() got: $arg, expected one of 'wav', 'aiff', 'bwf', 'mp3'" } + } + $this._filetype = $this.Setter('filetype', $val) + } + ) + hidden $_armedbus = $($this | Add-Member ScriptProperty 'armedbus' ` { foreach ($bus in 0..$($this.remote.kind.p_out + $this.remote.kind.v_out - 1)) { diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index a787e05..02f8e38 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -910,8 +910,8 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { try { $prefix = 'stringtest' $filetype = 'wav' - $vmr.recorder.prefix($prefix) - $vmr.recorder.filetype($filetype) + $vmr.recorder.prefix = $prefix + $vmr.recorder.filetype = $filetype $vmr.recorder.state = 'record' $stamp = '{0:yyyy-MM-dd} at {0:HH}h{0:mm}m{0:ss}s' -f (Get-Date) @@ -956,8 +956,8 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { BeforeAll { $prefix = 'actiontest' $filetype = 'wav' - $vmr.recorder.prefix($prefix) - $vmr.recorder.filetype($filetype) + $vmr.recorder.prefix = $prefix + $vmr.recorder.filetype = $filetype } BeforeEach { diff --git a/tests/run.ps1 b/tests/run.ps1 index 74b1cc3..ebf19fe 100644 --- a/tests/run.ps1 +++ b/tests/run.ps1 @@ -6,8 +6,8 @@ Import-Module (Join-Path (Split-Path $PSScriptRoot -Parent) 'lib\Voicemeeter.psm function Test-RecDir ([object]$vmr, [string]$recDir) { $prefix = 'temp' $filetype = 'wav' - $vmr.recorder.prefix($prefix) - $vmr.recorder.filetype($filetype) + $vmr.recorder.prefix = $prefix + $vmr.recorder.filetype = $filetype try {