1const e={id:"sweep",title:"Frequency Sweep Generator",description:"Generate frequency sweeps for testing speaker response and room acoustics.",category:"Basic Tones",defaultSettings:{startFreq:20,endFreq:2e4,duration:10,sweepType:"logarithmic",loop:!1,playing:!1},sweepTypes:{logarithmic:"Logarithmic",linear:"Linear"},createNodes(e,t){const r=e.createAnalyser() 2return r.fftSize=2048,r.connect(t),{analyser:r}},start(e,t,r){const n=r.createOscillator(),a=r.createGain(),o=r.createChannelMerger(2) 3n.connect(o,0,0),n.connect(o,0,1),o.connect(a),a.connect(e.analyser),n.frequency.setValueAtTime(t.startFreq,r.currentTime) 4const i=r.currentTime+t.duration 5return"logarithmic"===t.sweepType?n.frequency.exponentialRampToValueAtTime(t.endFreq,i):n.frequency.linearRampToValueAtTime(t.endFreq,i),a.gain.setValueAtTime(0,r.currentTime),a.gain.linearRampToValueAtTime(1,r.currentTime+.1),a.gain.setValueAtTime(1,i-.1),a.gain.linearRampToValueAtTime(0,i),n.start(),n.stop(i),e.oscillator=n,e.gainNode=a,e.monoToStereo=o,e.startTime=r.currentTime,e.initialDuration=t.duration,n},stop(e){if(e.oscillator){try{e.oscillator.stop()}catch(e){}e.oscillator.disconnect(),e.oscillator=null}e.gainNode&&(e.gainNode.disconnect(),e.gainNode=null),e.monoToStereo&&(e.monoToStereo.disconnect(),e.monoToStereo=null),e.startTime=null,e.initialDuration=null},restart(e,t,r){return this.stop(e),this.start(e,t,r)},getCurrentFrequency(e,t,r){if(!e.startTime)return t.startFreq 6const n=r.currentTime-e.startTime,a=e.initialDuration||t.duration,o=Math.min(n/a,1) 7if("logarithmic"===t.sweepType){const e=Math.log(t.startFreq),r=Math.log(t.endFreq) 8return Math.exp(e+(r-e)*o)}return t.startFreq+(t.endFreq-t.startFreq)*o},getProgress(e,t,r){if(!e.startTime)return 0 9const n=r.currentTime-e.startTime,a=e.initialDuration||t.duration 10return Math.min(n/a,1)},keyboard:{handlers:{" ":e=>({playing:!e.playing})}},visualization:{type:"spectrum",fftSize:2048,showFrequencyMarker:!0},controls:{showStartFreqSlider:!0,showEndFreqSlider:!0,showDurationSlider:!0,showSweepTypeSelector:!0,showPlayButton:!0,showProgress:!0,infoText:"Creates a smooth frequency transition to test speaker response across the spectrum."}} 11export{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.