remove loop, cleanup

- removed deprecated recorder.loop
- placed methods before hidden properties for readability
- added a couple mode tests for good measure
This commit is contained in:
pblivingston 2025-12-03 03:31:30 -05:00
parent e42862c32d
commit ab4baa5c44
3 changed files with 48 additions and 75 deletions

View File

@ -15,6 +15,8 @@ AddActionMembers now adds ScriptMethods instead of ScriptProperties:
- See Command section of README for details on using special commands - See Command section of README for details on using special commands
- See Recorder section of README for details on using playback/record actions - See Recorder section of README for details on using playback/record actions
Deprecated Recorder.Loop removed: use Recorder.Mode.Loop
### Added ### Added
- IRemote base class - IRemote base class

View File

@ -33,15 +33,41 @@ class Recorder : IRemote {
return 'Recorder' return 'Recorder'
} }
hidden $_loop = $($this | Add-Member ScriptProperty 'loop' ` [void] Eject () {
{ $this.remote.Setter('Command.Eject', 1)
[bool]$this.mode.loop }
} `
{ [void] Load ([string]$filename) {
param($arg) $this.Setter('load', $filename)
$this.mode.loop = $arg }
[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' ` hidden $_samplerate = $($this | Add-Member ScriptProperty 'samplerate' `
{ {
@ -150,42 +176,6 @@ class Recorder : IRemote {
$this._state = $this.Setter($arg, 1) $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 { 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) { function Make_Recorder ([Object]$remote) {
return [Recorder]::new($remote) return [Recorder]::new($remote)
} }

View File

@ -157,10 +157,6 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
$vmr.recorder.B1 | Should -Be $expected $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 @( It 'Should set and get Recorder.armstrip[i]' -ForEach @(
@{ Index = $phys_in }, @{ Index = $virt_in } @{ 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].set($value)
$vmr.recorder.armbus[$index].get() | Should -Be $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' { Context 'Command' {