bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
33.56k stars 3.26k forks source link

Make `bevy_audio` agnostic #5829

Open harudagondi opened 1 year ago

harudagondi commented 1 year ago

What problem does this solve or what need does it fill?

What solution would you like?

I don't really know what the exact implementation would look like, but I do know it probably would have a bunch of trait magic and generics, sooo

What alternative(s) have you considered?

Additional context

SolarLiner commented 3 months ago

I personally am against this. In a way, kira/rodio/knyst/etc., are all abstraction crates that aim at providing a unified interface for audio processing (with games in mind for most of them). However, almost all of them attempt to be "batteries included" by each providing a different set of effects and features.

There's two layers of abstraction at play here.
The first one is lower-level, and the responsibilty is to provide a framework for taking sources (files, audio input, procedural sound, etc.), processing them through effects, and outputing the result through sinks (device outputs, a file, a mock output, etc.). It should be general enough to support per-source effects, per-group (or per-track, depending on the vocabulary) effects, and per-sink effects (or master effects).
The second one provides useful DSP algorithms to perform certain tasks (providing spatial audio, simulating room reverb, attenuation and propagation delays, etc.), and can theoretically be inserted in any effect slot of any lower-level abstraction as described above.

The reason why there are so many crates, and why they are all providing both levels of abstractions, is because there are a lot of decisions to be taken at every level, leading to different compromises and different designs. There's also a lot of innovation due to Rust being a relatively young language and so there are multiple proposals for how audio programming could look in Rust.

To me, the goal of bevy_audio is to be general enough to be able to use crates that provide the latter level of abstraction (ie. knyst, oddio, fundsp, even kira in some aspects with its MockBackend), but not the former, because designing such a system would be much more complex for little gain, as these crates have been designed as a holistic solution, and therefore don't try to play nice with others.

If you want to run custom audio effects, or sound generation, then bevy_audio should be able to support that, either by having you writing the code directly, or using oddio or fundsp, and have the internals of the routing taken care of for you. This is how other game engines work.

tychedelia commented 2 months ago

https://github.com/bevyengine/bevy/issues/13226 would directly contravene this. Personally, I think audio is annoying and low level enough that it makes sense to just depend on a single implementation, for the same reason that we depend on winit rather than building abstractions over winit.