param([Parameter(Mandatory)][string]$ReferencePath,[Parameter(Mandatory)][string]$CapturedPath,[Parameter(Mandatory)][string]$WrongReferencePath,[Parameter(Mandatory)][string]$EvidenceDir) $ErrorActionPreference='Stop' New-Item -ItemType Directory -Path $EvidenceDir -Force | Out-Null $checks=[Collections.Generic.List[object]]::new() function Match([string]$Name,[string]$Reference,[string]$Captured,[bool]$Expected) { $path=Join-Path $EvidenceDir "$Name.json" & pwsh -NoProfile -File (Join-Path $PSScriptRoot 'compare-audio.ps1') -ReferencePath $Reference -CapturedPath $Captured -OutputPath $path -RequireFullSpeech $code=$LASTEXITCODE;$record=Get-Content -LiteralPath $path -Raw | ConvertFrom-Json $checks.Add(@{name=$Name;expectedPassed=$Expected;exitCode=$code;record=$record}) if ($record.passed -ne $Expected -or ($Expected -and $code -ne 0) -or (!$Expected -and $code -eq 0)) { throw "PCM negative control mismatch: $Name" } return $record } try { $positive=Match 'positive-full-speech' $ReferencePath $CapturedPath $true Add-Type -TypeDefinition @' using System; using System.IO; public static class NativeAudioControls { public static void Create(string input,string output,string kind,double onset,double duration) { byte[] bytes=File.ReadAllBytes(input);int rate=BitConverter.ToInt32(bytes,24),start=(int)Math.Round(onset*rate),length=(int)Math.Round(duration*rate),cut=rate/4,middle=start+(int)(rate*.85); if(BitConverter.ToInt16(bytes,20)!=1 || BitConverter.ToInt16(bytes,22)!=1 || BitConverter.ToInt16(bytes,34)!=16 || System.Text.Encoding.ASCII.GetString(bytes,36,4)!="data") throw new Exception("Canonical monoPCM16 WAV required"); short[] data=new short[(bytes.Length-44)/2];Buffer.BlockCopy(bytes,44,data,0,bytes.Length-44); if(start<0 || start+length>data.Length || length