Vendor the web assets from Lesavka a5758755. The RCT browser performs signal recognition and sends numeric observations through the existing receipt service.
39 lines
2.0 KiB
JavaScript
39 lines
2.0 KiB
JavaScript
// Existing numeric-only receipt contract; no new backend or media upload.
|
|
import {RunReporter} from './reporting.js';
|
|
|
|
/** Rotate bounded receipt windows without reopening the selected audio device. */
|
|
export class AudioReports {
|
|
constructor(status,Reporter=RunReporter) {
|
|
this.status=status;this.Reporter=Reporter;this.reporter=null;this.start=0;
|
|
this.baseline=null;this.ids=[];this.last=null;
|
|
}
|
|
snapshot(now,audio,settings,reason) {
|
|
const b=this.baseline??{};
|
|
const delta=k=>typeof audio?.[k]==='number'?Math.max(0,audio[k]-(b[k]??0)):null;
|
|
const path=audio?.path;
|
|
const boundedMs=value=>value<=180000?value:null;
|
|
const paired=path?{pilot:{...path,windows:path.windows-(b.path?.windows??0),
|
|
gapMaxMs:boundedMs(path.gapMaxMs),trailingGapMs:boundedMs(path.trailingGapMs)},
|
|
continuity:{badMarkers:path.sequenceFaults}}:null;
|
|
return {paired,elapsedMs:Math.max(0,now-this.start),reason,settings:{audio:settings},video:null,
|
|
audio:audio?{...audio,inputFrames:delta('inputFrames'),processedFrames:delta('processedFrames'),
|
|
exactZeroFrames:delta('exactZeroFrames')}:null};
|
|
}
|
|
observe(now,audio,settings) {
|
|
if(this.reporter&&now-this.start>=120000) {
|
|
const reason=audio?.path?'signal report window closed':'120 seconds complete';
|
|
this.reporter.finish(this.snapshot(now,audio,settings,reason));
|
|
this.remember();this.reporter=null;this.baseline=audio?{...audio}:null;
|
|
}
|
|
if(!this.reporter){this.start=now;this.reporter=new this.Reporter(this.status);}
|
|
this.last=this.snapshot(now,audio,settings,'observing');this.reporter.observe(this.last);
|
|
}
|
|
remember() {
|
|
if(this.reporter?.runId&&this.ids.length<32&&!this.ids.includes(this.reporter.runId))this.ids.push(this.reporter.runId);
|
|
}
|
|
finish(now,audio,settings,reason) {
|
|
if(!this.reporter)return;
|
|
this.reporter.finish(this.snapshot(now,audio,settings,reason));this.remember();
|
|
}
|
|
}
|