mirror of
https://github.com/onyx-and-iris/voicemeeter-api-powershell.git
synced 2026-04-09 17:33:33 +00:00
recorder.state
- prelim tests pass for potato
This commit is contained in:
@@ -876,4 +876,60 @@ Describe -Tag 'higher', -TestName 'All Higher Tests' {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'Action Tests' -Tag 'action' {
|
||||
Context 'Recorder' -Skip:$ifBasic {
|
||||
Context 'Recording/Playback' -Skip:$ifCustomDir {
|
||||
BeforeAll {
|
||||
$prefix = 'temp'
|
||||
$filetype = 'wav'
|
||||
$vmr.recorder.prefix($prefix)
|
||||
$vmr.recorder.filetype($filetype)
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$vmr.recorder.state = 'record'
|
||||
$stamp = '{0:yyyy-MM-dd} at {0:HH}h{0:mm}m{0:ss}s' -f (Get-Date)
|
||||
Start-Sleep -Milliseconds 2000
|
||||
|
||||
$tmp = [System.IO.Path]::Combine($recDir, ("{0} {1}.{2}" -f $prefix, $stamp, $filetype))
|
||||
|
||||
$vmr.recorder.state = 'pause'
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
$vmr.recorder.state = 'stop'
|
||||
$vmr.recorder.eject()
|
||||
Start-Sleep -Milliseconds 500
|
||||
|
||||
if (Test-Path $tmp) {
|
||||
Remove-Item -Path $tmp -Force
|
||||
}
|
||||
else {
|
||||
throw "Recording file $tmp was not found."
|
||||
}
|
||||
}
|
||||
|
||||
It 'Should call Recorder.record()' {
|
||||
$vmr.recorder.record()
|
||||
$vmr.recorder.state | Should -Be 'record'
|
||||
}
|
||||
|
||||
It 'Should call Recorder.pause()' {
|
||||
$vmr.recorder.record()
|
||||
Start-Sleep -Milliseconds 500
|
||||
$vmr.recorder.pause()
|
||||
$vmr.recorder.state | Should -Be 'pause'
|
||||
}
|
||||
|
||||
It 'Should call Recorder.play()' {
|
||||
$vmr.recorder.stop()
|
||||
Start-Sleep -Milliseconds 500
|
||||
$vmr.recorder.play()
|
||||
$vmr.recorder.state | Should -Be 'play'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,41 @@
|
||||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Target = "variablename")]
|
||||
Param([String]$tag, [string]$kind = 'potato')
|
||||
Param([String]$tag, [string]$kind = 'potato', [string]$recDir = (Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'Voicemeeter'))
|
||||
Import-Module (Join-Path (Split-Path $PSScriptRoot -Parent) 'lib\Voicemeeter.psm1') -Force
|
||||
|
||||
|
||||
function Test-RecDir ([object]$vmr, [string]$recDir) {
|
||||
$prefix = 'temp'
|
||||
$filetype = 'wav'
|
||||
$vmr.recorder.prefix($prefix)
|
||||
$vmr.recorder.filetype($filetype)
|
||||
|
||||
|
||||
try {
|
||||
$vmr.recorder.record()
|
||||
$stamp = '{0:yyyy-MM-dd} at {0:HH}h{0:mm}m{0:ss}s' -f (Get-Date)
|
||||
Start-Sleep -Milliseconds 2000
|
||||
|
||||
$tmp = Join-Path $recDir ("{0} {1}.{2}" -f $prefix, $stamp, $filetype)
|
||||
|
||||
$vmr.recorder.stop()
|
||||
$vmr.recorder.eject()
|
||||
Start-Sleep -Milliseconds 500
|
||||
}
|
||||
catch {
|
||||
Write-Warning "Failed to record pre-check clip: $_"
|
||||
}
|
||||
|
||||
if (Test-Path $tmp) {
|
||||
Remove-Item -Path $tmp -Force
|
||||
return $false
|
||||
}
|
||||
else {
|
||||
Write-Warning "Recorder output not found at given path: $tmp"
|
||||
Write-Warning "Skipping Recording/Playback tests. Provide custom path with -recDir"
|
||||
return $true
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
try {
|
||||
$vmr = Connect-Voicemeeter -Kind $kind
|
||||
@@ -30,6 +63,10 @@ function main() {
|
||||
$ifNotBasic = $vmr.kind.name -ne 'basic'
|
||||
$ifNotPotato = $vmr.kind.name -ne 'potato'
|
||||
|
||||
# recording directory: default ~/My Documents/Voicemeeter, override if custom
|
||||
$recDir = [System.IO.Path]::GetFullPath($recDir)
|
||||
$ifCustomDir = Test-RecDir -vmr $vmr -recDir $recDir # avoid creating files we can't delete
|
||||
|
||||
Invoke-Pester -Tag $tag -PassThru | Out-Null
|
||||
}
|
||||
finally { Disconnect-Voicemeeter }
|
||||
|
||||
Reference in New Issue
Block a user