{"version":3,"file":"pixi-sound.mjs","sources":["../src/instance.ts","../src/filters/Filter.ts","../src/filters/DistortionFilter.ts","../src/webaudio/WebAudioUtils.ts","../src/filters/EqualizerFilter.ts","../src/filters/MonoFilter.ts","../src/filters/ReverbFilter.ts","../src/filters/StereoFilter.ts","../src/filters/StreamFilter.ts","../src/filters/TelephoneFilter.ts","../src/htmlaudio/HTMLAudioContext.ts","../src/htmlaudio/HTMLAudioInstance.ts","../src/htmlaudio/HTMLAudioMedia.ts","../src/SoundSprite.ts","../src/utils/supported.ts","../src/utils/withoutUndefined.ts","../src/webaudio/WebAudioInstance.ts","../src/Filterable.ts","../src/webaudio/WebAudioNodes.ts","../src/webaudio/WebAudioMedia.ts","../src/webaudio/WebAudioStreamInstance.ts","../src/webaudio/WebAudioStreamMedia.ts","../src/Sound.ts","../src/SoundChannel.ts","../src/webaudio/WebAudioContext.ts","../src/SoundLibrary.ts","../src/utils/playOnce.ts","../src/utils/render.ts","../src/utils/sineTone.ts","../src/soundAsset.ts","../src/index.ts"],"sourcesContent":["import { type SoundLibrary } from './SoundLibrary';\n\n/**\n * Singleton instance of the SoundLibrary\n */\nlet instance: SoundLibrary;\n\n/**\n * Internal set function for the singleton instance.\n * @ignore\n * @param sound - - Sound library instance\n */\nfunction setInstance(sound: SoundLibrary): SoundLibrary\n{\n    instance = sound;\n\n    return sound;\n}\n\n/**\n * Internal get function for the singleton instance.\n * @ignore\n */\nfunction getInstance(): SoundLibrary\n{\n    return instance;\n}\n\nexport { getInstance, instance, setInstance };\n","/**\n * Base class for all filters. Wraps any WebAudio `AudioNode`, or a chain of them,\n * so it can be used in `Sound.filters`, `PlayOptions.filters` or `sound.filtersAll`.\n * Wrap a node directly, or extend this class for a reusable filter.\n * **Only supported with WebAudio.**\n * @example\n * import { filters, sound } from '@pixi/sound';\n * const { audioContext } = sound.context;\n *\n * // Wrap a single node\n * const lowpass = audioContext.createBiquadFilter();\n * lowpass.frequency.value = 800;\n * sound.find('music').filters = [new filters.Filter(lowpass)];\n *\n * // Wrap a chain: pass the first node (input) and the last node (output)\n * const highpass = audioContext.createBiquadFilter();\n * const gain = audioContext.createGain();\n * highpass.type = 'highpass';\n * highpass.connect(gain);\n * sound.play('music', { filters: [new filters.Filter(highpass, gain)] });\n * @memberof filters\n */\nclass Filter\n{\n    /** The input node, which the previous filter connects to. */\n    public destination!: AudioNode;\n\n    /** The output node, which connects to the next filter. */\n    public source!: AudioNode;\n\n    /**\n     * @param {AudioNode} destination - The audio node to use as the destination for the input AudioNode\n     * @param {AudioNode} [source] - Optional output node, defaults to destination node. This is useful\n     *        when creating filters which contains multiple AudioNode elements chained together.\n     */\n    constructor(destination: AudioNode, source?: AudioNode)\n    {\n        this.init(destination, source);\n    }\n\n    /** Reinitialize */\n    protected init(destination: AudioNode, source?: AudioNode): void\n    {\n        this.destination = destination;\n        this.source = source || destination;\n    }\n\n    /**\n     * Connect to the destination.\n     * @param {AudioNode} destination - The destination node to connect the output to\n     */\n    public connect(destination: AudioNode): void\n    {\n        this.source?.connect(destination);\n    }\n\n    /** Completely disconnect filter from destination and source nodes. */\n    public disconnect(): void\n    {\n        this.source?.disconnect();\n    }\n\n    /** Destroy the filter and don't use after this. */\n    public destroy(): void\n    {\n        this.disconnect();\n        this.destination = null!;\n        this.source = null!;\n    }\n}\n\nexport { Filter };\n","import { getInstance } from '../instance';\nimport { Filter } from './Filter';\n\n/**\n * Filter for adding adding delaynode.\n *\n * @memberof filters\n */\nclass DistortionFilter extends Filter\n{\n    /** The Wave shape node use to distort */\n    private _distortion: WaveShaperNode;\n\n    /** The amount of distoration */\n    private _amount!: number;\n\n    /** @param amount - The amount of distoration from 0 to 1. */\n    constructor(amount = 0)\n    {\n        let distortion!: WaveShaperNode;\n\n        if (!getInstance().useLegacy)\n        {\n            const { audioContext } = getInstance().context;\n\n            distortion = audioContext.createWaveShaper();\n        }\n\n        super(distortion);\n\n        this._distortion = distortion;\n\n        this.amount = amount;\n    }\n\n    /** The amount of distortion to set. */\n    set amount(value: number)\n    {\n        this._amount = value;\n        if (getInstance().useLegacy)\n        {\n            return;\n        }\n        const scaledValue = value * 1000;\n        const samples = 44100;\n        const curve = new Float32Array(samples);\n        const deg: number = Math.PI / 180;\n\n        let i = 0;\n        let x: number;\n\n        for (; i < samples; ++i)\n        {\n            x = (i * 2 / samples) - 1;\n            curve[i] = (3 + scaledValue) * x * 20 * deg / (Math.PI + (scaledValue * Math.abs(x)));\n        }\n        this._distortion.curve = curve;\n        this._distortion.oversample = '4x';\n    }\n    get amount(): number\n    {\n        return this._amount;\n    }\n\n    public destroy(): void\n    {\n        this._distortion = null!;\n        super.destroy();\n    }\n}\n\nexport { DistortionFilter };\n","import { getInstance } from '../instance';\nimport { type WebAudioContext } from './WebAudioContext';\n\n/**\n * Internal class for Web Audio abstractions and convenience methods.\n * @memberof webaudio\n */\nclass WebAudioUtils\n{\n    /**\n     * Dezippering is removed in the future Web Audio API, instead\n     * we use the `setValueAtTime` method, however, this is not available\n     * in all environments (e.g., Android webview), so we fallback to the `value` setter.\n     * @param param - AudioNode parameter object\n     * @param value - Value to set\n     * @return The value set\n     */\n    public static setParamValue(param: AudioParam, value: number): number\n    {\n        if (param.setValueAtTime)\n        {\n            const context = getInstance().context as WebAudioContext;\n\n            param.setValueAtTime(value, context.audioContext.currentTime);\n        }\n        else\n        {\n            param.value = value;\n        }\n\n        return value;\n    }\n}\n\nexport { WebAudioUtils };\n","import { getInstance } from '../instance';\nimport { WebAudioUtils } from '../webaudio/WebAudioUtils';\nimport { Filter } from './Filter';\n\ninterface Band\n{\n    f: number;\n    type: string;\n    gain: number;\n}\n\n/**\n * Filter for adding equalizer bands.\n *\n * @memberof filters\n */\nclass EqualizerFilter extends Filter\n{\n    /**\n     * Band at 32 Hz\n     * @readonly\n     */\n    public static readonly F32: number = 32;\n\n    /**\n     * Band at 64 Hz\n     * @readonly\n     */\n    public static readonly F64: number = 64;\n\n    /**\n     * Band at 125 Hz\n     * @readonly\n     */\n    public static readonly F125: number = 125;\n\n    /**\n     * Band at 250 Hz\n     * @readonly\n     */\n    public static readonly F250: number = 250;\n\n    /**\n     * Band at 500 Hz\n     * @readonly\n     */\n    public static readonly F500: number = 500;\n\n    /**\n     * Band at 1000 Hz\n     * @readonly\n     */\n    public static readonly F1K: number = 1000;\n\n    /**\n     * Band at 2000 Hz\n     * @readonly\n     */\n    public static readonly F2K: number = 2000;\n\n    /**\n     * Band at 4000 Hz\n     * @readonly\n     */\n    public static readonly F4K: number = 4000;\n\n    /**\n     * Band at 8000 Hz\n     * @readonly\n     */\n    public static readonly F8K: number = 8000;\n\n    /**\n     * Band at 16000 Hz\n     * @readonly\n     */\n    public static readonly F16K: number = 16000;\n\n    /**\n     * The list of bands\n     * @readonly\n     */\n    public readonly bands: BiquadFilterNode[];\n\n    /**\n     * The map of bands to frequency\n     * @readonly\n     */\n    public readonly bandsMap: Record<number, BiquadFilterNode>;\n\n    /**\n     * @param f32 - Default gain for 32 Hz\n     * @param f64 - Default gain for 64 Hz\n     * @param f125 - Default gain for 125 Hz\n     * @param f250 - Default gain for 250 Hz\n     * @param f500 - Default gain for 500 Hz\n     * @param f1k - Default gain for 1000 Hz\n     * @param f2k - Default gain for 2000 Hz\n     * @param f4k - Default gain for 4000 Hz\n     * @param f8k - Default gain for 8000 Hz\n     * @param f16k - Default gain for 16000 Hz\n     */\n    constructor(f32 = 0, f64 = 0, f125 = 0, f250 = 0, f500 = 0,\n        f1k = 0, f2k = 0, f4k = 0, f8k = 0, f16k = 0)\n    {\n        let bands: BiquadFilterNode[] = [];\n\n        const equalizerBands: Band[] = [\n            {\n                f: EqualizerFilter.F32,\n                type: 'lowshelf',\n                gain: f32,\n            },\n            {\n                f: EqualizerFilter.F64,\n                type: 'peaking',\n                gain: f64,\n            },\n            {\n                f: EqualizerFilter.F125,\n                type: 'peaking',\n                gain: f125,\n            },\n            {\n                f: EqualizerFilter.F250,\n                type: 'peaking',\n                gain: f250,\n            },\n            {\n                f: EqualizerFilter.F500,\n                type: 'peaking',\n                gain: f500,\n            },\n            {\n                f: EqualizerFilter.F1K,\n                type: 'peaking',\n                gain: f1k,\n            },\n            {\n                f: EqualizerFilter.F2K,\n                type: 'peaking',\n                gain: f2k,\n            },\n            {\n                f: EqualizerFilter.F4K,\n                type: 'peaking',\n                gain: f4k,\n            },\n            {\n                f: EqualizerFilter.F8K,\n                type: 'peaking',\n                gain: f8k,\n            },\n            {\n                f: EqualizerFilter.F16K,\n                type: 'highshelf',\n                gain: f16k,\n            },\n        ];\n\n        if (!getInstance().useLegacy)\n        {\n            bands = equalizerBands.map((band: Band) =>\n            {\n                const node: BiquadFilterNode = getInstance().context.audioContext.createBiquadFilter();\n\n                node.type = band.type as BiquadFilterType;\n                WebAudioUtils.setParamValue(node.Q, 1);\n                node.frequency.value = band.f; // WebAudioUtils.setParamValue(filter.frequency, band.f);\n                WebAudioUtils.setParamValue(node.gain, band.gain);\n\n                return node;\n            });\n        }\n\n        // Setup the constructor AudioNode, where first is the input, and last is the output\n        super(bands[0]!, bands[bands.length - 1]);\n\n        // Manipulate the bands\n        this.bands = bands;\n\n        // Create a map\n        this.bandsMap = {};\n\n        for (let i = 0; i < this.bands.length; i++)\n        {\n            const node = this.bands[i]!;\n\n            // Connect the previous band to the current one\n            if (i > 0)\n            {\n                this.bands[i - 1]!.connect(node);\n            }\n            this.bandsMap[node.frequency.value] = node;\n        }\n    }\n\n    /**\n     * Set gain on a specific frequency.\n     * @param frequency - The frequency, see EqualizerFilter.F* for bands\n     * @param gain - Recommended -40 to 40.\n     */\n    public setGain(frequency: number, gain = 0): void\n    {\n        if (!this.bandsMap[frequency])\n        {\n            throw new Error(`No band found for frequency ${frequency}`);\n        }\n        WebAudioUtils.setParamValue(this.bandsMap[frequency].gain, gain);\n    }\n\n    /**\n     * Get gain amount on a specific frequency.\n     * @return The amount of gain set.\n     */\n    public getGain(frequency: number): number\n    {\n        if (!this.bandsMap[frequency])\n        {\n            throw new Error(`No band found for frequency ${frequency}`);\n        }\n\n        return this.bandsMap[frequency].gain.value;\n    }\n\n    /**\n     * Gain at 32 Hz frequencey.\n     * @default 0\n     */\n    public set f32(value: number)\n    {\n        this.setGain(EqualizerFilter.F32, value);\n    }\n    public get f32(): number\n    {\n        return this.getGain(EqualizerFilter.F32);\n    }\n\n    /**\n     * Gain at 64 Hz frequencey.\n     * @default 0\n     */\n    public set f64(value: number)\n    {\n        this.setGain(EqualizerFilter.F64, value);\n    }\n    public get f64(): number\n    {\n        return this.getGain(EqualizerFilter.F64);\n    }\n\n    /**\n     * Gain at 125 Hz frequencey.\n     * @default 0\n     */\n    public set f125(value: number)\n    {\n        this.setGain(EqualizerFilter.F125, value);\n    }\n    public get f125(): number\n    {\n        return this.getGain(EqualizerFilter.F125);\n    }\n\n    /**\n     * Gain at 250 Hz frequencey.\n     * @default 0\n     */\n    public set f250(value: number)\n    {\n        this.setGain(EqualizerFilter.F250, value);\n    }\n    public get f250(): number\n    {\n        return this.getGain(EqualizerFilter.F250);\n    }\n\n    /**\n     * Gain at 500 Hz frequencey.\n     * @default 0\n     */\n    public set f500(value: number)\n    {\n        this.setGain(EqualizerFilter.F500, value);\n    }\n    public get f500(): number\n    {\n        return this.getGain(EqualizerFilter.F500);\n    }\n\n    /**\n     * Gain at 1 KHz frequencey.\n     * @default 0\n     */\n    public set f1k(value: number)\n    {\n        this.setGain(EqualizerFilter.F1K, value);\n    }\n    public get f1k(): number\n    {\n        return this.getGain(EqualizerFilter.F1K);\n    }\n\n    /**\n     * Gain at 2 KHz frequencey.\n     * @default 0\n     */\n    public set f2k(value: number)\n    {\n        this.setGain(EqualizerFilter.F2K, value);\n    }\n    public get f2k(): number\n    {\n        return this.getGain(EqualizerFilter.F2K);\n    }\n\n    /**\n     * Gain at 4 KHz frequencey.\n     * @default 0\n     */\n    public set f4k(value: number)\n    {\n        this.setGain(EqualizerFilter.F4K, value);\n    }\n    public get f4k(): number\n    {\n        return this.getGain(EqualizerFilter.F4K);\n    }\n\n    /**\n     * Gain at 8 KHz frequencey.\n     * @default 0\n     */\n    public set f8k(value: number)\n    {\n        this.setGain(EqualizerFilter.F8K, value);\n    }\n    public get f8k(): number\n    {\n        return this.getGain(EqualizerFilter.F8K);\n    }\n\n    /**\n     * Gain at 16 KHz frequencey.\n     * @default 0\n     */\n    public set f16k(value: number)\n    {\n        this.setGain(EqualizerFilter.F16K, value);\n    }\n    public get f16k(): number\n    {\n        return this.getGain(EqualizerFilter.F16K);\n    }\n\n    /** Reset all frequency bands to have gain of 0 */\n    public reset(): void\n    {\n        this.bands.forEach((band: BiquadFilterNode) =>\n        {\n            WebAudioUtils.setParamValue(band.gain, 0);\n        });\n    }\n\n    public destroy(): void\n    {\n        this.bands.forEach((band: BiquadFilterNode) =>\n        {\n            band.disconnect();\n        });\n        (this as any).bands = null;\n        (this as any).bandsMap = null;\n    }\n}\n\nexport { EqualizerFilter };\n","import { getInstance } from '../instance';\nimport { Filter } from './Filter';\n\n/**\n * Combine all channels into mono channel.\n *\n * @memberof filters\n */\nclass MonoFilter extends Filter\n{\n    /** Merger node */\n    private _merger: ChannelMergerNode;\n\n    constructor()\n    {\n        let merger!: ChannelMergerNode;\n        let splitter!: ChannelSplitterNode;\n\n        if (!getInstance().useLegacy)\n        {\n            const { audioContext } = getInstance().context;\n\n            splitter = audioContext.createChannelSplitter();\n            merger = audioContext.createChannelMerger();\n            merger.connect(splitter);\n        }\n        super(merger, splitter);\n        this._merger = merger;\n    }\n\n    public destroy(): void\n    {\n        this._merger?.disconnect();\n        this._merger = null!;\n        super.destroy();\n    }\n}\n\nexport { MonoFilter };\n","import { getInstance } from '../instance';\nimport { Filter } from './Filter';\n\n/**\n * Filter for adding reverb. Refactored from\n * https://github.com/web-audio-components/simple-reverb/\n *\n * @memberof filters\n */\nclass ReverbFilter extends Filter\n{\n    private _seconds: number;\n    private _decay: number;\n    private _reverse: boolean;\n\n    /**\n     * @param seconds - Seconds for reverb\n     * @param decay - The decay length\n     * @param reverse - Reverse reverb\n     */\n    constructor(seconds = 3, decay = 2, reverse = false)\n    {\n        super(null!);\n        this._seconds = this._clamp(seconds, 1, 50);\n        this._decay = this._clamp(decay, 0, 100);\n        this._reverse = reverse;\n        this._rebuild();\n    }\n\n    /**\n     * Clamp a value\n     * @param value\n     * @param min - Minimum value\n     * @param max - Maximum value\n     * @return Clamped number\n     */\n    private _clamp(value: number, min: number, max: number): number\n    {\n        return Math.min(max, Math.max(min, value));\n    }\n\n    /**\n     * Length of reverb in seconds from 1 to 50\n     * @default 3\n     */\n    get seconds(): number\n    {\n        return this._seconds;\n    }\n    set seconds(seconds: number)\n    {\n        this._seconds = this._clamp(seconds, 1, 50);\n        this._rebuild();\n    }\n\n    /**\n     * Decay value from 0 to 100\n     * @default 2\n     */\n    get decay(): number\n    {\n        return this._decay;\n    }\n    set decay(decay: number)\n    {\n        this._decay = this._clamp(decay, 0, 100);\n        this._rebuild();\n    }\n\n    /**\n     * Reverse value from 0 to 1\n     * @default false\n     */\n    get reverse(): boolean\n    {\n        return this._reverse;\n    }\n    set reverse(reverse: boolean)\n    {\n        this._reverse = reverse;\n        this._rebuild();\n    }\n\n    /**\n     * Utility function for building an impulse response\n     * from the module parameters.\n     */\n    private _rebuild(): void\n    {\n        if (getInstance().useLegacy)\n        {\n            return;\n        }\n        const { audioContext } = getInstance().context;\n        const rate: number = audioContext.sampleRate;\n        const length: number = rate * this._seconds;\n        const impulse: AudioBuffer = audioContext.createBuffer(2, length, rate);\n        const impulseL: Float32Array = impulse.getChannelData(0);\n        const impulseR: Float32Array = impulse.getChannelData(1);\n        let n: number;\n\n        for (let i = 0; i < length; i++)\n        {\n            n = this._reverse ? length - i : i;\n            impulseL[i] = ((Math.random() * 2) - 1) * Math.pow(1 - (n / length), this._decay);\n            impulseR[i] = ((Math.random() * 2) - 1) * Math.pow(1 - (n / length), this._decay);\n        }\n        const convolver = audioContext.createConvolver();\n\n        convolver.buffer = impulse;\n        this.init(convolver);\n    }\n}\n\nexport { ReverbFilter };\n","import { getInstance } from '../instance';\nimport { WebAudioUtils } from '../webaudio/WebAudioUtils';\nimport { Filter } from './Filter';\n\n/**\n * Filter for adding Stereo panning.\n *\n * @memberof filters\n */\nclass StereoFilter extends Filter\n{\n    /** The stereo panning node */\n    private _stereo: StereoPannerNode | undefined;\n\n    /** The stereo panning node */\n    private _panner: PannerNode | undefined;\n\n    /** The amount of panning, -1 is left, 1 is right, 0 is centered */\n    private _pan!: number;\n\n    /** @param pan - The amount of panning, -1 is left, 1 is right, 0 is centered. */\n    constructor(pan = 0)\n    {\n        let stereo: StereoPannerNode | undefined;\n        let panner: PannerNode | undefined;\n        let destination!: AudioNode;\n\n        if (!getInstance().useLegacy)\n        {\n            const { audioContext } = getInstance().context;\n\n            if (audioContext.createStereoPanner)\n            {\n                stereo = audioContext.createStereoPanner();\n                destination = stereo;\n            }\n            else\n            {\n                panner = audioContext.createPanner();\n                panner.panningModel = 'equalpower';\n                destination = panner;\n            }\n        }\n\n        super(destination);\n\n        this._stereo = stereo;\n        this._panner = panner;\n\n        this.pan = pan;\n    }\n\n    /** Set the amount of panning, where -1 is left, 1 is right, and 0 is centered */\n    set pan(value: number)\n    {\n        this._pan = value;\n        if (this._stereo)\n        {\n            WebAudioUtils.setParamValue(this._stereo.pan, value);\n        }\n        else if (this._panner)\n        {\n            this._panner.setPosition(value, 0, 1 - Math.abs(value));\n        }\n    }\n    get pan(): number\n    {\n        return this._pan;\n    }\n\n    public destroy(): void\n    {\n        super.destroy();\n        this._stereo = null!;\n        this._panner = null!;\n    }\n}\n\nexport { StereoFilter };\n","import { getInstance } from '../instance';\nimport { Filter } from './Filter';\n\n/**\n * Export a MediaStream to be recorded\n *\n * @memberof filters\n */\nclass StreamFilter extends Filter\n{\n    private _stream: MediaStream;\n\n    constructor()\n    {\n        let destination!: MediaStreamAudioDestinationNode;\n        let source!: MediaStreamAudioSourceNode;\n\n        if (!getInstance().useLegacy)\n        {\n            const { audioContext } = getInstance().context;\n\n            destination = audioContext.createMediaStreamDestination();\n            source = audioContext.createMediaStreamSource(destination.stream);\n        }\n\n        super(destination, source);\n        this._stream = destination?.stream;\n    }\n\n    public get stream(): MediaStream\n    {\n        return this._stream;\n    }\n\n    public destroy(): void\n    {\n        this._stream = null!;\n        super.destroy();\n    }\n}\n\nexport { StreamFilter };\n","import { getInstance } from '../instance';\nimport { WebAudioUtils } from '../webaudio/WebAudioUtils';\nimport { Filter } from './Filter';\n\n/**\n * Creates a telephone-sound filter.\n *\n * @memberof filters\n */\nclass TelephoneFilter extends Filter\n{\n    constructor()\n    {\n        let destination!: AudioNode;\n        let source!: AudioNode;\n\n        if (!getInstance().useLegacy)\n        {\n            const { audioContext } = getInstance().context;\n            const lpf1 = audioContext.createBiquadFilter();\n            const lpf2 = audioContext.createBiquadFilter();\n            const hpf1 = audioContext.createBiquadFilter();\n            const hpf2 = audioContext.createBiquadFilter();\n\n            lpf1.type = 'lowpass';\n            WebAudioUtils.setParamValue(lpf1.frequency, 2000.0);\n\n            lpf2.type = 'lowpass';\n            WebAudioUtils.setParamValue(lpf2.frequency, 2000.0);\n\n            hpf1.type = 'highpass';\n            WebAudioUtils.setParamValue(hpf1.frequency, 500.0);\n\n            hpf2.type = 'highpass';\n            WebAudioUtils.setParamValue(hpf2.frequency, 500.0);\n\n            lpf1.connect(lpf2);\n            lpf2.connect(hpf1);\n            hpf1.connect(hpf2);\n\n            destination = lpf1;\n            source = hpf2;\n        }\n\n        super(destination, source);\n    }\n}\n\nexport { TelephoneFilter };\n","import { EventEmitter } from 'pixi.js';\nimport { type Filter } from '../filters/Filter';\nimport { type IMediaContext } from '../interfaces/IMediaContext';\n\n/**\n * The fallback version of WebAudioContext which uses `<audio>` instead of WebAudio API.\n * @memberof htmlaudio\n * @extends PIXI.EventEmitter\n */\nclass HTMLAudioContext extends EventEmitter implements IMediaContext\n{\n    /** Current global speed from 0 to 1 */\n    public speed = 1;\n\n    /** Current muted status of the context */\n    public muted = false;\n\n    /** Current volume from 0 to 1  */\n    public volume = 1;\n\n    /** Current paused status */\n    private _paused = false;\n\n    /** Internal trigger when volume, mute or speed changes */\n    public refresh(): void\n    {\n        this.emit('refresh');\n    }\n\n    /** Internal trigger paused changes */\n    public refreshPaused(): void\n    {\n        this.emit('refreshPaused');\n    }\n\n    /**\n     * Pauses or resumes all sounds, the same as `pauseAll()` and `resumeAll()`.\n     * @default false\n     */\n    public set paused(paused: boolean)\n    {\n        this._paused = paused;\n        this.refreshPaused();\n    }\n    public get paused(): boolean\n    {\n        return this._paused;\n    }\n\n    /**\n     * HTML Audio does not support filters, this is non-functional API.\n     */\n    public get filters(): Filter[]\n    {\n        console.warn('HTML Audio does not support filters');\n\n        return null!;\n    }\n    public set filters(_filters: Filter[])\n    {\n        console.warn('HTML Audio does not support filters');\n    }\n\n    /**\n     * HTML Audio does not support `audioContext`\n     * @readonly\n     * @type {AudioContext}\n     */\n    public get audioContext(): AudioContext\n    {\n        console.warn('HTML Audio does not support audioContext');\n\n        return null!;\n    }\n\n    /**\n     * Toggles the muted state.\n     * @return The current muted state.\n     */\n    public toggleMute(): boolean\n    {\n        this.muted = !this.muted;\n        this.refresh();\n\n        return this.muted;\n    }\n\n    /**\n     * Toggles the paused state.\n     * @return The current paused state.\n     */\n    public togglePause(): boolean\n    {\n        this.paused = !this.paused;\n\n        return this.paused;\n    }\n\n    /** Destroy and don't use after this */\n    public destroy(): void\n    {\n        this.removeAllListeners();\n    }\n}\n\nexport { HTMLAudioContext };\n","import { EventEmitter, Ticker } from 'pixi.js';\nimport { type Filter } from '../filters/Filter';\nimport { type IMediaInstance } from '../interfaces/IMediaInstance';\nimport { type PlayOptions } from '../Sound';\nimport { type HTMLAudioMedia } from './HTMLAudioMedia';\n\nlet id = 0;\n\n/**\n * Instance which wraps the `<audio>` element playback.\n * @memberof htmlaudio\n * @extends PIXI.EventEmitter\n */\nclass HTMLAudioInstance extends EventEmitter implements IMediaInstance\n{\n    /** Extra padding, in seconds, to deal with low-latecy of HTMLAudio. */\n    public static readonly PADDING: number = 0.1;\n\n    /** The current unique ID for this instance. */\n    public readonly id: number;\n\n    /** The instance of the Audio element. */\n    private _source!: HTMLAudioElement;\n\n    /** The instance of the Audio media element. */\n    private _media!: HTMLAudioMedia;\n\n    /** When playback ends, in seconds, including the padding. */\n    private _end!: number;\n\n    /** Current instance paused state. */\n    private _paused: boolean | undefined;\n\n    /** Current instance muted state. */\n    private _muted!: boolean;\n\n    /** Current actual paused state. */\n    private _pausedReal: boolean;\n\n    /** Total length of the audio. */\n    private _duration!: number;\n\n    /** Playback rate, where 1 is 100%. */\n    private _start!: number;\n\n    /** Volume for the instance. */\n    private _volume!: number;\n\n    /** Speed for the instance. */\n    private _speed!: number;\n\n    /** `true` for looping the playback */\n    private _loop!: boolean;\n\n    /** @param parent - Parent element */\n    constructor(parent: HTMLAudioMedia)\n    {\n        super();\n\n        this.id = id++;\n        this._pausedReal = false;\n\n        this.init(parent);\n    }\n\n    /**\n     * Set a property by name, this makes it easy to chain values\n     * @param name - Name of the property to set\n     * @param value - Value to set property to\n     */\n    public set(name: 'speed' | 'volume' | 'muted' | 'loop' | 'paused', value: number | boolean): this\n    {\n        if (this[name] === undefined)\n        {\n            throw new Error(`Property with name ${name} does not exist.`);\n        }\n        else\n        {\n            switch (name)\n            {\n                case 'speed': this.speed = value as number; break;\n                case 'volume': this.volume = value as number; break;\n                case 'paused': this.paused = value as boolean; break;\n                case 'loop': this.loop = value as boolean; break;\n                case 'muted': this.muted = value as boolean; break;\n            }\n        }\n\n        return this;\n    }\n\n    /** The current playback progress from 0 to 1. */\n    public get progress(): number\n    {\n        const { currentTime } = this._source;\n\n        return currentTime / this._duration;\n    }\n\n    /** Pauses the sound. */\n    public get paused(): boolean\n    {\n        return this._paused!;\n    }\n    public set paused(paused: boolean)\n    {\n        this._paused = paused;\n        this.refreshPaused();\n    }\n\n    /**\n     * Initialize the instance.\n     * @param {htmlaudio.HTMLAudioMedia} media - Same as constructor\n     */\n    public init(media: HTMLAudioMedia): void\n    {\n        this._duration = media.source.duration;\n        const source = this._source = media.source.cloneNode(false) as HTMLAudioElement;\n\n        source.src = media.parent.url;\n        media.context.on('refresh', this.refresh, this);\n        media.context.on('refreshPaused', this.refreshPaused, this);\n        this._media = media;\n    }\n\n    /**\n     * Stop the sound playing\n     * @private\n     */\n    private _internalStop(): void\n    {\n        if (this._source)\n        {\n            this._source.onended = null;\n            this._source.pause();\n        }\n    }\n\n    /** Stop the sound playing */\n    public stop(): void\n    {\n        this._internalStop();\n\n        if (this._source)\n        {\n            this.emit('stop');\n        }\n    }\n\n    /** Set the instance speed from 0 to 1 */\n    public get speed(): number\n    {\n        return this._speed;\n    }\n    public set speed(speed: number)\n    {\n        this._speed = speed;\n        this.refresh();\n    }\n\n    /** Get the set the volume for this instance from 0 to 1 */\n    public get volume(): number\n    {\n        return this._volume;\n    }\n    public set volume(volume: number)\n    {\n        this._volume = volume;\n        this.refresh();\n    }\n\n    /** If the sound instance should loop playback */\n    public get loop(): boolean\n    {\n        return this._loop;\n    }\n    public set loop(loop: boolean)\n    {\n        this._loop = loop;\n        this.refresh();\n    }\n\n    /** `true` if the sound is muted */\n    public get muted(): boolean\n    {\n        return this._muted;\n    }\n    public set muted(muted: boolean)\n    {\n        this._muted = muted;\n        this.refresh();\n    }\n\n    /**\n     * HTML Audio does not support filters, this is non-functional API.\n     */\n    public get filters(): Filter[]\n    {\n        console.warn('HTML Audio does not support filters');\n\n        return null!;\n    }\n    public set filters(_filters: Filter[])\n    {\n        console.warn('HTML Audio does not support filters');\n    }\n\n    /** Call whenever the loop, speed or volume changes */\n    public refresh(): void\n    {\n        const global = this._media.context;\n        const sound = this._media.parent;\n\n        // Update the looping\n        this._source.loop = this._loop || sound.loop;\n\n        // Update the volume\n        const globalVolume = global.volume * (global.muted ? 0 : 1);\n        const soundVolume = sound.volume * (sound.muted ? 0 : 1);\n        const channel = sound.channel;\n        const channelVolume = channel ? channel.volume * (channel.muted ? 0 : 1) : 1;\n        const instanceVolume = this._volume * (this._muted ? 0 : 1);\n\n        this._source.volume = instanceVolume * soundVolume * channelVolume * globalVolume;\n\n        // Update the speed\n        this._source.playbackRate = this._speed * global.speed * sound.speed;\n    }\n\n    /** Handle changes in paused state, from the instance, sound, channel or global */\n    public refreshPaused(): void\n    {\n        const global = this._media.context;\n        const sound = this._media.parent;\n\n        // Handle the paused state, these can be undefined\n        const pausedReal = !!(this._paused || sound.paused || sound.channel?.paused || global.paused);\n\n        if (pausedReal !== this._pausedReal)\n        {\n            this._pausedReal = pausedReal;\n\n            if (pausedReal)\n            {\n                this._internalStop();\n\n                /**\n                 * The sound is paused.\n                 * @event paused\n                 */\n                this.emit('paused');\n            }\n            else\n            {\n                /**\n                 * The sound is unpaused.\n                 * @event resumed\n                 */\n                this.emit('resumed');\n\n                // A whole-file play stores the duration as its end,\n                // and passing that back would turn the loop off\n                let end: number | null = this._end;\n\n                if (this._loop)\n                {\n                    end = null;\n                }\n\n                // resume the playing with offset\n                this.play({\n                    start: this._source.currentTime,\n                    end,\n                    volume: this._volume,\n                    speed: this._speed,\n                    loop: this._loop,\n                    muted: this._muted,\n                });\n\n                // play() pads the end again, so keep the end the first play() padded. A loop passes\n                // no end and keeps play()'s (the duration), so turning the loop off still plays on\n                this._end = end ?? this._end;\n            }\n\n            /**\n             * The sound is paused or unpaused.\n             * @event pause\n             * @property {boolean} paused - If the instance was paused or not.\n             */\n            this.emit('pause', pausedReal);\n        }\n    }\n\n    /** Start playing the sound/ */\n    public play(options: PlayOptions): void\n    {\n        const { start, end, speed, loop, volume, muted } = options;\n\n        if (end)\n        {\n            // eslint-disable-next-line no-console\n            console.assert(end > start!, 'End time is before start time');\n        }\n\n        this._speed = speed!;\n        this._volume = volume!;\n        this._loop = !!loop;\n        this._muted = muted!;\n        this.refresh();\n\n        // WebAudio doesn't support looping when a duration is set\n        // we'll set this just for the heck of it\n        if (this.loop && end !== null)\n        {\n            console.warn('Looping not support when specifying an \"end\" time');\n            this.loop = false;\n        }\n\n        this._start = start!;\n        this._end = end || this._duration;\n\n        // Lets expand the start and end a little\n        // to deal with the low-latecy of playing audio this way\n        // this is a little fudge-factor\n        this._start = Math.max(0, this._start - HTMLAudioInstance.PADDING);\n        this._end = Math.min(this._end + HTMLAudioInstance.PADDING, this._duration);\n\n        // Set now so a resume before the metadata loads reads the start back. The handler sets it again,\n        // as Firefox can lose a position set this early. Skipped when it's already there: a seek to the\n        // same place still delays a resume\n        if (this._source.currentTime !== start)\n        {\n            this._source.currentTime = start!;\n        }\n        // On the data rather than the metadata: Firefox can load the metadata before the element can seek\n        this._source.onloadeddata = () =>\n        {\n            if (this._source)\n            {\n                this._source.currentTime = start!;\n                this._source.onloadeddata = null;\n                // Before the event, so a listener that stops the instance removes it\n                Ticker.shared.add(this._onUpdate, this);\n                this.emit('progress', start! / this._duration, this._duration);\n            }\n        };\n        this._source.onended = this._onComplete.bind(this);\n        this._source.play()?.catch((error: Error) =>\n        {\n            // A pause before playback starts rejects play()\n            if (error.name !== 'AbortError')\n            {\n                throw error;\n            }\n        });\n\n        // There's no AudioContext to suspend, so a play during pauseAll() waits here for resumeAll(),\n        // which reads the position back from the element. A play into a paused sound or channel waits the same way\n        const sound = this._media.parent;\n\n        if (this._media.context.paused || sound.paused || sound.channel?.paused)\n        {\n            this._pausedReal = true;\n            this._internalStop();\n        }\n\n        // Last, as a listener can stop the instance, which resets it for the pool\n        /**\n         * The sound is started.\n         * @event start\n         */\n        this.emit('start');\n    }\n\n    /**\n     * Handle time update on sound.\n     * @private\n     */\n    private _onUpdate(): void\n    {\n        this.emit('progress', this.progress, this._duration);\n        // A listener can stop the instance\n        if (this._source && this._source.currentTime >= this._end && !this._source.loop)\n        {\n            this._onComplete();\n        }\n    }\n\n    /**\n     * Callback when completed.\n     * @private\n     */\n    private _onComplete(): void\n    {\n        Ticker.shared.remove(this._onUpdate, this);\n        this._internalStop();\n        this.emit('progress', 1, this._duration);\n        /**\n         * The sound ends, don't use after this\n         * @event end\n         */\n        this.emit('end', this);\n    }\n\n    /** Don't use after this. */\n    public destroy(): void\n    {\n        Ticker.shared.remove(this._onUpdate, this);\n        this.removeAllListeners();\n\n        const source = this._source;\n\n        if (source)\n        {\n            // Remove the listeners\n            source.onended = null;\n            source.onloadeddata = null;\n\n            this._internalStop();\n        }\n\n        this._source = null!;\n        this._speed = 1;\n        this._volume = 1;\n        this._loop = false;\n        this._end = null!;\n        this._start = 0;\n        this._duration = 0;\n        this._pausedReal = false;\n        this._paused = false;\n        this._muted = false;\n\n        if (this._media)\n        {\n            // The context is gone after close()\n            this._media.context?.off('refresh', this.refresh, this);\n            this._media.context?.off('refreshPaused', this.refreshPaused, this);\n            this._media = null!;\n        }\n    }\n\n    /**\n     * To string method for instance.\n     * @return The string representation of instance.\n     */\n    public toString(): string\n    {\n        return `[HTMLAudioInstance id=${this.id}]`;\n    }\n}\n\nexport { HTMLAudioInstance };\n","import { EventEmitter } from 'pixi.js';\nimport { type Filter } from '../filters/Filter';\nimport { type IMedia } from '../interfaces/IMedia';\nimport { type LoadedCallback, type Sound } from '../Sound';\nimport { type HTMLAudioContext } from './HTMLAudioContext';\nimport { HTMLAudioInstance } from './HTMLAudioInstance';\n\n/**\n * The fallback version of Sound which uses `<audio>` instead of WebAudio API.\n * @memberof htmlaudio\n * @extends PIXI.EventEmitter\n */\nclass HTMLAudioMedia extends EventEmitter implements IMedia\n{\n    public parent!: Sound;\n    private _source!: HTMLAudioElement;\n\n    public init(parent: Sound): void\n    {\n        this.parent = parent;\n        this._source = parent.options.source as HTMLAudioElement || new Audio();\n        if (parent.url)\n        {\n            this._source.src = parent.url;\n        }\n    }\n\n    // Implement create\n    public create(): HTMLAudioInstance\n    {\n        return new HTMLAudioInstance(this);\n    }\n\n    /**\n     * If the audio media is playable (ready).\n     * @readonly\n     */\n    public get isPlayable(): boolean\n    {\n        return !!this._source && this._source.readyState === 4;\n    }\n\n    /**\n     * The duration of the media in seconds, or `NaN` until the element has loaded its metadata.\n     * @readonly\n     */\n    public get duration(): number\n    {\n        return this._source.duration;\n    }\n\n    /**\n     * Reference to the context.\n     * @readonly\n     */\n    public get context(): HTMLAudioContext\n    {\n        return this.parent.context as HTMLAudioContext;\n    }\n\n    /** The collection of filters, does not apply to HTML Audio. */\n    public get filters(): Filter[]\n    {\n        return null!;\n    }\n    public set filters(_filters: Filter[])\n    {\n        console.warn('HTML Audio does not support filters');\n    }\n\n    // Override the destroy\n    public destroy(): void\n    {\n        this.removeAllListeners();\n\n        this.parent = null!;\n\n        if (this._source)\n        {\n            this._source.src = '';\n            this._source.load();\n            this._source = null!;\n        }\n    }\n\n    /**\n     * Get the audio source element.\n     * @type {HTMLAudioElement}\n     * @readonly\n     */\n    public get source(): HTMLAudioElement\n    {\n        return this._source;\n    }\n\n    // Implement the method to being preloading\n    public load(callback?: LoadedCallback): void\n    {\n        const source = this._source;\n        const sound = this.parent;\n\n        // See if the source is already loaded\n        if (source.readyState === 4)\n        {\n            sound.isLoaded = true;\n            const instance = sound.autoPlayStart();\n\n            if (callback)\n            {\n                setTimeout(() =>\n                {\n                    callback(null!, sound, instance);\n                }, 0);\n            }\n\n            return;\n        }\n\n        // If there's no source, we cannot load\n        if (!sound.url)\n        {\n            callback!(new Error('sound.url or sound.source must be set'));\n\n            return;\n        }\n\n        // Set the source\n        source.src = sound.url;\n\n        const onLoad = () =>\n        {\n            // eslint-disable-next-line @typescript-eslint/no-use-before-define\n            removeListeners();\n            sound.isLoaded = true;\n            const instance = sound.autoPlayStart();\n\n            if (callback)\n            {\n                callback(null!, sound, instance);\n            }\n        };\n\n        const onAbort = () =>\n        {\n            // eslint-disable-next-line @typescript-eslint/no-use-before-define\n            removeListeners();\n            if (callback)\n            {\n                callback(new Error('Sound loading has been aborted'));\n            }\n        };\n\n        const onError = () =>\n        {\n            // eslint-disable-next-line @typescript-eslint/no-use-before-define\n            removeListeners();\n            const message = `Failed to load audio element (code: ${source.error!.code})`;\n\n            if (callback)\n            {\n                callback(new Error(message));\n            }\n            else\n            {\n                console.error(message);\n            }\n        };\n\n        // Remove all event listeners\n        const removeListeners = () =>\n        {\n            // Listen for callback\n            source.removeEventListener('canplaythrough', onLoad);\n            source.removeEventListener('load', onLoad);\n            source.removeEventListener('abort', onAbort);\n            source.removeEventListener('error', onError);\n        };\n\n        // Listen for callback\n        source.addEventListener('canplaythrough', onLoad, false);\n        source.addEventListener('load', onLoad, false);\n        source.addEventListener('abort', onAbort, false);\n        source.addEventListener('error', onError, false);\n\n        // Begin the loading\n        source.load();\n    }\n}\n\nexport { HTMLAudioMedia };\n","import { type IMediaInstance } from './interfaces';\nimport { type CompleteCallback, type Sound } from './Sound';\n\n/** Data for adding new sound sprites. */\ninterface SoundSpriteData\n{\n    /** The start time in seconds. */\n    start: number;\n    /** The end time in seconds. */\n    end: number;\n    /**\n     * The optional speed, where 1 is 100% speed. Defaults to 1.\n     * The parent sound's speed still applies on top of it.\n     * A `speed` passed to `play()` overrides it.\n     */\n    speed?: number;\n}\n\n// Collection of sound sprites\ntype SoundSprites = Record<string, SoundSprite>;\n\n/**\n * Object that represents a single Sound's sprite. To add sound sprites\n * use the {@link Sound#addSprites} method.\n * @example\n * import { sound } from '@pixi/sound';\n * sound.add('alias', {\n *   url: 'path/to/file.ogg',\n *   sprites: {\n *     blast: { start: 0, end: 0.2 },\n *     boom: { start: 0.3, end: 0.5 },\n *   },\n *   loaded() {\n *     sound.play('alias', 'blast');\n *   }\n * );\n *\n */\nclass SoundSprite\n{\n    /**\n     * The reference sound\n     * @readonly\n     */\n    public parent: Sound;\n\n    /**\n     * The starting location in seconds.\n     * @readonly\n     */\n    public start!: number;\n\n    /**\n     * The ending location in seconds\n     * @readonly\n     */\n    public end!: number;\n\n    /**\n     * Default instance speed for this sprite, where 1 is 100%.\n     * The parent sound's speed multiplies it.\n     * @readonly\n     */\n    public speed!: number;\n\n    /**\n     * The duration of the sound in seconds.\n     * @readonly\n     */\n    public duration: number;\n\n    /**\n     * Whether to loop the sound sprite.\n     * @readonly\n     */\n    public loop!: boolean;\n\n    /**\n     * @param parent - The parent sound\n     * @param options - Data associated with object.\n     */\n    constructor(parent: Sound, options: SoundSpriteData)\n    {\n        this.parent = parent;\n        Object.assign(this, options);\n        this.duration = this.end - this.start;\n\n        // eslint-disable-next-line no-console\n        console.assert(this.duration > 0, 'End time must be after start time');\n    }\n\n    /**\n     * Play the sound sprite.\n     * @param {Function} [complete] - Function call when complete\n     * @return Sound instance being played.\n     */\n    public play(complete?: CompleteCallback): IMediaInstance | Promise<IMediaInstance>\n    {\n        return this.parent.play({\n            complete,\n            speed: this.speed || 1,\n            end: this.end,\n            start: this.start,\n            loop: this.loop\n        });\n    }\n\n    /** Destroy and don't use after this */\n    public destroy(): void\n    {\n        this.parent = null!;\n    }\n}\n\nexport type { SoundSpriteData, SoundSprites };\nexport { SoundSprite };\n","type ExtensionMap = Record<string, boolean>;\n\n/**\n * The list of extensions that can be played. This is the preferred order of playback.\n * If you want to priority the order of playback, you can use this array to do so.\n * @readonly\n * @memberof utils\n */\nconst extensions: string[] = [\n    'ogg',\n    'oga',\n    'opus',\n    'm4a',\n    'mp3',\n    'mpeg',\n    'wav',\n    'aiff',\n    'wma',\n    'mid',\n    'caf',\n];\n\nconst mimes: string[] = [\n    'audio/mpeg',\n    'audio/ogg',\n];\n\n/**\n * The list of browser supported audio formats.\n * @readonly\n * @memberof utils\n * @property {boolean} mp3 - `true` if file-type is supported\n * @property {boolean} ogg - `true` if file-type is supported\n * @property {boolean} oga - `true` if file-type is supported\n * @property {boolean} opus - `true` if file-type is supported\n * @property {boolean} mpeg - `true` if file-type is supported\n * @property {boolean} wav - `true` if file-type is supported\n * @property {boolean} aiff - `true` if file-type is supported\n * @property {boolean} wma - `true` if file-type is supported\n * @property {boolean} mid - `true` if file-type is supported\n * @property {boolean} caf - `true` if file-type is supported. Note that for this we check if the\n *                             'opus' codec is supported inside the caf container.\n */\nconst supported: ExtensionMap = {};\n\n/**\n * Function to validate file type formats. This is called when the library initializes, but can\n * be called again if you need to recognize a format not listed in `utils.extensions` at\n * initialization.\n * @memberof utils\n * @param typeOverrides - - Dictionary of type overrides (inputs for\n *                                 AudioElement.canPlayType()), keyed by extension from the\n *                                 utils.extensions array.\n */\nfunction validateFormats(typeOverrides?: Record<string, string>): void\n{\n    const overrides: Record<string, string> = {\n        m4a: 'audio/mp4',\n        oga: 'audio/ogg',\n        opus: 'audio/ogg; codecs=\"opus\"',\n        caf: 'audio/x-caf; codecs=\"opus\"', ...(typeOverrides || {})\n    };\n    const audio = document.createElement('audio');\n    const formats: ExtensionMap = {};\n    const no = /^no$/;\n\n    extensions.forEach((ext) =>\n    {\n        const canByExt = audio.canPlayType(`audio/${ext}`).replace(no, '');\n        const canByType = overrides[ext] ? audio.canPlayType(overrides[ext]).replace(no, '') : '';\n\n        formats[ext] = !!canByExt || !!canByType;\n    });\n    Object.assign(supported, formats);\n}\n\n// initialize supported\nvalidateFormats();\n\nexport {\n    extensions,\n    mimes,\n    supported,\n    validateFormats,\n};\n","/**\n * Copy of the options without the keys set to `undefined`, so spreading\n * them over the defaults doesn't replace a default with `undefined`.\n * @ignore\n */\nexport function withoutUndefined<T extends object>(options?: T): Partial<T>\n{\n    const result: Partial<T> = {};\n\n    for (const key of Object.keys(options || {}) as (keyof T)[])\n    {\n        if (options![key] !== undefined)\n        {\n            result[key] = options![key];\n        }\n    }\n\n    return result;\n}\n","import { EventEmitter, Ticker } from 'pixi.js';\nimport { type Filter } from '../filters/Filter';\nimport { type IMediaInstance } from '../interfaces';\nimport { type PlayOptions } from '../Sound';\nimport { type WebAudioMedia } from './WebAudioMedia';\nimport { WebAudioUtils } from './WebAudioUtils';\n\nlet id = 0;\n\n/**\n * A single play instance that handles the AudioBufferSourceNode.\n * @memberof webaudio\n * @extends PIXI.EventEmitter\n */\nclass WebAudioInstance extends EventEmitter implements IMediaInstance\n{\n    /**\n     * The current unique ID for this instance.\n     * @readonly\n     */\n    public readonly id: number;\n\n    /** The source Sound. */\n    private _media: WebAudioMedia;\n\n    /** true if paused. */\n    private _paused: boolean;\n\n    /** true if muted. */\n    private _muted: boolean;\n\n    /** true if paused. */\n    private _pausedReal: boolean;\n\n    /** The instance volume */\n    private _volume!: number;\n\n    /** Last update frame number. */\n    private _lastUpdate!: number;\n\n    /** The total number of seconds elapsed in playback. */\n    private _elapsed: number;\n\n    /** Playback rate, where 1 is 100%. */\n    private _speed!: number;\n\n    /** Playback rate, where 1 is 100%. */\n    private _end: number | null | undefined;\n\n    /** `true` if should be looping. */\n    private _loop!: boolean;\n\n    /**\n     * Start of the region from the first `play()`, looping or not, so a loop turned on later\n     * still starts there. Resume seeks inside this region instead of using the offset as `loopStart`.\n     */\n    private _loopRegionStart: number | null = null;\n\n    /** Gain node for controlling volume of instance */\n    private _gain!: GainNode;\n\n    /** Length of the sound in seconds. */\n    private _duration!: number;\n\n    /** The progress of the sound from 0 to 1. */\n    private _progress!: number;\n\n    /** Audio buffer source clone from Sound object. */\n    private _source: AudioBufferSourceNode | null | undefined;\n\n    /** The filters */\n    private _filters: Filter[] | null | undefined;\n\n    constructor(media: WebAudioMedia)\n    {\n        super();\n\n        this.id = id++;\n        this._media = null!;\n        this._paused = false;\n        this._pausedReal = false;\n        this._muted = false;\n        this._elapsed = 0;\n\n        // Initialize\n        this.init(media);\n    }\n\n    /**\n     * Set a property by name, this makes it easy to chain values\n     * @param name - Name of the property to set.\n     * @param value - Value to set property to.\n     */\n    public set(name: 'speed' | 'volume' | 'muted' | 'loop' | 'paused', value: number | boolean): this\n    {\n        if (this[name] === undefined)\n        {\n            throw new Error(`Property with name ${name} does not exist.`);\n        }\n        else\n        {\n            switch (name)\n            {\n                case 'speed': this.speed = value as number; break;\n                case 'volume': this.volume = value as number; break;\n                case 'muted': this.muted = value as boolean; break;\n                case 'loop': this.loop = value as boolean; break;\n                case 'paused': this.paused = value as boolean; break;\n            }\n        }\n\n        return this;\n    }\n\n    /** Stops the instance, don't use after this. */\n    public stop(): void\n    {\n        if (this._source || this._pausedReal)\n        {\n            this._internalStop();\n            this.emit('stop');\n        }\n    }\n\n    /** Set the instance speed from 0 to 1 */\n    public get speed(): number\n    {\n        return this._speed;\n    }\n    public set speed(speed: number)\n    {\n        this._speed = speed;\n        this.refresh();\n        this._update(true); // update progress\n    }\n\n    /** Get the set the volume for this instance from 0 to 1 */\n    public get volume(): number\n    {\n        return this._volume;\n    }\n    public set volume(volume: number)\n    {\n        this._volume = volume;\n        this.refresh();\n    }\n\n    /** `true` if the sound is muted */\n    public get muted(): boolean\n    {\n        return this._muted;\n    }\n    public set muted(muted: boolean)\n    {\n        this._muted = muted;\n        this.refresh();\n    }\n\n    /** If the sound instance should loop playback */\n    public get loop(): boolean\n    {\n        return this._loop;\n    }\n    public set loop(loop: boolean)\n    {\n        this._loop = loop;\n        this.refresh();\n    }\n\n    /** The collection of filters. */\n    public get filters(): Filter[]\n    {\n        return this._filters!;\n    }\n    public set filters(filters: Filter[])\n    {\n        if (this._filters)\n        {\n            this._filters?.filter((filter) => filter).forEach((filter) => filter.disconnect());\n            this._filters = null;\n            // A held instance has no source, and play() on resume connects the new filters\n            if (this._source)\n            {\n                // Reconnect the direct path, unhooking the old first filter\n                this._source.disconnect();\n                this._source.connect(this._gain);\n            }\n        }\n        this._filters = filters?.length ? filters.slice(0) : null;\n        this.refresh();\n    }\n\n    /** Refresh loop, volume and speed based on changes to parent */\n    public refresh(): void\n    {\n        // Sound could be paused\n        if (!this._source)\n        {\n            return;\n        }\n        const global = this._media.context;\n        const sound = this._media.parent;\n\n        // Updating looping\n        this._source.loop = this._loop || sound.loop;\n\n        // Update the volume\n        const globalVolume = global.volume * (global.muted ? 0 : 1);\n        const soundVolume = sound.volume * (sound.muted ? 0 : 1);\n        const channel = sound.channel;\n        const channelVolume = channel ? channel.volume * (channel.muted ? 0 : 1) : 1;\n        const instanceVolume = this._volume * (this._muted ? 0 : 1);\n\n        WebAudioUtils.setParamValue(this._gain.gain, instanceVolume * soundVolume * channelVolume * globalVolume);\n\n        // Update the speed\n        WebAudioUtils.setParamValue(this._source.playbackRate, this._speed * sound.speed * global.speed);\n\n        this.applyFilters();\n    }\n\n    /** Connect filters nodes to audio context */\n    private applyFilters(): void\n    {\n        if (this._filters?.length)\n        {\n            // Disconnect direct path before inserting filters\n            this._source!.disconnect();\n\n            // Connect each filter\n            let source: { connect: (node: AudioNode) => void } = this._source!;\n\n            this._filters.forEach((filter: Filter) =>\n            {\n                source.connect(filter.destination);\n                source = filter;\n            });\n            source.connect(this._gain);\n        }\n    }\n\n    /** Handle changes in paused state, from the instance, sound, channel or global */\n    public refreshPaused(): void\n    {\n        const global = this._media.context;\n        const sound = this._media.parent;\n\n        // Consider global and sound paused, these can be undefined\n        const pausedReal = !!(this._paused || sound.paused || sound.channel?.paused || global.paused);\n\n        if (pausedReal !== this._pausedReal)\n        {\n            this._pausedReal = pausedReal;\n\n            if (pausedReal)\n            {\n                // pause the sounds\n                this._internalStop();\n\n                /**\n                 * The sound is paused.\n                 * @event paused\n                 */\n                this.emit('paused');\n            }\n            else\n            {\n                /**\n                 * The sound is unpaused.\n                 * @event resumed\n                 */\n                this.emit('resumed');\n\n                // A tick can land after the end of a sprite and before `ended`: resume at the end, so it ends\n                const pastEnd = !this._loop && !!this._end && this._elapsed >= this._end;\n\n                // resume the playing with offset\n                this.play({\n                    start: pastEnd ? this._end! : this._elapsed % this._duration,\n                    end: this._end,\n                    speed: this._speed,\n                    loop: this._loop,\n                    volume: this._volume,\n                    muted: this._muted,\n                    filters: this._filters!,\n                });\n            }\n\n            /**\n             * The sound is paused or unpaused.\n             * @event pause\n             * @property {boolean} paused - If the instance was paused or not.\n             */\n            this.emit('pause', pausedReal);\n        }\n    }\n\n    /**\n     * Plays the sound.\n     * @param options - Play options.\n     */\n    public play(options: PlayOptions): void\n    {\n        const { end, speed, loop, volume, muted, filters } = options;\n        let { start } = options;\n\n        // A play() on an instance that is still playing starts a new region\n        if (this._source)\n        {\n            this._loopRegionStart = null;\n        }\n\n        // Resume passes `elapsed % bufferDuration` as start and play() would also\n        // use that value as loopStart, collapsing a sprite loop to its tail.\n        if (loop && this._loopRegionStart !== null)\n        {\n            const regionEnd = end ?? this._duration;\n            const length = regionEnd - this._loopRegionStart;\n\n            if (length > 0)\n            {\n                start = this._loopRegionStart + positiveModulo(this._elapsed - this._loopRegionStart, length);\n            }\n        }\n\n        if (end)\n        {\n            // eslint-disable-next-line no-console\n            console.assert(end >= start!, 'End time is before start time');\n        }\n        this._paused = false;\n        this._internalStop();\n        this._gain?.disconnect();\n        const { source, gain } = this._media.nodes.cloneBufferSource();\n\n        this._source = source;\n        this._gain = gain;\n        this._speed = speed!;\n        this._volume = volume!;\n        this._loop = !!loop;\n        this._muted = muted!;\n        this._filters = filters;\n        this.refresh();\n\n        const duration: number = this._source.buffer!.duration;\n\n        this._duration = duration;\n        this._end = end;\n        this._lastUpdate = this._now();\n        this._elapsed = start!;\n        this._source.onended = this._onComplete.bind(this);\n\n        if (this._loopRegionStart === null)\n        {\n            this._loopRegionStart = start ?? 0;\n        }\n\n        if (this._loop)\n        {\n            this._source.loopEnd = end!;\n            this._source.loopStart = this._loopRegionStart;\n            this._source.start(0, start);\n        }\n        else if (end)\n        {\n            this._source.start(0, start, end - start!);\n\n            // WebKit doesn't fire `ended` for a source with nothing to play\n            if (end === start)\n            {\n                this._source.stop(0);\n            }\n        }\n        else\n        {\n            this._source.start(0, start);\n        }\n\n        // Start handling internal ticks. Before the event, so a listener that stops the instance removes it\n        this.enableTicker(true);\n\n        // A play into a paused sound or channel is held. The source stops in the task it started in, so nothing\n        // is heard, and a resume plays from this start\n        const sound = this._media.parent;\n\n        if (sound.paused || sound.channel?.paused)\n        {\n            this._progress = start! / duration;\n            this._pausedReal = true;\n            this._internalStop();\n        }\n\n        /**\n         * The sound is started.\n         * @event start\n         */\n        this.emit('start');\n\n        // Do an update for the initial progress\n        this._update(true);\n    }\n\n    /** Start the update progress. */\n    private enableTicker(enabled: boolean): void\n    {\n        Ticker.shared.remove(this._updateListener, this);\n        if (enabled)\n        {\n            Ticker.shared.add(this._updateListener, this);\n        }\n    }\n\n    /** The current playback progress from 0 to 1. */\n    public get progress(): number\n    {\n        return this._progress;\n    }\n\n    /** Pauses the sound. */\n    public get paused(): boolean\n    {\n        return this._paused;\n    }\n\n    public set paused(paused: boolean)\n    {\n        this._paused = paused;\n        this.refreshPaused();\n    }\n\n    /** Don't use after this. */\n    public destroy(): void\n    {\n        this.removeAllListeners();\n        this._internalStop();\n        if (this._gain)\n        {\n            this._gain.disconnect();\n            this._gain = null!;\n        }\n        if (this._media)\n        {\n            // The context is gone after close()\n            this._media.context?.events.off('refresh', this.refresh, this);\n            this._media.context?.events.off('refreshPaused', this.refreshPaused, this);\n            this._media = null!;\n        }\n        this._filters?.forEach((filter) => filter.disconnect());\n        this._filters = null;\n        this._end = null;\n        this._speed = 1;\n        this._volume = 1;\n        this._loop = false;\n        this._elapsed = 0;\n        this._duration = 0;\n        this._paused = false;\n        this._muted = false;\n        this._pausedReal = false;\n        this._loopRegionStart = null;\n    }\n\n    /**\n     * To string method for instance.\n     * @return The string representation of instance.\n     */\n    public toString(): string\n    {\n        return `[WebAudioInstance id=${this.id}]`;\n    }\n\n    /**\n     * Get the current time in seconds.\n     * @return Seconds since start of context\n     */\n    private _now(): number\n    {\n        return this._media.context.audioContext.currentTime;\n    }\n\n    /** Callback for update listener */\n    private _updateListener()\n    {\n        this._update();\n    }\n\n    /** Internal update the progress. */\n    private _update(force = false): void\n    {\n        if (this._source)\n        {\n            const now: number = this._now();\n            const delta: number = now - this._lastUpdate;\n\n            if (delta > 0 || force)\n            {\n                const speed: number = this._source.playbackRate.value;\n\n                this._elapsed += delta * speed;\n                this._lastUpdate = now;\n                const duration: number = this._duration;\n                let progress: number;\n\n                if (this._source.loopStart)\n                {\n                    const soundLength = this._source.loopEnd - this._source.loopStart;\n\n                    progress = (this._source.loopStart + (this._elapsed % soundLength)) / duration;\n                }\n                else\n                {\n                    progress = (this._elapsed % duration) / duration;\n                }\n\n                // Update the progress\n                this._progress = progress;\n\n                /**\n                 * The sound progress is updated.\n                 * @event progress\n                 * @property {number} progress - Amount progressed from 0 to 1\n                 * @property {number} duration - The total playback in seconds\n                 */\n                this.emit('progress', this._progress, duration);\n            }\n        }\n    }\n\n    /** Initializes the instance. */\n    public init(media: WebAudioMedia): void\n    {\n        this._media = media;\n        media.context.events.on('refresh', this.refresh, this);\n        media.context.events.on('refreshPaused', this.refreshPaused, this);\n    }\n\n    /** Stops the instance. */\n    private _internalStop(): void\n    {\n        if (this._source)\n        {\n            this.enableTicker(false);\n            this._source.onended = null;\n            try\n            {\n                this._source.stop(0); // param needed for iOS 8 bug\n            }\n            catch (err)\n            {\n                // A source that never started can't be stopped, e.g. play() threw before start()\n                if ((err as DOMException).name !== 'InvalidStateError')\n                {\n                    throw err;\n                }\n            }\n            this._source.disconnect();\n            try\n            {\n                this._source.buffer = null;\n            }\n            catch (err)\n            {\n                // try/catch workaround for bug in older Chrome versions\n                console.warn('Failed to set AudioBufferSourceNode.buffer to null:', err);\n            }\n            this._source = null;\n        }\n    }\n\n    /** Callback when completed. */\n    private _onComplete(): void\n    {\n        if (this._source)\n        {\n            this.enableTicker(false);\n            this._source.onended = null;\n            this._source.disconnect();\n            try\n            {\n                this._source.buffer = null;\n            }\n            catch (err)\n            {\n                // try/catch workaround for bug in older Chrome versions\n                console.warn('Failed to set AudioBufferSourceNode.buffer to null:', err);\n            }\n        }\n        this._source = null;\n        this._progress = 1;\n        this.emit('progress', 1, this._duration);\n        /**\n         * The sound ends, don't use after this\n         * @event end\n         */\n        this.emit('end', this);\n    }\n}\n\n/** Non-negative remainder. Playback elapsed can sit slightly below the region start. */\nfunction positiveModulo(value: number, length: number): number\n{\n    return ((value % length) + length) % length;\n}\n\nexport { WebAudioInstance };\n","import { type Filter } from './filters/Filter';\n\n/**\n * Abstract class which SoundNodes and SoundContext\n * both extend. This provides the functionality for adding\n * dynamic filters.\n */\nclass Filterable\n{\n    /** Get the gain node */\n    private _input: AudioNode;\n\n    /** The destination output audio node */\n    private _output: AudioNode;\n\n    /** Collection of filters. */\n    private _filters: Filter[] | null | undefined;\n\n    /**\n     * @param input - The source audio node\n     * @param output - The output audio node\n     */\n    constructor(input: AudioNode, output: AudioNode)\n    {\n        this._output = output;\n        this._input = input;\n    }\n\n    /** The destination output audio node */\n    get destination(): AudioNode\n    {\n        return this._input;\n    }\n\n    /** The collection of filters. */\n    get filters(): Filter[]\n    {\n        return this._filters!;\n    }\n    set filters(filters: Filter[])\n    {\n        if (this._filters)\n        {\n            this._filters.forEach((filter: Filter) =>\n            {\n                if (filter)\n                {\n                    filter.disconnect();\n                }\n            });\n            this._filters = null;\n            // Reconnect the direct path, unhooking the old first filter\n            this._input.disconnect();\n            this._input.connect(this._output);\n        }\n\n        if (filters && filters.length)\n        {\n            this._filters = filters.slice(0);\n\n            // Disconnect direct path before inserting filters\n            this._input.disconnect();\n\n            // Connect each filter\n            let prevFilter: Filter | null = null;\n\n            filters.forEach((filter: Filter) =>\n            {\n                if (prevFilter === null)\n                {\n                    // first filter is the destination\n                    // for the analyser\n                    this._input.connect(filter.destination);\n                }\n                else\n                {\n                    prevFilter.connect(filter.destination);\n                }\n                prevFilter = filter;\n            });\n            prevFilter!.connect(this._output);\n        }\n    }\n\n    /** Cleans up. */\n    public destroy(): void\n    {\n        this.filters = null!;\n        this._input = null!;\n        this._output = null!;\n    }\n}\n\nexport { Filterable };\n","import { Filterable } from '../Filterable';\nimport { type WebAudioContext } from './WebAudioContext';\nimport { WebAudioUtils } from './WebAudioUtils';\n\n/** Output for cloning source node. */\ninterface SourceClone\n{\n    /** Cloned audio buffer source */\n    source: AudioBufferSourceNode;\n    /** Independent volume control */\n    gain: GainNode;\n}\n\n/**\n * @memberof webaudio\n */\nclass WebAudioNodes extends Filterable\n{\n    /**\n     * The buffer size for script processor, default is `0` which auto-detects. If you plan to use\n     * script node on iOS, you'll need to provide a non-zero amount.\n     * @default 0\n     */\n    public static BUFFER_SIZE = 0;\n\n    /**\n     * Get the buffer source node\n     * @readonly\n     */\n    public bufferSource: AudioBufferSourceNode;\n\n    /**\n     * Get the gain node\n     * @readonly\n     */\n    public gain: GainNode;\n\n    /**\n     * Get the analyser node\n     * @readonly\n     */\n    public analyser: AnalyserNode;\n\n    /**\n     * Reference to the SoundContext\n     * @readonly\n     */\n    public context: WebAudioContext;\n\n    /** Private reference to the script processor node. */\n    private _script: ScriptProcessorNode | undefined;\n\n    /**\n     * @param context - The audio context.\n     * @param destination - The node the output connects to: the sound's channel, or the context.\n     */\n    constructor(context: WebAudioContext, destination: AudioNode = context.destination)\n    {\n        const audioContext: AudioContext = context.audioContext;\n\n        const bufferSource: AudioBufferSourceNode = audioContext.createBufferSource();\n        const gain: GainNode = audioContext.createGain();\n        const analyser: AnalyserNode = audioContext.createAnalyser();\n\n        bufferSource.connect(analyser);\n        analyser.connect(gain);\n        gain.connect(destination);\n\n        super(analyser, gain);\n\n        this.context = context;\n        this.bufferSource = bufferSource;\n        this.gain = gain;\n        this.analyser = analyser;\n    }\n\n    /**\n     * Get the script processor node.\n     * @readonly\n     */\n    public get script(): ScriptProcessorNode\n    {\n        if (!this._script)\n        {\n            this._script = this.context.audioContext.createScriptProcessor(WebAudioNodes.BUFFER_SIZE);\n            this._script.connect(this.context.destination);\n        }\n\n        return this._script;\n    }\n\n    /** Cleans up. */\n    public destroy(): void\n    {\n        super.destroy();\n\n        this.bufferSource.disconnect();\n        if (this._script)\n        {\n            this._script.disconnect();\n        }\n        this.gain.disconnect();\n        this.analyser.disconnect();\n\n        this.bufferSource = null!;\n        this._script = null!;\n        this.gain = null!;\n        this.analyser = null!;\n\n        this.context = null!;\n    }\n\n    /**\n     * Clones the bufferSource. Used just before playing a sound.\n     * @returns {SourceClone} The clone AudioBufferSourceNode.\n     */\n    public cloneBufferSource(): SourceClone\n    {\n        const orig: AudioBufferSourceNode = this.bufferSource;\n        const source: AudioBufferSourceNode = this.context.audioContext.createBufferSource();\n\n        source.buffer = orig.buffer;\n        WebAudioUtils.setParamValue(source.playbackRate, orig.playbackRate.value);\n        source.loop = orig.loop;\n\n        const gain: GainNode = this.context.audioContext.createGain();\n\n        source.connect(gain);\n        gain.connect(this.destination);\n\n        return { source, gain };\n    }\n\n    /**\n     * Get buffer size of `ScriptProcessorNode`.\n     * @readonly\n     */\n    get bufferSize(): number\n    {\n        return this.script.bufferSize;\n    }\n}\n\nexport type { SourceClone };\nexport { WebAudioNodes };\n","import { DOMAdapter } from 'pixi.js';\nimport { type Filter } from '../filters/Filter';\nimport { type IMedia } from '../interfaces/IMedia';\nimport { type LoadedCallback, type Sound } from '../Sound';\nimport { type WebAudioContext } from './WebAudioContext';\nimport { WebAudioInstance } from './WebAudioInstance';\nimport { WebAudioNodes } from './WebAudioNodes';\n\nconst DESTROYED = 'Sound was destroyed before it finished loading';\n\n/** Adds the sound's URL to a decode error. The original error is kept as `cause`. */\nfunction decodeError(err: Error, url?: string): Error\n{\n    let from = '';\n\n    if (url)\n    {\n        let name = url;\n\n        // A data URL holds the whole file, so only keep its header\n        if (url.startsWith('data:'))\n        {\n            name = `${url.slice(0, url.indexOf(',') + 1)}…`;\n        }\n        from = ` from ${name}`;\n    }\n\n    // Object.assign because the ES2020 target has no ErrorOptions\n    return Object.assign(new Error(`Failed to decode sound${from}: ${err.message}`), { cause: err });\n}\n\n/**\n * Represents a single sound element. Can be used to play, pause, etc. sound instances.\n * @memberof webaudio\n */\nclass WebAudioMedia implements IMedia\n{\n    /**\n     * Reference to the parent Sound container.\n     * @readonly\n     */\n    public parent!: Sound;\n\n    /**\n     * The file buffer to load.\n     * @readonly\n     */\n    public source!: ArrayBuffer | AudioBuffer;\n\n    /** Instance of the chain builder. */\n    private _nodes!: WebAudioNodes;\n\n    /** Instance of the source node. */\n    private _source!: AudioBufferSourceNode;\n\n    /**\n     * Re-initialize without constructing.\n     * @param parent - - Instance of parent Sound container\n     */\n    public init(parent: Sound): void\n    {\n        this.parent = parent;\n        this._nodes = new WebAudioNodes(this.context, parent.channel?.destination);\n        this._source = this._nodes.bufferSource;\n        this.source = parent.options.source as ArrayBuffer | AudioBuffer;\n    }\n\n    /** Destructor, safer to use `SoundLibrary.remove(alias)` to remove this sound. */\n    public destroy(): void\n    {\n        this.parent = null!;\n        this._nodes.destroy();\n        this._nodes = null!;\n        try\n        {\n            this._source.buffer = null;\n        }\n        catch (err)\n        {\n            // try/catch workaround for bug in older Chrome versions\n            console.warn('Failed to set AudioBufferSourceNode.buffer to null:', err);\n        }\n        this._source = null!;\n        this.source = null!;\n    }\n\n    // Implement create\n    public create(): WebAudioInstance\n    {\n        return new WebAudioInstance(this);\n    }\n\n    // Implement context\n    public get context(): WebAudioContext\n    {\n        return this.parent.context as WebAudioContext;\n    }\n\n    // Implement isPlayable\n    public get isPlayable(): boolean\n    {\n        return !!this._source && !!this._source.buffer;\n    }\n\n    // Implement filters\n    public get filters(): Filter[]\n    {\n        return this._nodes.filters;\n    }\n    public set filters(filters: Filter[])\n    {\n        this._nodes.filters = filters;\n    }\n\n    // Implements duration: NaN until the buffer is decoded (like HTMLMediaElement.duration)\n    public get duration(): number\n    {\n        return this._source.buffer?.duration ?? NaN;\n    }\n\n    /** Gets and sets the buffer. */\n    public get buffer(): AudioBuffer\n    {\n        return this._source.buffer!;\n    }\n    public set buffer(buffer: AudioBuffer)\n    {\n        this._source.buffer = buffer;\n    }\n\n    /** Get the current chained nodes object */\n    public get nodes(): WebAudioNodes\n    {\n        return this._nodes;\n    }\n\n    // Implements load\n    public load(callback?: LoadedCallback): void\n    {\n        // Load from the arraybuffer, incase it was loaded outside\n        if (this.source)\n        {\n            this._decode(this.source, callback);\n        }\n        // Load from the file path\n        else if (this.parent.url)\n        {\n            void this._loadUrl(callback);\n        }\n        else if (callback)\n        {\n            callback(new Error('sound.url or sound.source must be set'));\n        }\n        else\n        {\n            console.error('sound.url or sound.source must be set');\n        }\n    }\n\n    /** Loads a sound using XHMLHttpRequest object. */\n    private async _loadUrl(callback?: LoadedCallback): Promise<void>\n    {\n        try\n        {\n            const arrayBuffer = await this._fetch(this.parent.url);\n\n            if (!this.parent)\n            {\n                throw new Error(DESTROYED);\n            }\n            this._decode(arrayBuffer, callback);\n        }\n        catch (err)\n        {\n            if (callback)\n            {\n                callback(err as Error);\n            }\n            else\n            {\n                console.error(err);\n            }\n        }\n    }\n\n    /** Fetches the file, adding the URL to network and HTTP errors. */\n    private async _fetch(url: string): Promise<ArrayBuffer>\n    {\n        let response: Response;\n\n        try\n        {\n            response = await DOMAdapter.get().fetch(url);\n            if (response.ok)\n            {\n                return await response.arrayBuffer();\n            }\n        }\n        catch (err)\n        {\n            // Object.assign because the ES2020 target has no ErrorOptions\n            throw Object.assign(new Error(`Failed to load sound from ${url}: ${(err as Error).message}`), { cause: err });\n        }\n\n        throw new Error(`Failed to load sound from ${url}: HTTP ${response.status}`);\n    }\n\n    /**\n     * Decodes the array buffer. A decode error gets the sound's URL added, and is logged\n     * when there is no callback.\n     * @param arrayBuffer - From load.\n     * @param {Function} callback - Callback optional\n     */\n    private _decode(arrayBuffer: ArrayBuffer | AudioBuffer, callback?: LoadedCallback): void\n    {\n        const audioBufferReadyFn = (err: Error | null, buffer?: AudioBuffer) =>\n        {\n            // The sound was destroyed while the file was decoding\n            if (!this.parent)\n            {\n                err = new Error(DESTROYED);\n            }\n\n            if (err)\n            {\n                if (callback)\n                {\n                    callback(err);\n                }\n                else\n                {\n                    console.error(err);\n                }\n            }\n            else\n            {\n                this.parent.isLoaded = true;\n                this.buffer = buffer!;\n                const instance = this.parent.autoPlayStart();\n\n                if (callback)\n                {\n                    callback(null!, this.parent, instance);\n                }\n            }\n        };\n\n        if (arrayBuffer instanceof AudioBuffer)\n        {\n            audioBufferReadyFn(null, arrayBuffer);\n        }\n        else\n        {\n            const context = this.parent.context as WebAudioContext;\n            // Read the URL now, the sound may be destroyed before decoding finishes\n            const url = this.parent.url;\n\n            context.decode(arrayBuffer, (err?: Error, buffer?: AudioBuffer) =>\n            {\n                if (err)\n                {\n                    audioBufferReadyFn(decodeError(err, url), buffer);\n                }\n                else\n                {\n                    audioBufferReadyFn(null, buffer);\n                }\n            });\n        }\n    }\n}\n\nexport { WebAudioMedia };\n","import { EventEmitter, Ticker } from 'pixi.js';\nimport { type IMediaInstance } from '../interfaces';\nimport { type PlayOptions } from '../Sound';\nimport { type WebAudioStreamMedia } from './WebAudioStreamMedia';\nimport { WebAudioUtils } from './WebAudioUtils';\n\nlet id = 0;\n\n/** Chromium throws for a playback rate below this, and Firefox is silent below 0.125 */\nconst MIN_RATE = 0.0625;\n\n/** Chromium throws for a playback rate above this, and Firefox is silent above 8 */\nconst MAX_RATE = 16;\n\n/** Events that let a blocked play start. `touchstart` isn't one of them. */\nconst GESTURES = ['mousedown', 'touchend', 'keydown'];\n\n/**\n * A single play of a streaming sound, which handles the `<audio>` element.\n * @memberof webaudio\n * @extends PIXI.EventEmitter\n */\nclass WebAudioStreamInstance extends EventEmitter implements IMediaInstance\n{\n    /**\n     * The current unique ID for this instance.\n     * @readonly\n     */\n    public readonly id: number;\n\n    /** The source Sound. */\n    private _media: WebAudioStreamMedia | null;\n\n    /** true if paused. */\n    private _paused: boolean;\n\n    /** true if paused by the instance, sound, channel or context. */\n    private _pausedReal: boolean;\n\n    /** The instance volume */\n    private _volume: number;\n\n    /** true if muted. */\n    private _muted: boolean;\n\n    /** Playback rate, where 1 is 100%. */\n    private _speed: number;\n\n    /** `true` if should be looping. */\n    private _loop: boolean;\n\n    constructor(media: WebAudioStreamMedia)\n    {\n        super();\n\n        this.id = id++;\n        this._media = null;\n        this._paused = false;\n        this._pausedReal = false;\n        this._volume = 1;\n        this._muted = false;\n        this._speed = 1;\n        this._loop = false;\n\n        // Initialise\n        this.init(media);\n    }\n\n    /** Initialises the instance. */\n    public init(media: WebAudioStreamMedia): void\n    {\n        this._media = media;\n        media.context.events.on('refresh', this.refresh, this);\n        media.context.events.on('refreshPaused', this.refreshPaused, this);\n        // A direct `context.paused` write only suspends the context, and the element keeps its own clock\n        media.gain.context.addEventListener('statechange', this._onStateChange);\n    }\n\n    /** The context was suspended or resumed. */\n    private _onStateChange = (event: Event): void =>\n    {\n        // Not once the library is closed, nor for the old context after a new one is made\n        if (this._media!.context?.audioContext === event.target)\n        {\n            this.refreshPaused();\n        }\n    };\n\n    /**\n     * Set a property by name, this makes it easy to chain values\n     * @param name - Name of the property to set.\n     * @param value - Value to set property to.\n     */\n    public set(name: 'speed' | 'volume' | 'muted' | 'loop' | 'paused', value: number | boolean): this\n    {\n        if (this[name] === undefined)\n        {\n            throw new Error(`Property with name ${name} does not exist.`);\n        }\n        else\n        {\n            switch (name)\n            {\n                case 'speed': this.speed = value as number; break;\n                case 'volume': this.volume = value as number; break;\n                case 'muted': this.muted = value as boolean; break;\n                case 'loop': this.loop = value as boolean; break;\n                case 'paused': this.paused = value as boolean; break;\n            }\n        }\n\n        return this;\n    }\n\n    /** Stops the instance, don't use after this. */\n    public stop(): void\n    {\n        if (this._media)\n        {\n            this._internalStop();\n            this.emit('stop');\n        }\n    }\n\n    /**\n     * The instance speed. The element plays at the product of the instance, sound and global speeds,\n     * limited to 0.0625–16.\n     */\n    public get speed(): number\n    {\n        return this._speed;\n    }\n    public set speed(speed: number)\n    {\n        this._speed = speed;\n        this.refresh();\n    }\n\n    /** Get the set the volume for this instance from 0 to 1 */\n    public get volume(): number\n    {\n        return this._volume;\n    }\n    public set volume(volume: number)\n    {\n        this._volume = volume;\n        this.refresh();\n    }\n\n    /** `true` if the sound is muted */\n    public get muted(): boolean\n    {\n        return this._muted;\n    }\n    public set muted(muted: boolean)\n    {\n        this._muted = muted;\n        this.refresh();\n    }\n\n    /** If the sound instance should loop playback */\n    public get loop(): boolean\n    {\n        return this._loop;\n    }\n    public set loop(loop: boolean)\n    {\n        this._loop = loop;\n        this.refresh();\n    }\n\n    /** The current playback progress from 0 to 1. */\n    public get progress(): number\n    {\n        const source = this._media?.source;\n\n        return source ? (source.currentTime / source.duration) || 0 : 0;\n    }\n\n    /** Pauses the sound. */\n    public get paused(): boolean\n    {\n        return this._paused;\n    }\n    public set paused(paused: boolean)\n    {\n        this._paused = paused;\n        this.refreshPaused();\n    }\n\n    /** Refresh loop, volume and speed based on changes to parent */\n    public refresh(): void\n    {\n        if (!this._media)\n        {\n            return;\n        }\n        const global = this._media.context;\n        const sound = this._media.parent;\n        const source = this._media.source;\n\n        source.loop = this._loop || sound.loop;\n\n        // Update the volume\n        const globalVolume = global.volume * (global.muted ? 0 : 1);\n        const soundVolume = sound.volume * (sound.muted ? 0 : 1);\n        const channel = sound.channel;\n        const channelVolume = channel ? channel.volume * (channel.muted ? 0 : 1) : 1;\n        const instanceVolume = this._volume * (this._muted ? 0 : 1);\n\n        WebAudioUtils.setParamValue(this._media.gain.gain, instanceVolume * soundVolume * channelVolume * globalVolume);\n\n        // Update the speed\n        source.playbackRate = Math.min(Math.max(this._speed * sound.speed * global.speed, MIN_RATE), MAX_RATE);\n    }\n\n    /** Handle changes in paused state, from the instance, sound, channel or global */\n    public refreshPaused(): void\n    {\n        const media = this._media;\n\n        if (!media)\n        {\n            return;\n        }\n        const sound = media.parent;\n        const pausedReal = !!(this._paused || sound.paused || sound.channel?.paused || media.context.paused);\n\n        if (pausedReal !== this._pausedReal)\n        {\n            this._pausedReal = pausedReal;\n\n            if (pausedReal)\n            {\n                this._internalPause();\n\n                /**\n                 * The sound is paused.\n                 * @event paused\n                 */\n                this.emit('paused');\n            }\n            else\n            {\n                this._play();\n\n                /**\n                 * The sound is unpaused.\n                 * @event resumed\n                 */\n                this.emit('resumed');\n            }\n\n            /**\n             * The sound is paused or unpaused.\n             * @event pause\n             * @property {boolean} paused - If the instance was paused or not.\n             */\n            this.emit('pause', pausedReal);\n        }\n    }\n\n    /**\n     * Plays the sound. `end` and play filters are ignored, so a sprite plays from its start to the end of the file.\n     * @param options - Play options.\n     */\n    public play(options: PlayOptions): void\n    {\n        const media = this._media!;\n        const sound = media.parent;\n        const source = media.source;\n\n        if (options.end || options.filters?.length)\n        {\n            console.warn('A streaming sound plays to the end of the file: end and play filters are ignored');\n        }\n        this._paused = false;\n        this._speed = options.speed!;\n        this._loop = !!options.loop;\n        this._volume = options.volume!;\n        this._muted = options.muted!;\n        this.refresh();\n\n        // A seek before the metadata has loaded is queued by the element\n        source.currentTime = options.start ?? 0;\n        source.addEventListener('ended', this._onEnded);\n\n        // A play into a paused sound, channel or context is held until it's resumed\n        this._pausedReal = !!(sound.paused || sound.channel?.paused || media.context.paused);\n        if (!this._pausedReal)\n        {\n            this._play();\n        }\n\n        /**\n         * The sound is started.\n         * @event start\n         */\n        this.emit('start');\n    }\n\n    /** Plays the element, and retries on the next gesture if the browser blocks it. */\n    private _play(): void\n    {\n        Ticker.shared.remove(this._onUpdate, this);\n        Ticker.shared.add(this._onUpdate, this);\n        this._media!.source.play().catch((err: DOMException) =>\n        {\n            // This settles later: the instance may have been paused or destroyed since\n            if (err.name === 'NotAllowedError')\n            {\n                if (this._media && !this._pausedReal)\n                {\n                    this._waitForGesture();\n                }\n            }\n            // A pause before play() settled\n            else if (err.name !== 'AbortError')\n            {\n                console.error(err);\n            }\n        });\n    }\n\n    /** Waits for a gesture that lets the browser play the element. */\n    private _waitForGesture(): void\n    {\n        GESTURES.forEach((name) => document.addEventListener(name, this._onGesture, true));\n    }\n\n    /** Stops waiting for a gesture. */\n    private _stopWaiting(): void\n    {\n        GESTURES.forEach((name) => document.removeEventListener(name, this._onGesture, true));\n    }\n\n    /** A gesture came, so try the play again. */\n    private _onGesture = (): void =>\n    {\n        this._stopWaiting();\n        this._play();\n    };\n\n    /** Pauses the element, keeping its position. */\n    private _internalPause(): void\n    {\n        Ticker.shared.remove(this._onUpdate, this);\n        this._stopWaiting();\n        this._media!.source.pause();\n    }\n\n    /** Stops the instance. */\n    private _internalStop(): void\n    {\n        this._internalPause();\n        this._media!.source.removeEventListener('ended', this._onEnded);\n    }\n\n    /** Update the progress. */\n    private _onUpdate(): void\n    {\n        this.emit('progress', this.progress, this._media!.duration);\n    }\n\n    /** Callback when the element reaches the end. It never does while looping. */\n    private _onEnded = (): void =>\n    {\n        this._internalStop();\n        this.emit('progress', 1, this._media!.duration);\n        /**\n         * The sound ends, don't use after this\n         * @event end\n         */\n        this.emit('end', this);\n    };\n\n    /** Don't use after this. */\n    public destroy(): void\n    {\n        if (this._media)\n        {\n            this._internalStop();\n            this._media.gain.context.removeEventListener('statechange', this._onStateChange);\n            // The context is gone after close()\n            this._media.context?.events.off('refresh', this.refresh, this);\n            this._media.context?.events.off('refreshPaused', this.refreshPaused, this);\n        }\n        this.removeAllListeners();\n        this._media = null;\n        this._paused = false;\n        this._pausedReal = false;\n        this._volume = 1;\n        this._muted = false;\n        this._speed = 1;\n        this._loop = false;\n    }\n\n    /**\n     * To string method for instance.\n     * @return The string representation of instance.\n     */\n    public toString(): string\n    {\n        return `[WebAudioStreamInstance id=${this.id}]`;\n    }\n}\n\nexport { WebAudioStreamInstance };\n","import { type Filter } from '../filters/Filter';\nimport { HTMLAudioMedia } from '../htmlaudio/HTMLAudioMedia';\nimport { type IMedia } from '../interfaces/IMedia';\nimport { type LoadedCallback, type Sound } from '../Sound';\nimport { type WebAudioContext } from './WebAudioContext';\nimport { WebAudioNodes } from './WebAudioNodes';\nimport { WebAudioStreamInstance } from './WebAudioStreamInstance';\n\n/**\n * A sound that plays while it downloads, through an `<audio>` element connected to WebAudio.\n * Made by {@link Sound.from} for the `streaming` option.\n * @memberof webaudio\n */\nclass WebAudioStreamMedia implements IMedia\n{\n    /**\n     * Reference to the parent Sound container.\n     * @readonly\n     */\n    public parent!: Sound;\n\n    /** Loads and holds the element */\n    private _html!: HTMLAudioMedia;\n\n    /** Instance of the chain builder. */\n    private _nodes!: WebAudioNodes;\n\n    /** The element's node in the graph. */\n    private _node!: MediaElementAudioSourceNode;\n\n    /** Volume of the instance, sound, channel and context. */\n    private _gain!: GainNode;\n\n    /**\n     * Re-initialise without constructing.\n     * @param parent - Instance of parent Sound container\n     */\n    public init(parent: Sound): void\n    {\n        this.parent = parent;\n        this._html = new HTMLAudioMedia();\n        this._html.init(parent);\n\n        const source = this._html.source;\n        const audioContext = this.context.audioContext;\n\n        // Without it a file on another origin plays silently. An element passed in as the source is left as it is\n        if (!parent.options.source)\n        {\n            source.crossOrigin = 'anonymous';\n        }\n        // Speed changes pitch, as it does for buffer sounds\n        source.preservesPitch = false;\n        this._nodes = new WebAudioNodes(this.context, parent.channel?.destination);\n        this._gain = audioContext.createGain();\n        // Only one node can ever be made for an element\n        this._node = audioContext.createMediaElementSource(source);\n        this._node.connect(this._gain);\n        this._gain.connect(this._nodes.destination);\n    }\n\n    /** Destructor, safer to use `SoundLibrary.remove(alias)` to remove this sound. */\n    public destroy(): void\n    {\n        this._node.disconnect();\n        this._gain.disconnect();\n        this._nodes.destroy();\n        this._html.destroy();\n        this.parent = null!;\n        this._html = null!;\n        this._nodes = null!;\n        this._node = null!;\n        this._gain = null!;\n    }\n\n    // Implement create\n    public create(): WebAudioStreamInstance\n    {\n        return new WebAudioStreamInstance(this);\n    }\n\n    // Implement context\n    public get context(): WebAudioContext\n    {\n        return this.parent.context as WebAudioContext;\n    }\n\n    // Implement isPlayable. Not the element's ready state, which drops while it seeks\n    public get isPlayable(): boolean\n    {\n        return !!this._html;\n    }\n\n    // Implement filters\n    public get filters(): Filter[]\n    {\n        return this._nodes.filters;\n    }\n    public set filters(filters: Filter[])\n    {\n        this._nodes.filters = filters;\n    }\n\n    // Implements duration: NaN until the element has loaded its metadata\n    public get duration(): number\n    {\n        return this._html.duration;\n    }\n\n    /**\n     * The audio element.\n     * @readonly\n     */\n    public get source(): HTMLAudioElement\n    {\n        return this._html.source;\n    }\n\n    /**\n     * The gain for the volume of the instance, sound, channel and context.\n     * @readonly\n     */\n    public get gain(): GainNode\n    {\n        return this._gain;\n    }\n\n    /** Get the current chained nodes object */\n    public get nodes(): WebAudioNodes\n    {\n        return this._nodes;\n    }\n\n    // Implements load\n    public load(callback?: LoadedCallback): void\n    {\n        this._html.load(callback);\n    }\n}\n\nexport { WebAudioStreamMedia };\n","import { path } from 'pixi.js';\nimport { type Filter } from './filters/Filter';\nimport { HTMLAudioMedia } from './htmlaudio/HTMLAudioMedia';\nimport { getInstance } from './instance';\nimport { type IMedia, type IMediaContext, type IMediaInstance } from './interfaces';\nimport { type SoundChannel } from './SoundChannel';\nimport { SoundSprite, type SoundSpriteData, type SoundSprites } from './SoundSprite';\nimport { extensions, supported } from './utils/supported';\nimport { withoutUndefined } from './utils/withoutUndefined';\nimport { WebAudioMedia } from './webaudio/WebAudioMedia';\nimport { WebAudioStreamInstance } from './webaudio/WebAudioStreamInstance';\nimport { WebAudioStreamMedia } from './webaudio/WebAudioStreamMedia';\n\n/**\n * Options to use for creating sounds.\n */\ninterface Options\n{\n    /**\n     * `true` to immediately start preloading.\n     * @default false\n     */\n    autoPlay?: boolean;\n    /**\n     * Name of the channel the sound belongs to. See {@link SoundLibrary#channel}. Can't be changed later.\n     * An empty name means no channel.\n     */\n    channel?: string;\n    /**\n     * `true` to disallow playing multiple layered instances at once.\n     * @default false\n     */\n    singleInstance?: boolean;\n    /**\n     * `true` to start playing while the file downloads, for long sounds such as music. It plays\n     * through an `<audio>` element connected to WebAudio, instead of downloading and decoding the\n     * whole file first, so it counts as loaded once the browser can play it through.\n     * Volume, mute, speed, loop, pause, sound and channel filters and `filtersAll` still apply.\n     * It plays one instance at a time (`play()` restarts it), plays to the end of the file\n     * (`end` and play `filters` are ignored, so a sprite plays from its start to the end of the file),\n     * and limits speed to 0.0625–16 (Firefox is silent outside 0.125–8). `start` needs a server that\n     * supports range requests, and a file on another origin needs CORS headers. It needs a `url` or\n     * an `<audio>` `source`: an `ArrayBuffer` or `AudioBuffer` `source` is played as usual, with a\n     * warning. No effect with `useLegacy`.\n     * @default false\n     */\n    streaming?: boolean;\n    /**\n     * The amount of volume 1 = 100%.\n     * @default 1\n     */\n    volume?: number;\n    /**\n     * The playback rate where 1 is 100% speed.\n     * @default 1\n     */\n    speed?: number;\n    /**\n     * Global complete callback when play is finished.\n     * @type {Function}\n     */\n    complete?: CompleteCallback | null;\n    /**\n     * Call when finished loading. Called once with an error if loading or decoding fails.\n     * With WebAudio the error message names the file and the original error is in `cause`.\n     * If no callback is given, the error is logged to the console instead.\n     * Called once, even if `play()` is called while the sound is still loading.\n     * @type {Function}\n     */\n    loaded?: LoadedCallback | null;\n    /**\n     * `true` to immediately start preloading if loading from `url`. Calling `play()` while\n     * it is still loading waits for this load; it does not start another.\n     */\n    preload?: boolean;\n    /**\n     * Initial loop value, `true` is loop infinitely\n     * @default false\n     */\n    loop?: boolean;\n    /**\n     * The source of the file being loaded\n     */\n    url?: string | string[] | null;\n    /**\n     * If sound is already preloaded, available.\n     */\n    source?: ArrayBuffer | AudioBuffer | HTMLAudioElement | null;\n    /**\n     * The map of sprite data. Where a sprite is an object\n     * with a `start` and `end`, which are the times in seconds. Optionally, can include\n     * a `speed` amount where 1 is 100% speed.\n     */\n    sprites?: Record<string, SoundSpriteData>;\n}\n\n/**\n * Options used for sound playback.\n */\ninterface PlayOptions\n{\n    /**\n     * Start time offset in seconds.\n     * @default 0\n     */\n    start?: number;\n    /**\n     * End time in seconds.\n     */\n    end?: number | null;\n    /**\n     * The instance speed, where 1 is 100%. The sound and global speeds multiply it.\n     * Defaults to 1, or to the sprite's speed when playing a sprite, which this overrides.\n     */\n    speed?: number;\n    /**\n    * Override default loop, default to the Sound's loop setting.\n    */\n    loop?: boolean;\n    /**\n     * Override default volume, default to the Sound's volume setting.\n     */\n    volume?: number;\n    /**\n     * The sprite to play.\n     */\n    sprite?: string | null;\n    /**\n     * If sound instance is muted by default.\n     * @default false\n     */\n    muted?: boolean;\n    /**\n     * Filters that apply to play.\n     * Only supported with WebAudio.\n     */\n    filters?: Filter[];\n    /**\n     * When completed.\n     * @type {Function}\n     */\n    complete?: CompleteCallback | null;\n    /**\n     * If the sound has not loaded yet, called when it has, with the instance this call started.\n     * Not called if loading fails; the promise from `play()` rejects instead.\n     * @type {Function}\n     */\n    loaded?: LoadedCallback | null;\n    /**\n     * Setting `true` will stop any playing instances. This is the same as\n     * the singleInstance property on Sound, but is play-specific.\n     */\n    singleInstance?: boolean;\n}\n\n/**\n * Callback when sound is loaded.\n * @ignore\n * @param {Error} err - The callback error.\n * @param {Sound} sound - The instance of new sound.\n * @param {IMediaInstance} instance - The instance of auto-played sound.\n */\ntype LoadedCallback = (err: Error, sound?: Sound, instance?: IMediaInstance) => void;\n\n/**\n * Callback when sound is completed.\n * @ignore\n * @param {Sound} sound - The instance of sound.\n */\ntype CompleteCallback = (sound: Sound) => void;\n\ntype SoundSpriteDataMap = Record<string, SoundSpriteData>;\n\n/** A `play()` call that is waiting for the sound to load. */\ninterface PendingPlay\n{\n    options: PlayOptions;\n    resolve: (instance: IMediaInstance) => void;\n    reject: (err: Error) => void;\n}\n\n/**\n * Sound represents a single piece of loaded media. When playing a sound {@link IMediaInstance} objects\n * are created. Properties such a `volume`, `pause`, `mute`, `speed`, etc will have an effect on all instances.\n */\nclass Sound\n{\n    /** Pool of instances */\n    private static _pool: IMediaInstance[] = [];\n\n    /**\n     * `true` if the buffer is loaded.\n     * @default false\n     */\n    public isLoaded: boolean;\n\n    /**\n     * `true` while the sound has instances and isn't paused with `pause()` or `paused`.\n     * A paused channel, `pauseAll()` or the page losing focus holds the sound without changing it.\n     * It's `false` once the sound is destroyed.\n     * @default false\n     * @readonly\n     */\n    public isPlaying: boolean;\n\n    /**\n     * true to start playing immediate after load.\n     * @default false\n     * @readonly\n     */\n    public autoPlay: boolean;\n\n    /**\n     * `true` to disallow playing multiple layered instances at once.\n     * @default false\n     */\n    public singleInstance: boolean;\n\n    /**\n     * `true` to immediately start preloading.\n     * @default false\n     * @readonly\n     */\n    public preload: boolean;\n\n    /**\n     * The file source to load.\n     * @readonly\n     */\n    public url: string;\n\n    /**\n     * The constructor options.\n     * @readonly\n     */\n    public options: Options;\n\n    /** The audio source */\n    public media: IMedia;\n\n    /**\n     * The sound's channel, if it was created with one.\n     * @readonly\n     */\n    public readonly channel?: SoundChannel;\n\n    /** The play calls, after the first one, that are waiting for the sound to load. */\n    private _preloadQueue: PendingPlay[] | null;\n\n    /** The callbacks waiting for the load in progress, or `null` when nothing is loading. */\n    private _loadCallbacks: LoadedCallback[] | null;\n\n    /** The collection of instances being played. */\n    private _instances: IMediaInstance[];\n\n    /** The user defined sound sprites. */\n    private _sprites: SoundSprites;\n\n    /** The options when auto-playing. */\n    private _autoPlayOptions: PlayOptions | null;\n\n    /** The internal volume. */\n    private _volume!: number;\n\n    /** The internal paused state. */\n    private _paused: boolean | undefined;\n\n    /** The internal muted state. */\n    private _muted: boolean | undefined;\n\n    /** The internal volume. */\n    private _loop!: boolean;\n\n    /** The internal playbackRate */\n    private _speed!: number;\n\n    /**\n     * Create a new sound instance from source.\n     * The sound isn't added to the library, so `sound.stopAll()`, `sound.removeAll()` and\n     * `sound.isPlaying()` skip it until you call `sound.add('alias', mySound)`. The global\n     * volume, speed, mute, pause and filters still apply.\n     * @param source - Either the path or url to the source file.\n     *        or the object of options to use.\n     * @return Created sound instance.\n     */\n    public static from(source: string | string[] | Options | ArrayBuffer | HTMLAudioElement | AudioBuffer): Sound\n    {\n        let options: Options = {};\n\n        if (typeof source === 'string')\n        {\n            options.url = source as string;\n        }\n        else if (source instanceof ArrayBuffer || source instanceof AudioBuffer || source instanceof HTMLAudioElement)\n        {\n            options.source = source;\n        }\n        else if (Array.isArray(source))\n        {\n            options.url = source;\n        }\n        else\n        {\n            options = source;\n        }\n\n        // Default settings\n        options = {\n            autoPlay: false,\n            singleInstance: false,\n            streaming: false,\n            url: null,\n            source: null,\n            preload: false,\n            volume: 1,\n            speed: 1,\n            complete: null,\n            loaded: null,\n            loop: false, ...withoutUndefined(options)\n        };\n\n        Object.freeze(options);\n\n        let media: IMedia;\n\n        if (getInstance().useLegacy)\n        {\n            media = new HTMLAudioMedia();\n        }\n        else\n        {\n            // An ArrayBuffer or AudioBuffer is already in memory, so there's nothing to stream\n            const streaming = options.streaming && (!options.source || options.source instanceof HTMLAudioElement);\n\n            if (options.streaming && !streaming)\n            {\n                console.warn('streaming can\\'t use an ArrayBuffer or AudioBuffer source, so this sound plays without it');\n            }\n            media = streaming ? new WebAudioStreamMedia() : new WebAudioMedia();\n        }\n\n        return new Sound(media, options);\n    }\n\n    /**\n     * Use `Sound.from`\n     * @ignore\n     */\n    constructor(media: IMedia, options: Options)\n    {\n        this.media = media;\n        this.options = options;\n        this.channel = options.channel ? getInstance().channel(options.channel) : undefined;\n        this._instances = [];\n        this._sprites = {};\n\n        this.media.init(this);\n\n        const complete = options.complete;\n\n        this._autoPlayOptions = complete ? { complete } : null;\n        this.isLoaded = false;\n        this._preloadQueue = null;\n        this._loadCallbacks = null;\n        this.isPlaying = false;\n        this.autoPlay = options.autoPlay!;\n        this.singleInstance = options.singleInstance!;\n        this.preload = options.preload || this.autoPlay;\n\n        this.url = Array.isArray(options.url)\n            ? this.preferUrl(options.url)\n            : options.url!;\n        this.speed = options.speed!;\n        this.volume = options.volume!;\n        this.loop = options.loop!;\n\n        if (options.sprites)\n        {\n            this.addSprites(options.sprites);\n        }\n\n        if (this.preload)\n        {\n            this._preload(options.loaded);\n        }\n    }\n\n    /**\n     * Internal help for resolving which file to use if there are multiple provide\n     * this is especially helpful for working with bundlers (non Assets loading).\n     */\n    private preferUrl(urls: string[]): string\n    {\n        const [file] = urls\n            .map((url) => ({ url, ext: path.extname(url).slice(1) }))\n            .filter(({ ext }) => supported[ext])\n            .sort((a, b) => extensions.indexOf(a.ext) - extensions.indexOf(b.ext));\n\n        if (!file)\n        {\n            throw new Error('No supported file type found');\n        }\n\n        return file.url;\n    }\n\n    /** Instance of the media context. */\n    public get context(): IMediaContext\n    {\n        return getInstance().context;\n    }\n\n    /** Stops all the instances of this sound from playing. */\n    public pause(): this\n    {\n        this.paused = true;\n\n        return this;\n    }\n\n    /** Resuming all the instances of this sound from playing */\n    public resume(): this\n    {\n        this.paused = false;\n\n        return this;\n    }\n\n    /**\n     * `true` to pause all the instances of this sound. A sound played while it's paused\n     * starts paused, and plays when it's resumed.\n     */\n    public get paused(): boolean\n    {\n        return this._paused!;\n    }\n    public set paused(paused: boolean)\n    {\n        this._paused = paused;\n        this.isPlaying = !paused && this._instances.length > 0;\n        this.refreshPaused();\n    }\n\n    /** The playback rate. */\n    public get speed(): number\n    {\n        return this._speed;\n    }\n    public set speed(speed: number)\n    {\n        this._speed = speed;\n        this.refresh();\n    }\n\n    /** Set the filters. Only supported with WebAudio. */\n    public get filters(): Filter[]\n    {\n        return this.media.filters;\n    }\n    public set filters(filters: Filter[])\n    {\n        this.media.filters = filters;\n    }\n\n    /**\n     * Add a sound sprite, which is a saved instance of a longer sound.\n     * Similar to an image spritesheet.\n     * @param alias - The unique name of the sound sprite.\n     * @param data - Either completed function or play options.\n     */\n    public addSprites(alias: string, data: SoundSpriteData): SoundSprite;\n\n    /**\n     * Convenience method to add more than one sprite add a time.\n     * @param data - Map of sounds to add where the key is the alias,\n     *        and the data are configuration options.\n     * @return The map of sound sprites added.\n     */\n    public addSprites(data: SoundSpriteDataMap): SoundSprites;\n\n    /**\n     * @ignore\n     */\n    public addSprites(source: string | SoundSpriteDataMap, data?: SoundSpriteData): any\n    {\n        if (typeof source === 'object')\n        {\n            const results: SoundSprites = {};\n\n            for (const alias in source)\n            {\n                results[alias] = this.addSprites(alias, source[alias]!);\n            }\n\n            return results;\n        }\n\n        // eslint-disable-next-line no-console\n        console.assert(!this._sprites[source], `Alias ${source} is already taken`);\n        const sprite = new SoundSprite(this, data!);\n\n        this._sprites[source] = sprite;\n\n        return sprite;\n    }\n\n    /** Destructor, safer to use `SoundLibrary.remove(alias)` to remove this sound. */\n    public destroy(): void\n    {\n        this.channel?.sounds.delete(this);\n        this._removeInstances();\n        this.isPlaying = false;\n        this.removeSprites();\n        this.media.destroy();\n        this.media = null!;\n        this._sprites = null!;\n        this._instances = null!;\n        // The load in progress keeps its own references, and still reports to every waiting call\n        this._preloadQueue = null;\n        this._loadCallbacks = null;\n    }\n\n    /**\n     * Remove a sound sprite.\n     * @param alias - The unique name of the sound sprite, if alias is omitted, removes all sprites.\n     */\n    public removeSprites(alias?: string): Sound\n    {\n        if (!alias)\n        {\n            for (const name in this._sprites)\n            {\n                this.removeSprites(name);\n            }\n        }\n        else\n        {\n            const sprite: SoundSprite | undefined = this._sprites[alias];\n\n            if (sprite !== undefined)\n            {\n                sprite.destroy();\n                delete this._sprites[alias];\n            }\n        }\n\n        return this;\n    }\n\n    /** If the current sound is playable (loaded). */\n    public get isPlayable(): boolean\n    {\n        return this.isLoaded && this.media && this.media.isPlayable;\n    }\n\n    /** Stops all the instances of this sound from playing. */\n    public stop(): this\n    {\n        if (!this.isPlayable)\n        {\n            this.autoPlay = false;\n            this._autoPlayOptions = null;\n\n            return this;\n        }\n        this.isPlaying = false;\n\n        // Go in reverse order so we don't skip items. A stop listener can stop this sound again, which\n        // empties the list, or destroy it, which nulls it\n        for (let i = this._instances.length - 1; i >= 0; i--)\n        {\n            this._instances?.[i]?.stop();\n        }\n\n        return this;\n    }\n\n    /**\n     * Play a sound sprite, which is a saved instance of a longer sound.\n     * Similar to an image spritesheet.\n     * @method play\n     * @instance\n     * @param alias - The unique name of the sound sprite.\n     * @param {Function} callback - Callback when completed.\n     * @return The sound instance,\n     *        this cannot be reused after it is done playing. Returns a Promise for it if the sound\n     *        has not yet loaded. Each call made before loading starts its own instance once the\n     *        sound has loaded. The promise rejects if loading fails. Returns `null` if there's no\n     *        sprite with that name.\n     */\n    public play(alias: string, callback?: CompleteCallback): IMediaInstance | Promise<IMediaInstance>;\n\n    /**\n     * Plays the sound.\n     * @method play\n     * @instance\n     * @param {Function|PlayOptions} source - Either completed function or play options.\n     * @param {Function} callback - Callback when completed.\n     * @return The sound instance,\n     *        this cannot be reused after it is done playing. Returns a Promise for it if the sound\n     *        has not yet loaded. Each call made before loading starts its own instance once the\n     *        sound has loaded. The promise rejects if loading fails. Returns `null` if there's no\n     *        sprite with that name.\n     */\n    public play(source?: string | PlayOptions | CompleteCallback,\n        callback?: CompleteCallback): IMediaInstance | Promise<IMediaInstance>;\n\n    // Overloaded function\n    public play(source?: string | PlayOptions | CompleteCallback,\n        complete?: CompleteCallback): IMediaInstance | Promise<IMediaInstance>\n    {\n        let options: PlayOptions;\n\n        if (typeof source === 'string')\n        {\n            const sprite: string = source as string;\n\n            options = { sprite, loop: this.loop, complete };\n        }\n        else if (typeof source === 'function')\n        {\n            options = {};\n            options.complete = source as CompleteCallback;\n        }\n        else\n        {\n            options = source as PlayOptions;\n        }\n\n        const playOptions = withoutUndefined(options);\n\n        options = {\n            complete: null,\n            loaded: null,\n            sprite: null,\n            end: null,\n            start: 0,\n            volume: 1,\n            speed: 1,\n            muted: false,\n            loop: false, ...playOptions\n        };\n\n        // A sprite is specified, add the options\n        if (options.sprite)\n        {\n            const alias: string = options.sprite;\n\n            // eslint-disable-next-line no-console\n            console.assert(!!this._sprites[alias], `Alias ${alias} is not available`);\n            const sprite: SoundSprite | undefined = this._sprites[alias];\n\n            if (!sprite)\n            {\n                return null!;\n            }\n\n            options.start = sprite.start + (options.start || 0);\n            options.end = sprite.end;\n            options.speed = playOptions.speed ?? (sprite.speed || 1);\n            options.loop = sprite.loop || options.loop;\n            delete options.sprite;\n        }\n\n        // @deprecated offset option\n        if ((options as any).offset)\n        {\n            options.start = (options as any).offset as number;\n        }\n\n        // if not yet playable, ignore\n        // - usefull when the sound download isnt yet completed\n        if (!this.isLoaded)\n        {\n            return new Promise<IMediaInstance>((resolve, reject) =>\n            {\n                // Only the first play() asks for the load; the ones after it wait in the queue\n                if (this._preloadQueue)\n                {\n                    this._preloadQueue.push({ options, resolve, reject });\n\n                    return;\n                }\n\n                const queue: PendingPlay[] = [];\n\n                this._preloadQueue = queue;\n                this.autoPlay = true;\n                this._autoPlayOptions = options;\n\n                this._preload((err: Error, sound?: Sound, media?: IMediaInstance) =>\n                {\n                    this._preloadQueue = null;\n\n                    if (err)\n                    {\n                        reject(err);\n                        queue.forEach((pending) => pending.reject(err));\n\n                        return;\n                    }\n\n                    options.loaded?.(null!, sound, media);\n                    resolve(media!);\n\n                    for (const pending of queue)\n                    {\n                        const instance = this.play(pending.options) as IMediaInstance;\n\n                        pending.options.loaded?.(null!, sound, instance);\n                        pending.resolve(instance);\n                    }\n                });\n            });\n        }\n\n        // Stop all sounds. A streaming sound has one element, so it plays one instance at a time\n        if (this.singleInstance || options.singleInstance || this.media instanceof WebAudioStreamMedia)\n        {\n            this._removeInstances();\n        }\n\n        // clone the bufferSource\n        const instance = this._createInstance();\n\n        this._instances.push(instance);\n        this.channel?.sounds.add(this);\n        this.isPlaying = !this._paused;\n        instance.once('end', () =>\n        {\n            if (options.complete)\n            {\n                options.complete(this);\n            }\n            this._onComplete(instance);\n        });\n        instance.once('stop', () =>\n        {\n            this._onComplete(instance);\n        });\n\n        instance.play(options);\n\n        return instance;\n    }\n\n    /** Internal only, speed, loop, volume change occured. */\n    public refresh(): void\n    {\n        const len = this._instances.length;\n\n        for (let i = 0; i < len; i++)\n        {\n            this._instances[i]!.refresh();\n        }\n    }\n\n    /** Handle changes in paused state. Internal only. */\n    public refreshPaused(): void\n    {\n        const len = this._instances.length;\n\n        for (let i = 0; i < len; i++)\n        {\n            this._instances[i]!.refreshPaused();\n        }\n    }\n\n    /** Gets and sets the volume. */\n    public get volume(): number\n    {\n        return this._volume;\n    }\n    public set volume(volume: number)\n    {\n        this._volume = volume;\n        this.refresh();\n    }\n\n    /** Gets and sets the muted flag. */\n    public get muted(): boolean\n    {\n        return this._muted!;\n    }\n    public set muted(muted: boolean)\n    {\n        this._muted = muted;\n        this.refresh();\n    }\n\n    /** Gets and sets the looping. */\n    public get loop(): boolean\n    {\n        return this._loop;\n    }\n    public set loop(loop: boolean)\n    {\n        this._loop = loop;\n        this.refresh();\n    }\n\n    /** Starts the preloading of sound. */\n    private _preload(callback?: LoadedCallback | null): void\n    {\n        // Already loading: wait for that load, don't start another\n        if (this._loadCallbacks)\n        {\n            if (callback)\n            {\n                this._loadCallbacks.push(callback);\n            }\n\n            return;\n        }\n\n        const callbacks: LoadedCallback[] = callback ? [callback] : [];\n\n        // Set before load(), as an AudioBuffer source calls back straight away\n        this._loadCallbacks = callbacks;\n        this.media.load((err: Error, sound?: Sound, instance?: IMediaInstance) =>\n        {\n            // Cleared first, so a play() after a failed load can start a new one\n            this._loadCallbacks = null;\n\n            if (err && callbacks.length === 0)\n            {\n                console.error(err);\n            }\n            callbacks.forEach((loaded) => loaded(err, sound, instance));\n        });\n    }\n\n    /** Gets the list of instances that are currently being played of this sound. */\n    public get instances(): IMediaInstance[]\n    {\n        return this._instances;\n    }\n\n    /** Get the map of sprites. */\n    public get sprites(): SoundSprites\n    {\n        return this._sprites;\n    }\n\n    /**\n     * The duration of the audio in seconds, or `NaN` while it isn't known: before the sound\n     * has loaded, if loading failed, or after `destroy()`. Use `isPlayable` to check for a loaded sound.\n     * With HTML audio the duration can be known as soon as the file's metadata arrives,\n     * shortly before `isPlayable` is `true`.\n     * @readonly\n     */\n    public get duration(): number\n    {\n        return this.media?.duration ?? NaN;\n    }\n\n    /** Auto play the first instance. */\n    public autoPlayStart(): IMediaInstance\n    {\n        let instance!: IMediaInstance;\n\n        if (this.autoPlay)\n        {\n            instance = this.play(this._autoPlayOptions!) as IMediaInstance;\n        }\n\n        return instance;\n    }\n\n    /** Removes all instances. */\n    private _removeInstances(): void\n    {\n        // destroying also stops\n        for (let i = this._instances.length - 1; i >= 0; i--)\n        {\n            this._poolInstance(this._instances[i]!);\n        }\n        this._instances.length = 0;\n    }\n\n    /**\n     * Sound instance completed.\n     * @param instance\n     */\n    private _onComplete(instance: IMediaInstance): void\n    {\n        if (this._instances)\n        {\n            const index = this._instances.indexOf(instance);\n\n            if (index > -1)\n            {\n                this._instances.splice(index, 1);\n            }\n            this.isPlaying = !this._paused && this._instances.length > 0;\n            if (!this._instances.length)\n            {\n                this.channel?.sounds.delete(this);\n            }\n        }\n        this._poolInstance(instance);\n    }\n\n    /** Create a new instance. */\n    private _createInstance(): IMediaInstance\n    {\n        if (!(this.media instanceof WebAudioStreamMedia) && Sound._pool.length > 0)\n        {\n            const instance: IMediaInstance = Sound._pool.pop()!;\n\n            instance.init(this.media);\n\n            return instance;\n        }\n\n        return this.media.create();\n    }\n\n    /**\n     * Destroy/recycling the instance object.\n     * @param instance - Instance to recycle\n     */\n    private _poolInstance(instance: IMediaInstance): void\n    {\n        instance.destroy();\n        // Add it if it isn't already added\n        if (!(instance instanceof WebAudioStreamInstance) && Sound._pool.indexOf(instance) < 0)\n        {\n            Sound._pool.push(instance);\n        }\n    }\n}\n\nexport { Sound };\nexport type {\n    CompleteCallback,\n    LoadedCallback,\n    Options,\n    PlayOptions,\n    SoundSpriteDataMap\n};\n","import { Filterable } from './Filterable';\nimport { type Filter } from './filters/Filter';\nimport { getInstance } from './instance';\nimport { type Sound } from './Sound';\nimport { type WebAudioContext } from './webaudio/WebAudioContext';\n\n/**\n * A named group of sounds with its own volume, mute, pause and (WebAudio only) filters, applied\n * on top of each sound's own settings and under the global ones. Get one with `sound.channel(name)`.\n */\nclass SoundChannel\n{\n    private _volume = 1;\n    private _muted = false;\n    private _paused = false;\n\n    /**\n     * The channel's sounds that have instances, playing or paused.\n     * @ignore\n     */\n    public readonly sounds = new Set<Sound>();\n\n    /** The filter chain between the channel's WebAudio sounds and the global filters, if WebAudio is supported */\n    private _nodes: Filterable | undefined;\n\n    /** @param context - The WebAudio context, if WebAudio is supported */\n    constructor(context?: WebAudioContext)\n    {\n        if (context)\n        {\n            const input = context.audioContext.createGain();\n\n            input.connect(context.destination);\n            this._nodes = new Filterable(input, context.destination);\n        }\n    }\n\n    /**\n     * The node the channel's WebAudio sounds connect to.\n     * @ignore\n     */\n    public get destination(): AudioNode | undefined\n    {\n        return this._nodes?.destination;\n    }\n\n    /**\n     * Filters applied to every sound in the channel, after each sound's own filters and before\n     * `sound.filtersAll`. **Only supported with WebAudio.**\n     */\n    public get filters(): Filter[]\n    {\n        return getInstance().useLegacy ? [] : this._nodes!.filters;\n    }\n    public set filters(filters: Filter[])\n    {\n        if (getInstance().useLegacy)\n        {\n            console.warn('HTML Audio does not support filters');\n\n            return;\n        }\n        this._nodes!.filters = filters;\n    }\n\n    /** Volume of the channel, from 0 to 1. Multiplied with the sound's and the global volume. */\n    public get volume(): number\n    {\n        return this._volume;\n    }\n    public set volume(volume: number)\n    {\n        this._volume = volume;\n        getInstance().context.refresh();\n    }\n\n    /** `true` to silence the channel's sounds without changing any volume. */\n    public get muted(): boolean\n    {\n        return this._muted;\n    }\n    public set muted(muted: boolean)\n    {\n        this._muted = muted;\n        getInstance().context.refresh();\n    }\n\n    /**\n     * `true` to pause the channel's sounds. They resume when this is set back to `false`,\n     * unless they are also paused themselves or globally. A sound played while its channel\n     * is paused starts paused.\n     */\n    public get paused(): boolean\n    {\n        return this._paused;\n    }\n    public set paused(paused: boolean)\n    {\n        this._paused = paused;\n        getInstance().context.refreshPaused();\n    }\n\n    /**\n     * `true` if any sound in the channel is playing, also while the channel is paused.\n     * A sound stops counting once it's paused with `pause()`.\n     */\n    public get isPlaying(): boolean\n    {\n        return [...this.sounds].some((sound) => sound.isPlaying);\n    }\n\n    /**\n     * Stops every sound in the channel, paused ones too, including sounds never added to the library.\n     * @return Instance for chaining.\n     */\n    public stop(): this\n    {\n        for (const sound of [...this.sounds])\n        {\n            sound.stop();\n        }\n\n        return this;\n    }\n}\n\nexport { SoundChannel };\n","import { EventEmitter } from 'pixi.js';\nimport { Filterable } from '../Filterable';\nimport { type IMediaContext } from '../interfaces';\n\n/** A suspend() or resume() rejects when the context is closed or interrupted before it settles */\nconst ignore = (): void => { /* nothing to do */ };\n\n/** Time constant in seconds of the fade into a blur pause and out of any pause */\nconst FADE_TIME_CONSTANT = 0.005;\n\n/** Seconds until that fade is down by 60 dB */\nconst FADE_OUT = 0.04;\n\n/** Seconds ahead that the fade out starts. Firefox has already rendered up to a block past `currentTime` */\nconst FADE_LEAD = 0.02;\n\n/** Seconds allowed for the output device to play what has been rendered */\nconst OUTPUT_DELAY = 0.06;\n\n/** Seconds of audio the compressor holds back. It plays first after a pause, so the fade in waits for it */\nconst COMPRESSOR_DELAY = 0.006;\n\n/**\n * Main class to handle WebAudio API. There's a simple chain\n * of AudioNode elements: analyser > compressor > gain > context.destination.\n * Any filters that are added are inserted between the analyser and compressor nodes.\n * The gain fades the output out before the window-blur pause and back in afterwards.\n * @memberof webaudio\n */\nclass WebAudioContext extends Filterable implements IMediaContext\n{\n    /**\n     * Context Compressor node\n     * @readonly\n     */\n    public compressor: DynamicsCompressorNode;\n\n    /**\n     * Context Analyser node\n     * @readonly\n     */\n    public analyser: AnalyserNode;\n\n    /**\n     * Global speed of all sounds\n     * @readonly\n     */\n    public speed: number;\n\n    /**\n     * Sets the muted state.\n     * @default false\n     */\n    public muted: boolean;\n\n    /**\n     * Sets the volume from 0 to 1.\n     * @default 1\n     */\n    public volume: number;\n\n    /**\n     * Handle global events\n     * @type {PIXI.EventEmitter}\n     */\n    public events: EventEmitter;\n\n    /** The instance of the AudioContext for WebAudio API. */\n    private _ctx: AudioContext;\n\n    /** The instance of the OfflineAudioContext for fast decoding audio. */\n    private _offlineCtx: OfflineAudioContext;\n\n    /** Current paused status */\n    private _paused!: boolean;\n\n    /**\n     * Indicated whether audio on iOS has been unlocked, which requires a touchend/mousedown event that plays an\n     * empty sound. Only ever goes from true to false.\n     */\n    private _locked: boolean;\n\n    /**\n     * The paused state saved by a window blur, or undefined when no blur is waiting for its focus.\n     * Setting paused while it waits clears it, so the focus leaves the app's choice alone.\n     */\n    private _pausedOnBlur: boolean | undefined;\n\n    /** The last node of the chain, new at each pause. It fades the output out before a blur pause and back in on resume. */\n    private _gate: GainNode;\n\n    /** Pauses once the fade started by a blur has been played, or undefined when no blur is fading */\n    private _blurTimer: ReturnType<typeof setTimeout> | undefined;\n\n    /**\n     * Set to false to stop pausing when the window is blurred.\n     * A pause that a blur has already made still ends on the next focus or tap.\n     */\n    public autoPause = true;\n\n    constructor()\n    {\n        const win: any = window as any;\n        const ctx = new WebAudioContext.AudioContext();\n        const compressor: DynamicsCompressorNode = ctx.createDynamicsCompressor();\n        const analyser: AnalyserNode = ctx.createAnalyser();\n        const gate = ctx.createGain();\n\n        // setup the end of the node chain\n        analyser.connect(compressor);\n        compressor.connect(gate);\n        gate.connect(ctx.destination);\n\n        super(analyser, compressor);\n\n        this._gate = gate;\n        this._ctx = ctx;\n        // ios11 safari's webkitOfflineAudioContext allows only 44100 Hz sample rate\n        //\n        // For the sample rate value passed to OfflineAudioContext constructor,\n        // all browsers are required to support a range of 8000 to 96000.\n        // Reference:\n        // https://www.w3.org/TR/webaudio/#dom-offlineaudiocontext-offlineaudiocontext-numberofchannels-length-samplerate\n        this._offlineCtx = new WebAudioContext.OfflineAudioContext(1, 2,\n            (win.OfflineAudioContext) ? Math.max(8000, Math.min(96000, ctx.sampleRate)) : 44100);\n\n        this.compressor = compressor;\n        this.analyser = analyser;\n        this.events = new EventEmitter();\n\n        // Set the defaults\n        this.volume = 1;\n        this.speed = 1;\n        this.muted = false;\n        this.paused = false;\n\n        this._locked = ctx.state === 'suspended' && ('ontouchstart' in globalThis || 'onclick' in globalThis);\n\n        this._unlock = this._unlock.bind(this);\n        this._checkUnlocked = this._checkUnlocked.bind(this);\n        // Listen for document level clicks to unlock WebAudio the first time, and to start it again\n        // after the OS stops it. See the _unlock method.\n        document.addEventListener('mousedown', this._unlock, true);\n        document.addEventListener('touchstart', this._unlock, true);\n        document.addEventListener('touchend', this._unlock, true);\n        if (this._locked)\n        {\n            // The context can also start without one of these: the app resumes it, or a sound starts in a key press\n            ctx.addEventListener('statechange', this._checkUnlocked);\n            this._unlock(); // When played inside of a touch event, this will enable audio on iOS immediately.\n        }\n\n        this.onFocus = this.onFocus.bind(this);\n        this.onBlur = this.onBlur.bind(this);\n        globalThis.addEventListener('focus', this.onFocus);\n        globalThis.addEventListener('blur', this.onBlur);\n    }\n\n    /** Handle mobile WebAudio context resume */\n    private onFocus(): void\n    {\n        const paused = this._pausedOnBlur;\n\n        if (paused === undefined)\n        {\n            // No blur to undo. Safari can still have stopped the context (it uses the non-standard\n            // \"interrupted\" state when the screen is locked or the user switches to another app)\n            if (this.autoPause && !this._paused)\n            {\n                this._resume();\n            }\n\n            return;\n        }\n        this.paused = paused;\n        this.refreshPaused();\n    }\n\n    /** Handle mobile WebAudio context suspend */\n    private onBlur(): void\n    {\n        if (!this.autoPause)\n        {\n            return;\n        }\n        if (!this._locked && this._pausedOnBlur === undefined)\n        {\n            const ctx = this._ctx;\n            const pausedOnBlur = this._paused;\n            const pause = (): void =>\n            {\n                this.paused = true;\n                // The setter forgets a waiting blur, as it must for the app's own pause, so save it again\n                this._pausedOnBlur = pausedOnBlur;\n                this.refreshPaused();\n            };\n\n            this._pausedOnBlur = pausedOnBlur;\n            if (this._paused || ctx.state !== 'running')\n            {\n                pause();\n\n                return;\n            }\n            // suspend() cuts the output wherever the wave is, so fade out first. It also drops what\n            // has been rendered but not yet played, so wait for the output delay as well.\n            // Reading outputLatency can stall Firefox's audio, hence the fixed allowance\n            this._paused = true;\n            this._fade(0, FADE_LEAD);\n            this._blurTimer = setTimeout(pause,\n                (FADE_LEAD + FADE_OUT + (ctx.baseLatency || 0) + OUTPUT_DELAY) * 1000);\n        }\n    }\n\n    /** Fade the output level to `value`, starting `delay` seconds from now. */\n    private _fade(value: number, delay: number): void\n    {\n        const { gain } = this._gate;\n        const at = this._ctx.currentTime + delay;\n\n        gain.cancelScheduledValues(at);\n        gain.setTargetAtTime(value, at, FADE_TIME_CONSTANT);\n    }\n\n    /**\n     * Try to unlock audio on iOS. This is triggered from either WebAudio plugin setup (which will work if inside of\n     * a `mousedown` or `touchend` event stack), or the first document touchend/mousedown event. If it fails (touchend\n     * will fail if the user presses for too long, indicating a scroll event instead of a click event.\n     *\n     * Note that earlier versions of iOS supported `touchstart` for this, but iOS9 removed this functionality. Adding\n     * a `touchstart` event to support older platforms may preclude a `mousedown` even from getting fired on iOS9, so we\n     * stick with `mousedown` and `touchend`.\n     *\n     * Once unlocked, the same events restart a context that iOS stopped (app switch, call, headphones unplugged)\n     * unless it's paused.\n     */\n    private _unlock(): void\n    {\n        if (this._locked)\n        {\n            this.playEmptySound();\n            this._checkUnlocked();\n\n            return;\n        }\n        this._recover();\n    }\n\n    /**\n     * Clear the lock once the context is running, whatever started it. Firefox and Safari only\n     * update the state when resume() settles, so this also runs on `statechange` and after each resume().\n     */\n    private _checkUnlocked(): void\n    {\n        if (this._locked && this._ctx.state === 'running')\n        {\n            this._locked = false;\n            this._ctx.removeEventListener('statechange', this._checkUnlocked);\n        }\n    }\n\n    /**\n     * Start the context again when something other than `paused` stopped it: iOS suspends or interrupts it\n     * on an app switch, a call or when headphones are unplugged, and may only let it resume in a user gesture.\n     */\n    private _recover(): void\n    {\n        // A tap means the page is in front, even if the focus event never came\n        if (this._pausedOnBlur !== undefined)\n        {\n            this.onFocus();\n\n            return;\n        }\n        const state = this._ctx.state as AudioContextState | 'interrupted';\n\n        if (!this._paused && (state === 'suspended' || state === 'interrupted'))\n        {\n            this._resume();\n        }\n    }\n\n    /** Stop listening for the events that unlock or restart the context. */\n    private _removeUnlockListeners(): void\n    {\n        this._ctx.removeEventListener('statechange', this._checkUnlocked);\n        document.removeEventListener('mousedown', this._unlock, true);\n        document.removeEventListener('touchend', this._unlock, true);\n        document.removeEventListener('touchstart', this._unlock, true);\n    }\n\n    /** Resume the context, then suspend it again if that settles while paused. */\n    private _resume(): void\n    {\n        const ctx = this._ctx;\n\n        ctx.resume()?.then(() =>\n        {\n            if (this._ctx !== ctx)\n            {\n                return;\n            }\n            this._checkUnlocked();\n            // An unlock gesture resumes the context even while paused, and\n            // older Chromium ignores a suspend() made while a resume() is in flight.\n            // A blur that is still fading out suspends when its timer fires\n            if (this._paused && this._blurTimer === undefined && ctx.state === 'running')\n            {\n                ctx.suspend()?.catch(ignore);\n            }\n        }).catch(ignore);\n    }\n\n    /**\n     * Plays an empty sound in the web audio context.  This is used to enable web audio on iOS devices, as they\n     * require the first sound to be played inside of a user initiated event (touch/click).\n     * If the context is paused, it's suspended again as soon as it has started.\n     */\n    public playEmptySound(): void\n    {\n        const source = this._ctx.createBufferSource();\n\n        source.buffer = this._ctx.createBuffer(1, 1, 22050);\n        source.connect(this._ctx.destination);\n        source.start(0, 0, 0);\n        const state = source.context.state as AudioContextState | 'interrupted';\n\n        if (state === 'suspended' || state === 'interrupted')\n        {\n            this._resume();\n        }\n    }\n\n    /**\n     * Get AudioContext class, if not supported returns `null`\n     * @type {AudioContext}\n     * @readonly\n     */\n    public static get AudioContext(): typeof AudioContext\n    {\n        const win: any = window as any;\n\n        return (\n            win.AudioContext\n            || win.webkitAudioContext\n            || null\n        );\n    }\n\n    /**\n     * Get OfflineAudioContext class, if not supported returns `null`\n     * @type {OfflineAudioContext}\n     * @readonly\n     */\n    public static get OfflineAudioContext(): typeof OfflineAudioContext\n    {\n        const win: any = window as any;\n\n        return (\n            win.OfflineAudioContext\n            || win.webkitOfflineAudioContext\n            || null\n        );\n    }\n\n    /** Destroy this context. */\n    public destroy(): void\n    {\n        super.destroy();\n\n        const ctx: any = this._ctx as any;\n        // check if browser supports AudioContext.close()\n\n        if (typeof ctx.close !== 'undefined')\n        {\n            ctx.close();\n        }\n        this._removeUnlockListeners();\n        clearTimeout(this._blurTimer);\n        this._gate.disconnect();\n        globalThis.removeEventListener('focus', this.onFocus);\n        globalThis.removeEventListener('blur', this.onBlur);\n        this.events.removeAllListeners();\n        this.analyser.disconnect();\n        this.compressor.disconnect();\n        this.analyser = null!;\n        this.compressor = null!;\n        this.events = null!;\n        this._gate = null!;\n        this._offlineCtx = null!;\n        this._ctx = null!;\n    }\n\n    /**\n     * The WebAudio API AudioContext object.\n     * @readonly\n     * @type {AudioContext}\n     */\n    public get audioContext(): AudioContext\n    {\n        return this._ctx;\n    }\n\n    /**\n     * The WebAudio API OfflineAudioContext object.\n     * @readonly\n     * @type {OfflineAudioContext}\n     */\n    public get offlineContext(): OfflineAudioContext\n    {\n        return this._offlineCtx;\n    }\n\n    /**\n     * Pauses all sounds, even though we handle this at the instance\n     * level, we'll also pause the audioContext so that the\n     * time used to compute progress isn't messed up.\n     * The audioContext follows the last value set, including when\n     * it's changed more than once in the same tick.\n     * While not paused, a context stopped by the browser is resumed on the next tap,\n     * including one stopped by calling `audioContext.suspend()` directly. Use `paused` or\n     * `pauseAll()` to pause.\n     * Setting it while the window is blurred overrides the blur's pause, so the next focus keeps it.\n     * A direct `paused = false` made then resumes the context and streaming sounds, but not the other\n     * sounds, so use `resumeAll()`.\n     * @default false\n     */\n    public set paused(paused: boolean)\n    {\n        clearTimeout(this._blurTimer);\n        this._blurTimer = undefined;\n        this._pausedOnBlur = undefined;\n        this._paused = paused;\n        const ctx = this._ctx;\n\n        if (ctx.state === 'closed')\n        {\n            return;\n        }\n        // The state can still show the old value while an earlier suspend() or resume() is in\n        // flight (Firefox, Safari), so always ask for the state we want instead of checking it first\n        if (paused)\n        {\n            // The compressor holds back 6 ms and plays it after the pause, at the level it had before.\n            // A gain change can land a sample late, so swap in a gate that starts shut\n            try\n            {\n                this.compressor.disconnect(this._gate);\n                const gate = ctx.createGain();\n\n                gate.gain.value = 0;\n                this.compressor.connect(gate);\n                gate.connect(ctx.destination);\n                this._gate = gate;\n            }\n            catch\n            {\n                // The app has disconnected the compressor itself, so there is nothing to swap\n            }\n            ctx.suspend()?.catch(ignore);\n        }\n        else\n        {\n            this._fade(1, COMPRESSOR_DELAY);\n            this._resume();\n        }\n    }\n    public get paused(): boolean\n    {\n        return this._paused;\n    }\n\n    /** Emit event when muted, volume or speed changes */\n    public refresh(): void\n    {\n        this.events.emit('refresh');\n    }\n\n    /** Emit event when muted, volume or speed changes */\n    public refreshPaused(): void\n    {\n        this.events.emit('refreshPaused');\n    }\n\n    /**\n     * Toggles the muted state.\n     * @return The current muted state.\n     */\n    public toggleMute(): boolean\n    {\n        this.muted = !this.muted;\n        this.refresh();\n\n        return this.muted;\n    }\n\n    /**\n     * Toggles the paused state.\n     * @return The current muted state.\n     */\n    public togglePause(): boolean\n    {\n        this.paused = !this.paused;\n        this.refreshPaused();\n\n        return this._paused;\n    }\n\n    /**\n     * Decode the audio data\n     * @param arrayBuffer - Buffer from loader\n     * @param callback - Called once when decoding finishes, with the browser's error or the decoded buffer.\n     */\n    public decode(arrayBuffer: ArrayBuffer, callback: (err?: Error, buffer?: AudioBuffer) => void): void\n    {\n        // A failed decode rejects the promise and also calls the error callback, and some\n        // errors only reject the promise, so listen to both and report the first outcome only\n        let settled = false;\n        const finish = (err: Error, buffer?: AudioBuffer) =>\n        {\n            if (settled)\n            {\n                return;\n            }\n            settled = true;\n            callback(err, buffer);\n        };\n        const handleError = (err: Error) =>\n        {\n            // Old engines call back with no error at all\n            finish(err?.message ? err : new Error('Unable to decode file'));\n        };\n        const result = this._offlineCtx.decodeAudioData(\n            arrayBuffer, (buffer: AudioBuffer) =>\n            {\n                finish(null!, buffer);\n            },\n            handleError,\n        );\n        // Reference: https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/decodeAudioData\n        // decodeAudioData return value: Void, or a Promise object that fulfills with the decodedData.\n\n        if (result)\n        {\n            result.catch(handleError);\n        }\n    }\n}\n\nexport { WebAudioContext };\n","import { type Filter } from './filters/Filter';\nimport { HTMLAudioContext } from './htmlaudio/HTMLAudioContext';\nimport { type IMediaContext } from './interfaces/IMediaContext';\nimport { type IMediaInstance } from './interfaces/IMediaInstance';\nimport { type CompleteCallback, type Options, type PlayOptions, Sound } from './Sound';\nimport { SoundChannel } from './SoundChannel';\nimport { withoutUndefined } from './utils/withoutUndefined';\nimport { WebAudioContext } from './webaudio/WebAudioContext';\n\ntype SoundSourceMap = Record<string, Options | string | ArrayBuffer | AudioBuffer | HTMLAudioElement>;\ntype SoundMap = Record<string, Sound>;\n\n/**\n * Manages the playback of sounds. This is the main class for PixiJS Sound. Only the\n * exported `sound` instance is supported: sounds and filters always use the audio context\n * of `sound`, so a second `SoundLibrary` isn't independent of it. If you're using the\n * browser-based bundled this is `PIXI.sound`. Otherwise, you can do this:\n * @example\n * import { sound } from '@pixi/sound';\n *\n * // sound is an instance of SoundLibrary\n * sound.add('my-sound', 'path/to/file.mp3');\n * sound.play('my-sound');\n */\nclass SoundLibrary\n{\n    /**\n     * For legacy approach for Audio. Instead of using WebAudio API\n     * for playback of sounds, it will use HTML5 `<audio>` element.\n     */\n    private _useLegacy!: boolean;\n\n    /** The global context to use. */\n    private _context!: IMediaContext;\n\n    /** The WebAudio specific context */\n    private _webAudioContext: WebAudioContext | undefined;\n\n    /** The HTML Audio (legacy) context. */\n    private _htmlAudioContext!: HTMLAudioContext;\n\n    /** The map of all sounds by alias. */\n    private _sounds!: SoundMap;\n\n    /** The channels by name. */\n    private _channels!: Record<string, SoundChannel>;\n\n    constructor()\n    {\n        this.init();\n    }\n\n    /**\n     * Re-initialize the sound library, this will\n     * recreate the AudioContext. If there's a hardware-failure\n     * call `close` and then `init`.\n     * @return Sound instance\n     */\n    public init(): this\n    {\n        if (this.supported)\n        {\n            this._webAudioContext = new WebAudioContext();\n        }\n        this._htmlAudioContext = new HTMLAudioContext();\n        this._sounds = {};\n        this._channels = Object.create(null);\n        this.useLegacy = !this.supported;\n\n        return this;\n    }\n\n    /**\n     * Get a channel by name, creating it the first time the name is used.\n     * @param name - Name of the channel, as given in a sound's `channel` option.\n     * @example\n     * import { sound } from '@pixi/sound';\n     * sound.add('theme', { url: 'theme.mp3', channel: 'music' });\n     * sound.channel('music').volume = 0.5;\n     */\n    public channel(name: string): SoundChannel\n    {\n        this._channels[name] ??= new SoundChannel(this._webAudioContext);\n\n        return this._channels[name];\n    }\n\n    /**\n     * The global context to use.\n     * @readonly\n     */\n    public get context(): IMediaContext\n    {\n        return this._context;\n    }\n\n    /**\n     * Apply filters to all sounds. Can be useful\n     * for setting global planning or global effects.\n     * **Only supported with WebAudio.**\n     * @example\n     * import { sound, filters } from '@pixi/sound';\n     * // Adds a filter to pan all output left\n     * sound.filtersAll = [\n     *     new filters.StereoFilter(-1)\n     * ];\n     */\n    public get filtersAll(): Filter[]\n    {\n        if (!this.useLegacy)\n        {\n            return this._context.filters;\n        }\n\n        return [];\n    }\n    public set filtersAll(filtersAll: Filter[])\n    {\n        if (!this.useLegacy)\n        {\n            this._context.filters = filtersAll;\n        }\n    }\n\n    /**\n     * `true` if WebAudio is supported on the current browser.\n     */\n    public get supported(): boolean\n    {\n        return WebAudioContext.AudioContext !== null;\n    }\n\n    /**\n     * Register an existing sound with the library cache.\n     * @method add\n     * @instance\n     * @param {string} alias - The sound alias reference.\n     * @param {Sound} sound - Sound reference to use.\n     * @return {Sound} Instance of the Sound object.\n     */\n\n    /**\n     * Adds a new sound by alias.\n     * @param alias - The sound alias reference.\n     * @param {ArrayBuffer|AudioBuffer|String|Options|HTMLAudioElement} options - Either the path or url to the source file.\n     *        or the object of options to use.\n     * @return Instance of the Sound object.\n     */\n    public add(alias: string, options: Options | string | ArrayBuffer | AudioBuffer | HTMLAudioElement | Sound): Sound;\n\n    /**\n     * Adds multiple sounds at once.\n     * @param map - Map of sounds to add, the key is the alias, the value is the\n     *        `string`, `ArrayBuffer`, `AudioBuffer`, `HTMLAudioElement` or the list of options\n     *        (see {@link Options} for full options).\n     * @param globalOptions - Options applied to every sound in the map. These override\n     *        a sound's own options with the same key.\n     * @return Instance to the Sound object.\n     */\n    public add(map: SoundSourceMap, globalOptions?: Options): SoundMap;\n\n    /**\n     * @ignore\n     */\n    public add(source: string | SoundSourceMap,\n        sourceOptions?: Options | string | ArrayBuffer | AudioBuffer | HTMLAudioElement | Sound): any\n    {\n        if (typeof source === 'object')\n        {\n            const results: SoundMap = {};\n\n            for (const alias in source)\n            {\n                const options: Options = this._getOptions(\n                    source[alias]!,\n                    sourceOptions as Options,\n                );\n\n                results[alias] = this.add(alias, options);\n            }\n\n            return results;\n        }\n\n        // eslint-disable-next-line no-console\n        console.assert(!this._sounds[source], `Sound with alias ${source} already exists.`);\n\n        if (sourceOptions instanceof Sound)\n        {\n            this._sounds[source] = sourceOptions;\n\n            return sourceOptions;\n        }\n\n        const options: Options = this._getOptions(sourceOptions!);\n        const sound: Sound = Sound.from(options);\n\n        this._sounds[source] = sound;\n\n        return sound;\n    }\n\n    /**\n     * Internal methods for getting the options object\n     * @private\n     * @param source - The source options\n     * @param overrides - Override default options\n     * @return The construction options\n     */\n    private _getOptions(source: string | ArrayBuffer | AudioBuffer | HTMLAudioElement | Options,\n        overrides?: Options): Options\n    {\n        let options: Options;\n\n        if (typeof source === 'string')\n        {\n            options = { url: source };\n        }\n        else if (Array.isArray(source))\n        {\n            options = { url: source };\n        }\n        else if (source instanceof ArrayBuffer || source instanceof AudioBuffer || source instanceof HTMLAudioElement)\n        {\n            options = { source };\n        }\n        else\n        {\n            options = source as Options;\n        }\n        options = { ...options, ...withoutUndefined(overrides) };\n\n        return options;\n    }\n\n    /**\n     * Do not use WebAudio, force the use of legacy. This **must** be called before loading any files.\n     */\n    public get useLegacy(): boolean\n    {\n        return this._useLegacy;\n    }\n    public set useLegacy(legacy: boolean)\n    {\n        this._useLegacy = legacy;\n\n        // Set the context to use\n        this._context = (!legacy && this.supported)\n            ? this._webAudioContext!\n            : this._htmlAudioContext;\n    }\n\n    /**\n     * This disables auto-pause all playback when the window blurs (WebAudio only).\n     * This is helpful to keep from playing sounds when the user switches tabs.\n     * The output fades out first, so sounds pause a little over a tenth of a second after the blur.\n     * However, if you're running content within an iframe, this may be undesirable\n     * and you should disable (set to `true`) this behavior.\n     * Turning it on while a blur has paused the sounds lets them resume on the next focus.\n     * When WebAudio isn't supported, nothing auto-pauses, so it reads `true` and setting it does nothing.\n     * @default false\n     */\n    public get disableAutoPause(): boolean\n    {\n        return !this._webAudioContext?.autoPause;\n    }\n    public set disableAutoPause(autoPause: boolean)\n    {\n        if (this._webAudioContext)\n        {\n            this._webAudioContext.autoPause = !autoPause;\n        }\n    }\n\n    /**\n     * Removes a sound and all aliases referencing it.\n     * @param alias - The sound alias reference.\n     * @return Instance for chaining.\n     */\n    public remove(alias: string): this\n    {\n        const sound = this.find(alias);\n\n        if (!sound)\n        {\n            return this;\n        }\n\n        for (const name in this._sounds)\n        {\n            if (this._sounds[name] === sound)\n            {\n                delete this._sounds[name];\n            }\n        }\n        sound.destroy();\n\n        return this;\n    }\n\n    /**\n     * Set the global volume for all sounds. To set per-sound volume see {@link SoundLibrary#volume}.\n     */\n    public get volumeAll(): number\n    {\n        return this._context.volume;\n    }\n    public set volumeAll(volume: number)\n    {\n        this._context.volume = volume;\n        this._context.refresh();\n    }\n\n    /**\n     * Set the global speed for all sounds. To set per-sound speed see {@link SoundLibrary#speed}.\n     */\n    public get speedAll(): number\n    {\n        return this._context.speed;\n    }\n    public set speedAll(speed: number)\n    {\n        this._context.speed = speed;\n        this._context.refresh();\n    }\n\n    /**\n     * Toggle paused property for all sounds.\n     * @return `true` if all sounds are paused.\n     */\n    public togglePauseAll(): boolean\n    {\n        return this._context.togglePause();\n    }\n\n    /**\n     * Pauses any playing sounds. A sound played while paused starts on `resumeAll()`.\n     * @return Instance for chaining.\n     */\n    public pauseAll(): this\n    {\n        this._context.paused = true;\n        this._context.refreshPaused();\n\n        return this;\n    }\n\n    /**\n     * Resumes any sounds.\n     * @return Instance for chaining.\n     */\n    public resumeAll(): this\n    {\n        this._context.paused = false;\n        this._context.refreshPaused();\n\n        return this;\n    }\n\n    /**\n     * Toggle muted property for all sounds.\n     * @return `true` if all sounds are muted.\n     */\n    public toggleMuteAll(): boolean\n    {\n        return this._context.toggleMute();\n    }\n\n    /**\n     * Mutes all playing sounds.\n     * @return Instance for chaining.\n     */\n    public muteAll(): this\n    {\n        this._context.muted = true;\n        this._context.refresh();\n\n        return this;\n    }\n\n    /**\n     * Unmutes all playing sounds.\n     * @return Instance for chaining.\n     */\n    public unmuteAll(): this\n    {\n        this._context.muted = false;\n        this._context.refresh();\n\n        return this;\n    }\n\n    /**\n     * Stops and removes all sounds in the library. They cannot be used after this.\n     * @return Instance for chaining.\n     */\n    public removeAll(): this\n    {\n        if (!this._sounds)\n        {\n            return this;\n        }\n        for (const sound of new Set(Object.values(this._sounds)))\n        {\n            sound.destroy();\n        }\n        this._sounds = {};\n\n        return this;\n    }\n\n    /**\n     * Stops all sounds in the library (see {@link Sound.from}).\n     * @return Instance for chaining.\n     */\n    public stopAll(): this\n    {\n        if (!this._sounds)\n        {\n            return this;\n        }\n        for (const sound of new Set(Object.values(this._sounds)))\n        {\n            sound.stop();\n        }\n\n        return this;\n    }\n\n    /**\n     * Checks if a sound by alias exists.\n     * @param alias - Check for alias.\n     * @param assert - Whether enable console.assert.\n     * @return true if the sound exists.\n     */\n    public exists(alias: string, assert = false): boolean\n    {\n        const exists = !!this._sounds[alias];\n\n        if (assert)\n        {\n            // eslint-disable-next-line no-console\n            console.assert(exists, `No sound matching alias '${alias}'.`);\n        }\n\n        return exists;\n    }\n\n    /**\n     * Convenience function to check to see if any sound in the library is playing.\n     * @returns `true` if any sound is currently playing.\n     */\n    public isPlaying(): boolean\n    {\n        for (const alias in this._sounds)\n        {\n            if (this._sounds[alias]!.isPlaying)\n            {\n                return true;\n            }\n        }\n\n        return false;\n    }\n\n    /**\n     * Find a sound by alias.\n     * @param alias - The sound alias reference.\n     * @return Sound object.\n     */\n    public find(alias: string): Sound\n    {\n        this.exists(alias, true);\n\n        return this._sounds[alias]!;\n    }\n\n    /**\n     * Plays a sound.\n     * @method play\n     * @instance\n     * @param {string} alias - The sound alias reference.\n     * @param {string} sprite - The alias of the sprite to play.\n     * @return {IMediaInstance|Promise<IMediaInstance>|null} The sound instance, this cannot be reused\n     *         after it is done playing. Returns a Promise if the sound has not yet loaded, or `null`\n     *         if there's no sound with that alias or no sprite with that name.\n     */\n\n    /**\n     * Plays a sound.\n     * @param alias - The sound alias reference.\n     * @param {PlayOptions|Function} options - The options or callback when done.\n     * @return The sound instance,\n     *        this cannot be reused after it is done playing. Returns a Promise if the sound\n     *        has not yet loaded. Returns `null` if there's no sound with that alias or no sprite\n     *        with that name.\n     */\n    public play(\n        alias: string,\n        options?: PlayOptions | CompleteCallback | string): IMediaInstance | Promise<IMediaInstance>\n    {\n        return this.find(alias)?.play(options) ?? null;\n    }\n\n    /**\n     * Stops a sound.\n     * @param alias - The sound alias reference.\n     * @return Sound object, or `undefined` if there's no sound with that alias.\n     */\n    public stop(alias: string): Sound\n    {\n        return this.find(alias)?.stop();\n    }\n\n    /**\n     * Pauses a sound.\n     * @param alias - The sound alias reference.\n     * @return Sound object, or `undefined` if there's no sound with that alias.\n     */\n    public pause(alias: string): Sound\n    {\n        return this.find(alias)?.pause();\n    }\n\n    /**\n     * Resumes a sound.\n     * @param alias - The sound alias reference.\n     * @return Sound object, or `undefined` if there's no sound with that alias.\n     */\n    public resume(alias: string): Sound\n    {\n        return this.find(alias)?.resume();\n    }\n\n    /**\n     * Get or set the volume for a sound.\n     * @param alias - The sound alias reference.\n     * @param volume - Optional current volume to set.\n     * @return The current volume, or `NaN` if there's no sound with that alias.\n     */\n    public volume(alias: string, volume?: number): number\n    {\n        const sound = this.find(alias);\n\n        if (sound && volume !== undefined)\n        {\n            sound.volume = volume;\n        }\n\n        return sound?.volume ?? NaN;\n    }\n\n    /**\n     * Get or set the speed for a sound.\n     * @param alias - The sound alias reference.\n     * @param speed - Optional current speed to set.\n     * @return The current speed, or `NaN` if there's no sound with that alias.\n     */\n    public speed(alias: string, speed?: number): number\n    {\n        const sound = this.find(alias);\n\n        if (sound && speed !== undefined)\n        {\n            sound.speed = speed;\n        }\n\n        return sound?.speed ?? NaN;\n    }\n\n    /**\n     * Get the length of a sound in seconds.\n     * @param alias - The sound alias reference.\n     * @return The duration in seconds, or `NaN` if the sound hasn't loaded yet, failed to load, or\n     *         there's no sound with that alias.\n     */\n    public duration(alias: string): number\n    {\n        return this.find(alias)?.duration ?? NaN;\n    }\n\n    /**\n     * Closes the sound library. This will release/destroy\n     * the AudioContext(s). Sounds that aren't in the library are paused, and can\n     * still be stopped or destroyed. Playing them again isn't supported, even after\n     * `init()`: create them again. Can be used safely if you want to\n     * initialize the sound library later. Use `init` method.\n     */\n    public close(): this\n    {\n        this.removeAll();\n        // Sounds not in the library keep their instances: hold them, so nothing keeps playing after close\n        if (this._context)\n        {\n            this.pauseAll();\n        }\n        this._sounds = null!;\n        if (this._webAudioContext)\n        {\n            this._webAudioContext.destroy();\n            this._webAudioContext = null!;\n        }\n        if (this._htmlAudioContext)\n        {\n            this._htmlAudioContext.destroy();\n            this._htmlAudioContext = null!;\n        }\n        this._context = null!;\n\n        return this;\n    }\n}\n\nexport { SoundLibrary };\nexport type { SoundMap, SoundSourceMap };\n","import { getInstance } from '../instance';\n\n/**\n * Increment the alias for play once\n * @static\n * @default 0\n */\nlet PLAY_ID = 0;\n\n/**\n * Create a new \"Audio\" stream based on given audio path and project uri; returns the audio object.\n * @memberof utils\n * @param url - Full path of the file to play.\n * @param {Function} callback - Callback when complete.\n * @return New audio element alias.\n */\nfunction playOnce(url: string, callback?: (err?: Error) => void): string\n{\n    const alias = `alias${PLAY_ID++}`;\n\n    getInstance().add(alias, {\n        url,\n        preload: true,\n        autoPlay: true,\n        loaded: (err: Error) =>\n        {\n            if (err)\n            {\n                console.error(err);\n                // Already gone if the sound was removed, or the library closed, while loading\n                if (getInstance().context && getInstance().exists(alias))\n                {\n                    getInstance().remove(alias);\n                }\n                if (callback)\n                {\n                    callback(err);\n                }\n            }\n        },\n        complete: () =>\n        {\n            getInstance().remove(alias);\n            if (callback)\n            {\n                callback(null!);\n            }\n        },\n    });\n\n    return alias;\n}\n\nexport { PLAY_ID, playOnce };\n","import { CanvasSource, type ICanvas, type TextureSource } from 'pixi.js';\nimport { type Sound } from '../Sound';\nimport { WebAudioMedia } from '../webaudio/WebAudioMedia';\n\ninterface RenderOptions\n{\n    /**\n     * Width of the render.\n     * @default 512\n     */\n    width?: number;\n    /**\n     * Height of the render.\n     * @default 128\n     */\n    height?: number;\n    /**\n     * Fill style for waveform.\n     * @default 'black'\n     */\n    fill?: string | CanvasPattern | CanvasGradient;\n}\n\n/**\n * Render image as Texture. **Only supported with WebAudio**\n * @memberof utils\n * @param sound - Instance of sound to render\n * @param options - Custom rendering options\n * @return Result texture\n */\nfunction render(sound: Sound, options?: RenderOptions): TextureSource\n{\n    const canvas: HTMLCanvasElement = document.createElement('canvas');\n\n    options = {\n        width: 512,\n        height: 128,\n        fill: 'black', ...(options || {})\n    };\n\n    canvas.width = options.width!;\n    canvas.height = options.height!;\n\n    const textureSource = new CanvasSource({\n        resource: canvas as ICanvas,\n    });\n\n    if (!(sound.media instanceof WebAudioMedia))\n    {\n        return textureSource;\n    }\n\n    const media: WebAudioMedia = sound.media as WebAudioMedia;\n\n    // eslint-disable-next-line no-console\n    console.assert(!!media.buffer, 'No buffer found, load first');\n\n    const context: CanvasRenderingContext2D = canvas.getContext('2d')!;\n\n    context.fillStyle = options.fill!;\n    const data: Float32Array = media.buffer.getChannelData(0);\n    const step: number = Math.ceil(data.length / options.width!);\n    const amp: number = options.height! / 2;\n\n    for (let i = 0; i < options.width!; i++)\n    {\n        let min = 1.0;\n        let max = -1.0;\n\n        for (let j = 0; j < step; j++)\n        {\n            const datum: number = data[(i * step) + j]!;\n\n            if (datum < min)\n            {\n                min = datum;\n            }\n            if (datum > max)\n            {\n                max = datum;\n            }\n        }\n        context.fillRect(i, (1 + min) * amp, 1, Math.max(1, (max - min) * amp));\n    }\n\n    return textureSource;\n}\n\nexport { render };\nexport type { RenderOptions };\n\n","import { Sound } from '../Sound';\nimport { type WebAudioContext } from '../webaudio/WebAudioContext';\nimport { WebAudioMedia } from '../webaudio/WebAudioMedia';\n\n/**\n * Create a new sound for a sine wave-based tone at full scale (peaks at 1); use `volume` to make it quieter.\n * **Only supported with WebAudio**\n * @memberof utils\n * @param hertz - Frequency of sound.\n * @param seconds - Duration of sound in seconds.\n * @return New sound.\n */\nfunction sineTone(hertz = 200, seconds = 1): Sound\n{\n    const sound = Sound.from({\n        singleInstance: true,\n    });\n\n    if (!(sound.media instanceof WebAudioMedia))\n    {\n        return sound;\n    }\n\n    const media = sound.media as WebAudioMedia;\n    const context = sound.context as WebAudioContext;\n\n    // set default value\n    const nChannels = 1;\n    const sampleRate = 48000;\n\n    // create the buffer\n    const buffer = context.audioContext.createBuffer(\n        nChannels,\n        seconds * sampleRate,\n        sampleRate,\n    );\n    const fArray = buffer.getChannelData(0);\n\n    // fill the buffer\n    for (let i = 0; i < fArray.length; i++)\n    {\n        const time = i / buffer.sampleRate;\n        const angle = hertz * time * 2 * Math.PI;\n\n        fArray[i] = Math.sin(angle);\n    }\n\n    // set the buffer\n    media.buffer = buffer;\n    sound.isLoaded = true;\n\n    return sound;\n}\n\nexport { sineTone };\n","import {\n    type AssetExtension,\n    extensions,\n    ExtensionType,\n    type LoaderParser,\n    LoaderParserPriority,\n    path,\n    type ResolvedAsset\n} from 'pixi.js';\nimport { getInstance } from './instance';\nimport { type Options, Sound } from './Sound';\nimport { extensions as exts, mimes, supported } from './utils/supported';\n\n/** Get all aliases while preserving the basename fallback for direct URL loads. */\nconst getAliases = (asset: ResolvedAsset) =>\n{\n    const src = asset.src!;\n    let alias = asset?.alias?.[0];\n\n    if (!alias || asset.src === alias)\n    {\n        alias = path.basename(src, path.extname(src));\n    }\n\n    return [...new Set([alias, ...(asset.alias || []).filter((entry) => entry && entry !== src)])];\n};\n\n/**\n * Assets extension that loads audio files as {@link Sound} objects and adds them to the library\n * under every alias. The asset's `data` is passed to {@link Sound.from}, so it accepts any\n * {@link Options} except `url` and `preload`, including `sprites`.\n */\nconst soundAsset = {\n    extension: ExtensionType.Asset,\n    detection: {\n        test: async () => true,\n        add: async (formats) => [...formats, ...exts.filter((ext) => supported[ext])],\n        remove: async (formats) => formats.filter((ext) => formats.includes(ext)),\n    },\n    loader: {\n        name: 'sound',\n        extension: {\n            type: [ExtensionType.LoadParser],\n            priority: LoaderParserPriority.High,\n        },\n\n        /** Should we attempt to load this file? */\n        test(url: string): boolean\n        {\n            const ext = path.extname(url).slice(1);\n\n            return !!supported[ext] || mimes.some((mime) => url.startsWith(`data:${mime}`));\n        },\n\n        /** Load the sound file, this is mostly handled by Sound.from() */\n        async load(url: string, asset: ResolvedAsset<Omit<Options, 'url' | 'preload'>>): Promise<Sound>\n        {\n            // We'll use the internal Sound.from to load the asset\n            const sound = await new Promise<Sound>((resolve, reject) => Sound.from({\n                ...asset.data,\n                url,\n                preload: true,\n                loaded(err, sound)\n                {\n                    if (err)\n                    {\n                        reject(err);\n                    }\n                    else\n                    {\n                        resolve(sound!);\n                    }\n                    asset.data?.loaded?.(err, sound);\n                },\n            }));\n\n            for (const alias of getAliases(asset))\n            {\n                getInstance().add(alias, sound);\n            }\n\n            return sound;\n        },\n\n        /** Remove the sound from the library */\n        async unload(_sound: Sound, asset: ResolvedAsset): Promise<void>\n        {\n            const library = getInstance();\n            const alias = getAliases(asset).find((name) => library.exists(name) && library.find(name) === _sound);\n\n            // Removing one alias removes every reference to this sound. It may already\n            // have been removed manually, or an alias may now belong to another sound.\n            if (alias !== undefined)\n            {\n                library.remove(alias);\n            }\n            else if (_sound.media)\n            {\n                _sound.destroy();\n            }\n        },\n    } as LoaderParser<Sound>,\n} as AssetExtension;\n\nextensions.add(soundAsset);\n\nexport { soundAsset };\n","import * as filters from './filters';\nimport * as htmlaudio from './htmlaudio';\nimport { setInstance } from './instance';\nimport { SoundLibrary } from './SoundLibrary';\nimport * as utils from './utils';\nimport * as webaudio from './webaudio';\n\nconst sound = setInstance(new SoundLibrary());\n\nexport * from './Filterable';\nexport * from './filters/Filter';\nexport * from './interfaces';\nexport * from './Sound';\nexport * from './soundAsset';\nexport * from './SoundChannel';\nexport * from './SoundLibrary';\nexport * from './SoundSprite';\nexport {\n    filters,\n    htmlaudio,\n    sound,\n    utils,\n    webaudio,\n};\n"],"names":["instance","setInstance","sound","getInstance","destination","source","_a","Filter","amount","distortion","audioContext","value","scaledValue","samples","curve","deg","i","x","param","context","_EqualizerFilter","f32","f64","f125","f250","f500","f1k","f2k","f4k","f8k","f16k","bands","equalizerBands","band","node","WebAudioUtils","frequency","gain","EqualizerFilter","merger","splitter","h$4","seconds","decay","reverse","min","max","rate","length","impulse","impulseL","impulseR","n","convolver","p$5","pan","stereo","panner","l$3","lpf1","lpf2","hpf1","hpf2","s$2","EventEmitter","paused","_filters","id","_HTMLAudioInstance","parent","name","currentTime","media","speed","volume","loop","muted","global","globalVolume","soundVolume","channel","channelVolume","instanceVolume","pausedReal","end","options","_b","start","Ticker","error","HTMLAudioInstance","callback","onLoad","removeListeners","onAbort","onError","message","complete","extensions","mimes","supported","validateFormats","typeOverrides","overrides","__spreadValues","audio","formats","no","ext","canByExt","canByType","withoutUndefined","result","key","R$1","filters","filter","pastEnd","positiveModulo","duration","enabled","_c","force","now","delta","progress","soundLength","err","input","output","prevFilter","_WebAudioNodes","Filterable","bufferSource","analyser","orig","WebAudioNodes","DESTROYED","decodeError","url","from","WebAudioInstance","buffer","arrayBuffer","response","DOMAdapter","audioBufferReadyFn","MIN_RATE","MAX_RATE","GESTURES","c$2","event","d$1","HTMLAudioMedia","WebAudioStreamInstance","A","C","L","M","o","e","t","h","_Sound","streaming","WebAudioStreamMedia","WebAudioMedia","urls","file","path","a","b","data","results","alias","sprite","SoundSprite","playOptions","resolve","reject","queue","pending","len","callbacks","loaded","index","Sound","s$1","ignore","FADE_TIME_CONSTANT","FADE_OUT","FADE_LEAD","OUTPUT_DELAY","COMPRESSOR_DELAY","WebAudioContext","win","ctx","compressor","gate","pausedOnBlur","pause","delay","at","state","settled","finish","handleError","c","l","f","d","u","x$1","HTMLAudioContext","SoundChannel","filtersAll","sourceOptions","legacy","autoPause","assert","exists","PLAY_ID","playOnce","v","g","render","canvas","textureSource","CanvasSource","step","amp","j","datum","sineTone","hertz","nChannels","sampleRate","fArray","time","angle","S","m","R","s","p","getAliases","asset","src","entry","soundAsset","ExtensionType","exts","LoaderParserPriority","mime","__spreadProps","_sound","library","SoundLibrary"],"mappings":";;;;;;;;mKAKA,IAAIA,EAOJ,SAASC,GAAYC,EACrB,CACI,OAAAF,EAAWE,EAEJA,CACX,CAMA,SAASC,GACT,CACI,OAAOH,CACX,OCJA,KACA,CAYI,YAAYI,EAAwBC,EACpC,CACI,KAAK,KAAKD,EAAaC,CAAM,CACjC,CAGU,KAAKD,EAAwBC,EACvC,CACI,KAAK,YAAcD,EACnB,KAAK,OAASC,GAAUD,CAC5B,CAMO,QAAQ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