sound icon indicating copy to clipboard operation
sound copied to clipboard

Implementing Custom Filters

Open BlindElephants opened this issue 5 years ago • 5 comments

Wondering if there are any hints or documentation about implementing additional filters?

Thanks,

BlindElephants avatar Oct 01 '20 17:10 BlindElephants

You'll want this: http://pixijs.io/pixi-sound/docs/PIXI.sound.filters.Filter.html

You pass in an AudioNode (or a source and destination if you have a bigger chain). That's it. There are examples in src/filters folder (e.g., MonoFilter)

To get access to the WebAudio Context (in order to create AudioNodes), you'd get that from sound.context.audioContext.

Hope that helps. If you come up with any cool filters, would gladly add them to the project.

bigtimebuddy avatar Oct 01 '20 19:10 bigtimebuddy

Thank you!

Followup question,

sound is no longer appearing in my resources for each loaded item. And it appears that the loadType and type of each loaded resource has changed. Instead, what is handed back is an <audio> element.

I'm assuming this is because I've loaded the library incorrectly, or perhaps prepped it incorrectly after forking pixi-sound and adding my own Filter class definitions. Any advice on this?

BlindElephants avatar Oct 01 '20 22:10 BlindElephants

Please provide some more context about the issue you're having or make an example/repo that reproduces. I'm not sure what you're doing. Here's an simple example using Webpack: https://github.com/bigtimebuddy/pixi-sound-webpack-example/

bigtimebuddy avatar Oct 01 '20 23:10 bigtimebuddy

If your project is built so that pixi-sound has its own copy of the @pixi/loaders dependency instead of sharing the one from pixi.js that you are loading with (if you linked in your local fork of pixi-sound, for example), you could see this problem - pixi-sound registers loader middleware on its version of the loader, but the loader you are actually initiating is a separate version that doesn't know about the sound middleware. The resource-loader library that the loader extends will, in the absence of middleware, load .wav, .ogg, and .mp3 files as <audio> elements.

andrewstart avatar Oct 02 '20 00:10 andrewstart

thank you @andrewstart, that helps greatly.

@bigtimebuddy , just realized you may have been suggestion creating a custom audio filter by creating it as a JS class or Object that can be implemented through the pixi-sound Filters interface. This would not require any extension of the pixi-sound library using TypeScript. Am I understanding correctly?

Thank you both for your advice.

BlindElephants avatar Oct 02 '20 01:10 BlindElephants