mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2025-12-05 05:07:47 +00:00
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:
parent
e42862c32d
commit
ab4baa5c44
@ -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
|
||||
|
||||
105
lib/recorder.ps1
105
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)
|
||||
}
|
||||
|
||||
@ -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' {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user