{"version":3,"file":"Filter.mjs","sources":["../../src/filters/Filter.ts"],"sourcesContent":["/**\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"],"names":[],"mappings":"AAsBA,MAAM,MACN,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYI,WAAA,CAAY,aAAwB,MACpC,EAAA;AACI,IAAK,IAAA,CAAA,IAAA,CAAK,aAAa,MAAM,CAAA,CAAA;AAAA,GACjC;AAAA;AAAA,EAGU,IAAA,CAAK,aAAwB,MACvC,EAAA;AACI,IAAA,IAAA,CAAK,WAAc,GAAA,WAAA,CAAA;AACnB,IAAA,IAAA,CAAK,SAAS,MAAU,IAAA,WAAA,CAAA;AAAA,GAC5B;AAAA;AAAA;AAAA;AAAA;AAAA,EAMO,QAAQ,WACf,EAAA;AACI,IAAK,IAAA,CAAA,MAAA,EAAQ,QAAQ,WAAW,CAAA,CAAA;AAAA,GACpC;AAAA;AAAA,EAGO,UACP,GAAA;AACI,IAAA,IAAA,CAAK,QAAQ,UAAW,EAAA,CAAA;AAAA,GAC5B;AAAA;AAAA,EAGO,OACP,GAAA;AACI,IAAA,IAAA,CAAK,UAAW,EAAA,CAAA;AAChB,IAAA,IAAA,CAAK,WAAc,GAAA,IAAA,CAAA;AACnB,IAAA,IAAA,CAAK,MAAS,GAAA,IAAA,CAAA;AAAA,GAClB;AACJ;;;;"}