PageSourceSearch

https://asenno.com/_app/immutable/chunks/D2QplrIU.js

js asenno.com collected 2026-10-08 13:53:58 UTC 4,395 bytes, 28 lines download raw bytes

1const e={id:"polarity-pulse",title:"Polarity Pulse",description:"Single-cycle square wave to verify speaker polarity - woofer should move outward on positive pulse.",category:"Channel & Routing",defaultSettings:{pulseType:"positive",pulseWidth:50,pulseInterval:1e3,channel:"both",amplitude:.5,playing:!1,singleShot:!1,showWaveform:!0},pulseTypes:{positive:"Positive First",negative:"Negative First",alternating:"Alternating"},channels:[{id:"left",name:"Left Only",color:"#ff6b6b"},{id:"right",name:"Right Only",color:"#4ecdc4"},{id:"both",name:"Both",color:"#45b7d1"},{id:"alternatingLR",name:"Alternating L/R",color:"#96ceb4"}],createPulseBuffer(e,t){const n=e.sampleRate,a=Math.floor(t.pulseWidth/1e3*n),o=Math.floor(t.pulseInterval/1e3*n),r=e.createBuffer(2,o,n),l=r.getChannelData(0),s=r.getChannelData(1)
2let i=t.amplitude
3"negative"===t.pulseType&&(i=-t.amplitude)
4const c=Math.min(48,a/10)
5for(let e=0;e<a;e++){let n=i
6e<c?n*=e/c:e>a-c&&(n*=(a-e)/c),"left"!==t.channel&&"both"!==t.channel||(l[e]=n),"right"!==t.channel&&"both"!==t.channel||(s[e]=n)}return"alternating"===t.pulseType&&(r.alternating=!0),r},createDCTestBuffer(e,t){const n=e.sampleRate,a=2*n,o=e.createBuffer(2,a,n),r=o.getChannelData(0),l=o.getChannelData(1),s=2*n
7for(let e=0;e<a;e++){const n=e%s<s/2?t.amplitude:-t.amplitude
8"left"!==t.channel&&"both"!==t.channel||(r[e]=n),"right"!==t.channel&&"both"!==t.channel||(l[e]=n)}return o},createNodes(e,t){const n=e.createGain(),a=e.createGain(),o=e.createChannelMerger(2)
9n.connect(o,0,0),a.connect(o,0,1)
10const r=e.createAnalyser()
11return r.fftSize=4096,r.smoothingTimeConstant=0,o.connect(r),r.connect(t),{leftGain:n,rightGain:a,merger:o,analyser:r,scopeData:{bufferLength:r.frequencyBinCount,dataArray:new Float32Array(r.frequencyBinCount)},pulseCount:0,lastPulseTime:0}},start(e,t,n){const a=this.createPulseBuffer(n,t),o=n.createBufferSource()
12o.buffer=a,o.loop=!t.singleShot
13const r=n.createChannelSplitter(2)
14if(o.connect(r),r.connect(e.leftGain,0),r.connect(e.rightGain,1),"alternatingLR"===t.channel){const t=n.createScriptProcessor(4096,2,2)
15let a=!1
16t.onaudioprocess=t=>{const o=t.inputBuffer.getChannelData(0),r=t.inputBuffer.getChannelData(1),l=t.outputBuffer.getChannelData(0),s=t.outputBuffer.getChannelData(1)
17let i=!1
18for(let e=0;e<o.length;e++)if(Math.abs(o[e])>.001||Math.abs(r[e])>.001){i=!0
19break}i&&n.currentTime-e.lastPulseTime>.5&&(a=!a,e.lastPulseTime=n.currentTime,e.pulseCount++)
20for(let e=0;e<o.length;e++)a?(l[e]=0,s[e]=o[e]||r[e]):(l[e]=o[e]||r[e],s[e]=0)},r.disconnect(),o.disconnect(),o.connect(t),t.connect(r),e.scriptProcessor=t}if("alternating"===t.pulseType){n.createGain()
21let t=1
22const a=n.createScriptProcessor(4096,2,2)
23a.onaudioprocess=a=>{const o=a.inputBuffer.getChannelData(0),r=a.inputBuffer.getChannelData(1),l=a.outputBuffer.getChannelData(0),s=a.outputBuffer.getChannelData(1)
24let i=!1
25for(let e=0;e<o.length;e++)if(Math.abs(o[e])>.001||Math.abs(r[e])>.001){i=!0
26break}i&&n.currentTime-e.lastPulseTime>.5&&(t*=-1,e.lastPulseTime=n.currentTime)
27for(let e=0;e<o.length;e++)l[e]=o[e]*t,s[e]=r[e]*t},e.scriptProcessor?(e.scriptProcessor.connect(a),a.connect(r)):(o.disconnect(),o.connect(a),a.connect(r)),e.polarityProcessor=a}o.start(),e.source=o,e.pulseBuffer=a,t.singleShot&&(o.onended=()=>{t.playing=!1})},stop(e){e.source&&(e.source.stop(),e.source.disconnect(),e.source=null),e.scriptProcessor&&(e.scriptProcessor.disconnect(),e.scriptProcessor=null),e.polarityProcessor&&(e.polarityProcessor.disconnect(),e.polarityProcessor=null),e.pulseCount=0,e.lastPulseTime=0},updateSettings(e,t,n){t.playing&&(this.stop(e),this.start(e,t,n))},getWaveformData:e=>e.analyser?(e.analyser.getFloatTimeDomainData(e.scopeData.dataArray),e.scopeData.dataArray):null,keyboard:{handlers:{" ":e=>({playing:!e.playing}),p:()=>({pulseType:"positive"}),n:()=>({pulseType:"negative"}),a:()=>({pulseType:"alternating"}),l:()=>({channel:"left"}),r:()=>({channel:"right"}),b:()=>({channel:"both"}),s:e=>({singleShot:!e.singleShot})}},visualization:{type:"oscilloscope",fftSize:4096,showPulseInfo:!0},controls:{showPulseType:!0,showChannelSelector:!0,showPulseWidth:!0,showPulseInterval:!0,showAmplitude:!0,showSingleShot:!0,showWaveformDisplay:!0,showPlayButton:!0,infoText:"Generate single-cycle pulses to verify speaker polarity. Positive pulse should move woofer outward. Press P/N/A for polarity modes, L/R/B for channels."}}
28export{e as default}

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.