From ab4baa5c440da9a3a823505860d13b56cb291e10 Mon Sep 17 00:00:00 2001 From: pblivingston <71585805+pblivingston@users.noreply.github.com> Date: Wed, 3 Dec 2025 03:31:30 -0500 Subject: [PATCH] remove loop, cleanup - removed deprecated recorder.loop - placed methods before hidden properties for readability - added a couple mode tests for good measure --- CHANGELOG.md | 2 + lib/recorder.ps1 | 105 +++++++++++++---------------------------- tests/higher.Tests.ps1 | 16 +++++-- 3 files changed, 48 insertions(+), 75 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8e35df..0d06cda 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ AddActionMembers now adds ScriptMethods instead of ScriptProperties: - See Command section of README for details on using special commands - See Recorder section of README for details on using playback/record actions +Deprecated Recorder.Loop removed: use Recorder.Mode.Loop + ### Added - IRemote base class diff --git a/lib/recorder.ps1 b/lib/recorder.ps1 index a5aa67a..24bda3e 100644 --- a/lib/recorder.ps1 +++ b/lib/recorder.ps1 @@ -33,15 +33,41 @@ class Recorder : IRemote { return 'Recorder' } - hidden $_loop = $($this | Add-Member ScriptProperty 'loop' ` - { - [bool]$this.mode.loop - } ` - { - param($arg) - $this.mode.loop = $arg + [void] Eject () { + $this.remote.Setter('Command.Eject', 1) + } + + [void] Load ([string]$filename) { + $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)) { + $timespan = [timespan]::Parse($timestring) + $this.Setter('GoTo', $timespan.TotalSeconds) + } + } + catch [FormatException] { + "Time string $timestring does not match the required format 'hh:mm:ss'" | Write-Warning + } + } hidden $_samplerate = $($this | Add-Member ScriptProperty 'samplerate' ` { @@ -150,42 +176,6 @@ class Recorder : IRemote { $this._state = $this.Setter($arg, 1) } ) - - [void] Load ([string]$filename) { - $this.Setter('load', $filename) - } - - [void] GoTo ([string]$timestring) { - try { - if ([datetime]::ParseExact($timestring, 'HH:mm:ss', $null)) { - $timespan = [timespan]::Parse($timestring) - $this.Setter('GoTo', $timespan.TotalSeconds) - } - } - catch [FormatException] { - "Time string $timestring does not match the required format 'hh:mm:ss'" | Write-Warning - } - } - - [void] FileType($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] Prefix ([string]$prefix) { - $this.Setter('prefix', $prefix) - } - - [void] Eject () { - $this.remote.Setter('Command.Eject', 1) - } } class RecorderMode : IRemote { @@ -198,33 +188,6 @@ class RecorderMode : IRemote { } } -class RecorderArm : IRemote { - RecorderArm ([int]$index, [Object]$remote) : base ($index, $remote) { - } - - Set ([bool]$val) { - $this.Setter('', $(if ($val) { 1 } else { 0 })) - } -} - -class RecorderArmStrip : RecorderArm { - RecorderArmStrip ([int]$index, [Object]$remote) : base ($index, $remote) { - } - - [string] identifier () { - return "Recorder.ArmStrip[$($this.index)]" - } -} - -class RecorderArmBus : RecorderArm { - RecorderArmBus ([int]$index, [Object]$remote) : base ($index, $remote) { - } - - [string] identifier () { - return "Recorder.ArmBus[$($this.index)]" - } -} - function Make_Recorder ([Object]$remote) { return [Recorder]::new($remote) } diff --git a/tests/higher.Tests.ps1 b/tests/higher.Tests.ps1 index 3a8a84c..1804098 100644 --- a/tests/higher.Tests.ps1 +++ b/tests/higher.Tests.ps1 @@ -157,10 +157,6 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { $vmr.recorder.B1 | Should -Be $expected } - It 'Should set and get Recorder.loop' { - $vmr.recorder.loop = $value - } - It 'Should set and get Recorder.armstrip[i]' -ForEach @( @{ Index = $phys_in }, @{ Index = $virt_in } ) { @@ -174,6 +170,18 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' { $vmr.recorder.armbus[$index].set($value) $vmr.recorder.armbus[$index].get() | Should -Be $value } + + Context 'Mode' { + It 'Should set and get Recorder.mode.multitrack' { + $vmr.recorder.mode.multitrack = $value + $vmr.recorder.mode.multitrack | Should -Be $expected + } + + It 'Should set and get Recorder.mode.loop' { + $vmr.recorder.mode.loop = $value + $vmr.recorder.mode.loop | Should -Be $expected + } + } } Context 'Command' {