Description
What problem does this solve or what need does it fill?
During the development of my plugin (bevy_fundsp
, also shameless self promotion lol), I found that bevy_audio (and bevy_kira_audio
, for that matter) is rather limited.
To play sounds, one must create an AudioSource
, which stores the bytes of the sound data, then play it in a system using Res<Audio>
.
This isn't feasible when using DSP (digital signal processing) libraries such as fundsp
. DSP graphs can be played forever (see example here), so it would be impossible to convert these into AudioSource
s. A workaround for this is to pass a definite length and convert the graph into wave data bytes, which is then converted to an AudioSource
.
This is very hacky, and it does not exploit the full capabilities of DSP libraries, especially fundsp
.
What solution would you like?
I don't know what exact implementation would actually look like, but I would like:
- A
StreamingAudioSource
that holds an iterator whose items is an array of floats (f32 ideally) where its length is the number of channels (usually two for left/right channels). StreamingAudioSource
can only be played (by continuing to iterate), paused (by stopping the iteration), or possibly reset (this is possible withfundsp
specifically).
Using this solution would probably need access to cpal
directly.
What alternative(s) have you considered?
Bypass bevy_audio
and directly use cpal
. This is bad, because audio programming is very hard, and it is better for Bevy to provide its own solution.
Metadata
Assignees
Type
Projects
Status
Open