PageSourceSearch

https://ds-k.site/_astro/webAudioStaticSound.DbSbRJTj.js

js ds-k.site collected 2026-09-24 10:12:01 UTC 9,099 bytes, 1 lines download raw bytes

1import{A as h,_ as d}from"./abstractSoundInstance.C1U73nUN.js";import{_,a as c,b as l,c as f}from"./spatialWebAudio.CWwraS7v.js";import{b2 as p,be as m,bf as u}from"./Layout.astro_astro_type_script_index_0_lang.D7HFstIc.js";import"./abstractSoundSource.Bv6zigu5.js";import"./webAudioBaseSubGraph.wb856c9X.js";import"./_commonjsHelpers.CqkleIqs.js";class g extends h{constructor(t,e){super(t,e)}get duration(){return this._options.duration}set duration(t){this._options.duration=t}get loopStart(){return this._options.loopStart}set loopStart(t){this._options.loopStart=t}get loopEnd(){return this._options.loopEnd}set loopEnd(t){this._options.loopEnd=t}get pitch(){return this._options.pitch}set pitch(t){this._options.pitch=t;const e=this._instances.values();for(let i=e.next();!i.done;i=e.next())i.value.pitch=t}get playbackRate(){return this._options.playbackRate}set playbackRate(t){this._options.playbackRate=t;const e=this._instances.values();for(let i=e.next();!i.done;i=e.next())i.value.playbackRate=t}play(t={}){if(this.state===5){this.resume();return}t.duration??(t.duration=this.duration),t.loop??(t.loop=this.loop),t.loopStart??(t.loopStart=this.loopStart),t.loopEnd??(t.loopEnd=this.loopEnd),t.startOffset??(t.startOffset=this.startOffset),t.volume??(t.volume=1),t.waitTime??(t.waitTime=0);const e=this._createInstance();this._beforePlay(e),e.play(t),this._afterPlay(e),this._stopExcessInstances()}stop(t={}){if(t.waitTime&&0<t.waitTime?this._setState(0):this._setState(1),!!this._instances)for(const e of Array.from(this._instances))e.stop(t)}}let y=1;class b{constructor(t){this.name=`StaticSoundBuffer #${y++}`,this.engine=t}}class S extends d{}class a extends g{constructor(t,e,i){super(t,e),this._spatial=null,this._spatialAutoUpdate=!0,this._spatialMinUpdateTime=0,this._stereo=null,typeof i.spatialAutoUpdate=="boolean"&&(this._spatialAutoUpdate=i.spatialAutoUpdate),typeof i.spatialMinUpdateTime=="number"&&(this._spatialMinUpdateTime=i.spatialMinUpdateTime),this._options={autoplay:i.autoplay??!1,duration:i.duration??0,loop:i.loop??!1,loopEnd:i.loopEnd??0,loopStart:i.loopStart??0,maxInstances:i.maxInstances??1/0,pitch:i.pitch??0,playbackRate:i.playbackRate??1,startOffset:i.startOffset??0},this._subGraph=new a._SubGraph(this)}async _initAsync(t,e){this._audioContext=this.engine._audioContext,t instanceof r?this._buffer=t:(typeof t=="string"||Array.isArray(t)||t instanceof ArrayBuffer||t instanceof AudioBuffer)&&(this._buffer=await this.engine.createSoundBufferAsync(t,e)),e.outBus?this.outBus=e.outBus:e.outBusAutoDefault!==!1&&(await this.engine.isReadyPromise,this.outBus=this.engine.defaultMainBus),await this._subGraph.initAsync(e),_(e)&&this._initSpatialProperty(),e.autoplay&&this.play(),this.engine._addNode(this)}get buffer(){return this._buffer}get _inNode(){return this._subGraph._inNode}get _outNode(){return this._subGraph._outNode}get spatial(){return this._spatial?this._spatial:this._initSpatialProperty()}get stereo(){return this._stereo??(this._stereo=new c(this._subGraph))}async cloneAsync(t=null){const e=await this.engine.createSoundAsync(this.name,t?.cloneBuffer?this.buffer.clone():this.buffer,this._options);return e.outBus=t?.outBus?t.outBus:this.outBus,e}dispose(){super.dispose(),this._spatial?.dispose(),this._spatial=null,this._stereo=null,this._subGraph.dispose(),this.engine._removeNode(this)}getClassName(){return"_WebAudioStaticSound"}_createInstance(){return new N(this,this._options)}_connect(t){return super._connect(t)?(t._inNode&&this._outNode?.connect(t._inNode),!0):!1}_disconnect(t){return super._disconnect(t)?(t._inNode&&this._outNode?.disconnect(t._inNode),!0):!1}_initSpatialProperty(){return this._spatial||(this._spatial=new l(this._subGraph,this._spatialAutoUpdate,this._spatialMinUpdateTime)),this._spatial}}a._SubGraph=class extends f{get _downstreamNodes(){return this._owner._downstreamNodes??null}get _upstreamNodes(){return this._owner._upstreamNodes??null}};class r extends b{constructor(t){super(t)}async _initAsync(t,e){t instanceof AudioBuffer?this._audioBuffer=t:typeof t=="string"?await this._initFromUrlAsync(t):Array.isArray(t)?await this._initFromUrlsAsync(t,e.skipCodecCheck??!1):t instanceof ArrayBuffer&&await this._initFromArrayBufferAsync(t)}get channelCount(){return this._audioBuffer.numberOfChannels}get duration(){return this._audioBuffer.duration}get length(){return this._audioBuffer.length}get sampleRate(){return this._audioBuffer.sampleRate}clone(t=null){const e=new AudioBuffer({length:this._audioBuffer.length,numberOfChannels:this._audioBuffer.numberOfChannels,sampleRate:this._audioBuffer.sampleRate});for(let s=0;s<this._audioBuffer.numberOfChannels;
1s++)e.copyToChannel(this._audioBuffer.getChannelData(s),s);const i=new r(this.engine);return i._audioBuffer=e,i.name=t?.name?t.name:this.name,i}async _initFromArrayBufferAsync(t){this._audioBuffer=await this.engine._audioContext.decodeAudioData(t)}async _initFromUrlAsync(t){t=p(t),await this._initFromArrayBufferAsync(await(await fetch(t)).arrayBuffer())}async _initFromUrlsAsync(t,e){for(const i of t){if(e)await this._initFromUrlAsync(i);else{const n=i.match(m)?.at(1);if(n&&this.engine.isFormatValid(n))try{await this._initFromUrlAsync(i)}catch{n&&0<n.length&&this.engine.flagInvalidFormat(n)}}if(this._audioBuffer)break}}}class N extends S{constructor(t,e){super(t),this._enginePlayTime=0,this._enginePauseTime=0,this._isConnected=!1,this._pitch=null,this._playbackRate=null,this._sourceNode=null,this._onEnded=()=>{this._enginePlayTime=0,this.onEndedObservable.notifyObservers(this),this._deinitSourceNode()},this._onEngineStateChanged=()=>{this.engine.state==="running"&&(this._options.loop&&this.state===2&&this.play(),this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged))},this._options=e,this._volumeNode=new GainNode(t._audioContext),this._initSourceNode()}dispose(){super.dispose(),this._pitch?.dispose(),this._playbackRate?.dispose(),this._sourceNode=null,this.stop(),this._deinitSourceNode(),this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged)}get currentTime(){if(this._state===1)return 0;const t=this._state===5?0:this.engine.currentTime-this._enginePlayTime;return this._enginePauseTime+t+this._options.startOffset}set currentTime(t){const e=this._state===2||this._state===3;e&&(this.stop(),this._deinitSourceNode()),this._options.startOffset=t,e&&this.play()}get _outNode(){return this._volumeNode}set pitch(t){this._pitch?.setTargetValue(t)}set playbackRate(t){this._playbackRate?.setTargetValue(t)}get startTime(){return this._state===1?0:this._enginePlayTime}getClassName(){return"_WebAudioStaticSoundInstance"}play(t={}){if(this._state===3)return;t.duration!==void 0&&(this._options.duration=t.duration),t.loop!==void 0&&(this._options.loop=t.loop),t.loopStart!==void 0&&(this._options.loopStart=t.loopStart),t.loopEnd!==void 0&&(this._options.loopEnd=t.loopEnd),t.startOffset!==void 0&&(this._options.startOffset=t.startOffset);let e=this._options.startOffset;this._state===5&&(e+=this.currentTime,e%=this._sound.buffer.duration),this._enginePlayTime=this.engine.currentTime+(t.waitTime??0),this._volumeNode.gain.value=t.volume??1,this._initSourceNode(),this.engine.state==="running"?(this._setState(3),this._sourceNode?.start(this._enginePlayTime,e,this._options.duration>0?this._options.duration:void 0)):this._options.loop&&(this._setState(2),this.engine.stateChangedObservable.add(this._onEngineStateChanged))}pause(){this._state!==5&&(this._setState(5),this._enginePauseTime+=this.engine.currentTime-this._enginePlayTime,this._sourceNode?.stop(),this._deinitSourceNode())}resume(){this._state===5&&this.play()}stop(t={}){if(this._state===1)return;this._setState(1);const e=this.engine.currentTime+(t.waitTime??0);this._sourceNode?.stop(e),this.engine.stateChangedObservable.removeCallback(this._onEngineStateChanged)}_connect(t){return super._connect(t)?(t instanceof a&&t._inNode&&(this._outNode?.connect(t._inNode),this._isConnected=!0),!0):!1}_disconnect(t){return super._disconnect(t)?(t instanceof a&&t._inNode&&(this._outNode?.disconnect(t._inNode),this._isConnected=!1),!0):!1}_deinitSourceNode(){if(this._sourceNode){if(this._isConnected&&!this._disconnect(this._sound))throw new Error("Disconnect failed");this._sourceNode.disconnect(this._volumeNode),this._sourceNode.removeEventListener("ended",this._onEnded),this._sourceNode=null}}_initSourceNode(){if(!this._sourceNode){if(this._sourceNode=new AudioBufferSourceNode(this._sound._audioContext,{buffer:this._sound.buffer._audioBuffer}),this._sourceNode.addEventListener("ended",this._onEnded,{once:!0}),this._sourceNode.connect(this._volumeNode),!this._connect(this._sound))throw new Error("Connect failed");this._pitch=new u(this.engine,this._sourceNode.detune),this._playbackRate=new u(this.engine,this._sourceNode.playbackRate)}const t=this._sourceNode;t.detune.value=this._sound.pitch,t.loop=this._options.loop,t.loopEnd=this._options.loopEnd,t.loopStart=this._options.loopStart,t.playbackRate.value=this._sound.playbackRate}}export{a as _WebAudioStaticSound,r as _WebAudioStaticSoundBuffer};

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.