tentone / nunuStudio

Web powered cross-platform 3D, WebXR game engine.
https://nunustudio.org
MIT License
2.13k stars 319 forks source link

Add Reverb option for positional audio #122

Open mienaikoe opened 7 years ago

mienaikoe commented 7 years ago

In game engines, filters and convolvers are used for environment-responsive sound. This is used to make sound feel more immersive (for instance, muffling speech behind a wall vs being in the same room with the speaker). To implement this, a developer would need to be able to set rules on the filter or convolver based on the geometry of the scene. Examples of this:

1) When position of camera is in some area mapped by a box (i.e. a room), set a low pass filter cutoff frequency on an audio emitter in the same box high. When the camera leaves the room, set the frequency low.

2) Add a Convolver node in series with the Panner in PositionalAudio and have them both connect to the common output. The distance may cut off the volume of a raw sound quickly, but the falloff for the Convolver should be much more subtle, giving a much more immersive sound. This way you can model environments anywhere from small rooms to giant subway tunnels along with the position of the source of sound.

tentone commented 7 years ago

Hi

I want to add some audio effects down the road but i want to include them as "nodes" and have gui to add and connect these nodes.

This should be easy to implement with web audio since the API already uses this "node" structure.

Regarding zones (rooms), the zone change should already be easy to implement using the physics engine.

Right now im trying to focus all my attention on the animation component of the editor. But if want to feel free to create a PR with some of these effects. There are still some problems with audio in the engine, i have to manage better when to dispose my buffers to avoid getting error messages.

Thanks a lot for the suggestion i really appreciate it.