Adaptive Music v0.8.0 release candidate
Validate and generate manual release / package (push) Waiting to run
Validate and generate manual release / package (push) Waiting to run
This commit is contained in:
1 parent
8c07a468a4
commit
95b0427aa1
48 files changed
+3631
-313
No files matched your search
@@ -0,0 +1,61 @@
|
||||
// Test instrumentation only. Report counts; never record or retain audio.
|
||||
class AdaptiveContinuityMeter extends AudioWorkletProcessor {
|
||||
frames=0;
|
||||
channelSamples=0;
|
||||
zeroRun=0;
|
||||
maxZeroRun=0;
|
||||
shortDropouts=0;
|
||||
nearFullScale=0;
|
||||
jumps=0;
|
||||
maxStep=0;
|
||||
last=0;
|
||||
nextReport=0;
|
||||
audible=false;
|
||||
|
||||
constructor(){
|
||||
super();
|
||||
this.port.onmessage=event=>{
|
||||
if(event.data!=='start-phase')return;
|
||||
this.zeroRun=this.maxZeroRun=0;
|
||||
this.port.postMessage({...this.metrics(),phaseStarted:true});
|
||||
};
|
||||
}
|
||||
|
||||
metrics(){
|
||||
return {sampleRate,frames:this.frames,channelSamples:this.channelSamples,shortDropouts:this.shortDropouts,
|
||||
maxZeroRun:this.maxZeroRun,trailingZeroRun:this.zeroRun,nearFullScale:this.nearFullScale,jumps:this.jumps,maxStep:this.maxStep};
|
||||
}
|
||||
|
||||
process([input],[output]) {
|
||||
const length=output[0].length;
|
||||
for(let i=0;i<length;i++){
|
||||
let peak=0;
|
||||
for(const channel of input){
|
||||
peak=Math.max(peak,Math.abs(channel[i]));
|
||||
if(Math.abs(channel[i])>=0.999)this.nearFullScale++;
|
||||
this.channelSamples++;
|
||||
}
|
||||
if(peak<=0.000001)this.zeroRun++;
|
||||
if(peak>0.000001){
|
||||
if(this.audible){
|
||||
this.maxZeroRun=Math.max(this.maxZeroRun,this.zeroRun);
|
||||
if(this.zeroRun>=sampleRate*0.00075&&this.zeroRun<=sampleRate*0.08)this.shortDropouts++;
|
||||
}
|
||||
this.zeroRun=0;
|
||||
this.audible=true;
|
||||
}
|
||||
const sample=input[0]?.[i]??0;
|
||||
const step=Math.abs(this.last-sample);
|
||||
this.maxStep=Math.max(this.maxStep,step);
|
||||
if(step>0.35)this.jumps++;
|
||||
this.last=sample;
|
||||
}
|
||||
this.frames+=length;
|
||||
if(currentFrame>=this.nextReport){
|
||||
this.nextReport=currentFrame+sampleRate;
|
||||
this.port.postMessage(this.metrics());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
registerProcessor('adaptive-continuity-meter',AdaptiveContinuityMeter);
|
||||
Reference in new issue
Block a user