PageSourceSearch

https://www.musikhack.com/static/mh-cloud/assets/loudness.worklet-hADCNyTQ.js

js musikhack.com collected 2026-10-07 23:02:57 UTC 2,771 bytes, 1 lines download raw bytes

1(function(){"use strict";class b{constructor(t,e=2){if(!Number.isFinite(t)||t<8e3||!Number.isInteger(e)||e<1||e>2)throw new RangeError("Expected sample rate >= 8000 and one or two channels");this.channelCount=e,this.hop=Math.round(t/10);const s=Math.tan(Math.PI*1681.974450955533/t),r=.7071752369554196,o=10**(3.999843853973347/20),h=o**.4996667741545416,i=1+s/r+s*s;this.shelf=[(o+h*s/r+s*s)/i,2*(s*s-o)/i,(o-h*s/r+s*s)/i,2*(s*s-1)/i,(1-s/r+s*s)/i];const n=Math.tan(Math.PI*38.13547087602444/t),f=1+n/.5003270373238773+n*n;this.highpass=[2*(n*n-1)/f,(1-n/.5003270373238773+n*n)/f],this.state=new Float64Array(e*4),this.windows=new Float64Array(4),this.counts=new Float64Array(12001),this.energies=new Float64Array(12001),this.reset()}reset(){this.state.fill(0),this.windows.fill(0),this.counts.fill(0),this.energies.fill(0),this.frames=this.segmentEnergy=this.segments=0,this.totalEnergy=this.totalCount=0,this.integratedLufs=this.momentaryLufs=-1/0,this.revision=0}processSamples(t){const e=t[0]?.length??0,[s,r,o,h,i]=this.shelf,[n,f]=this.highpass,a=this.state;for(let u=0;u<e;u++){let y=0;for(let c=0;c<this.channelCount;c++){const g=c*4,w=t[c]?.[u]??0,d=Number.isFinite(w)?w:0,l=s*d+a[g];a[g]=r*d-h*l+a[g+1],a[g+1]=o*d-i*l;const m=l+a[g+2];a[g+2]=-2*l-n*m+a[g+3],a[g+3]=l-f*m,y+=m*m}this.segmentEnergy+=y,++this.frames===this.hop&&(this.windows[this.segments%4]=this.segmentEnergy,this.segments++,this.frames=this.segmentEnergy=0,this.segments>=4&&this.finishWindow())}}finishWindow(){const t=(this.windows[0]+this.windows[1]+this.windows[2]+this.windows[3])/(4*this.hop);if(this.momentaryLufs=-.691+10*Math.log10(t),Number.isFinite(t)&&this.momentaryLufs>-70){const e=Math.min(12e3,Math.floor((this.momentaryLufs+70)*100));this.counts[e]++,this.energies[e]+=t,this.totalEnergy+=t,this.totalCount++;const s=-.691+10*Math.log10(this.totalEnergy/this.totalCount)-10,r=Math.max(0,Math.min(12e3,Math.ceil((s+70)*100-.5)));let o=0,h=0;for(let i=r;i<this.counts.length;i++)o+=this.energies[i],h+=this.counts[i];this.integratedLufs=h?-.691+10*Math.log10(o/h):-1/0}this.revision++}getValues(){return{integratedLufs:this.integratedLufs,momentaryLufs:this.momentaryLufs}}}class p extends AudioWorkletProcessor{constructor(){super(),this.meter=new b(sampleRate,2),this.enabled=!1,this.generation=0,this.port.onmessage=({data:t})=>{t.type==="reset"?(this.meter.reset(),this.generation=t.generation):t.type==="enabled"?this.enabled=t.enabled:t.type==="destroy"&&(this.destroyed=!0)}}process(t){if(this.destroyed)return!1;if(this.enabled&&t[0]?.length){const e=this.meter.revision;this.meter.processSamples(t[0]),e!==this.meter.revision&&this.port.postMessage({...this.meter.getValues(),generation:this.generation})}return!0}}registerProcessor("hyfi-integrated-loudness",p)})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.