-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for streaming DSP graphs #1
Comments
# Objective - Allow non-`Sync` Decoders - Unblocks #5422. - Unblocks harudagondi/bevy_fundsp#1 ## Solution - Remove `Sync` requirement in `Decodable::Decoder` - This aligns with kira's [`Sound`] and majority of [oddio]'s types (like [`Mixer`]). [`Sound`]: https://docs.rs/kira/latest/kira/sound/trait.Sound.html [oddio]: https://docs.rs/oddio/latest/oddio/index.html [`Mixer`]: https://docs.rs/oddio/latest/oddio/struct.Mixer.html --- ## Changelog ### Changed - `Decodable::Decoder` now no longer requires `Sync` types.
# Objective - Allow non-`Sync` Decoders - Unblocks bevyengine#5422. - Unblocks harudagondi/bevy_fundsp#1 ## Solution - Remove `Sync` requirement in `Decodable::Decoder` - This aligns with kira's [`Sound`] and majority of [oddio]'s types (like [`Mixer`]). [`Sound`]: https://docs.rs/kira/latest/kira/sound/trait.Sound.html [oddio]: https://docs.rs/oddio/latest/oddio/index.html [`Mixer`]: https://docs.rs/oddio/latest/oddio/struct.Mixer.html --- ## Changelog ### Changed - `Decodable::Decoder` now no longer requires `Sync` types.
# Objective - This is a very big refactor that allows better ergonomics, better refactorability, and better support for streaming audio. - Partially complete #1 for `bevy_audio`, - bevyengine/bevy#5819 ~needs to be merged first.~ is now merged! Now waiting for bevy 0.9. - NiklasEi/bevy_kira_audio#63 is blocking for `kira`. - Partially complete #2 for `oddio` - bevyengine/bevy#5828 needs to be resolved first - NiklasEi/bevy_kira_audio#63 is blocking for `kira` - `oddio` isn't even implemented yet for this PR - By virtue of solving #2, then #3 will be unblocked - Unblocks #4 by using `DspGraph` - Fixes #5 ## Solution - [x] Add support for - [x] `bevy_audio`, ~blocked by bevyengine/bevy#5819~ Now waiting for bevy 0.9. - [x] `bevy_kira_audio`, ~blocked by NiklasEi/bevy_kira_audio#72~ Now waiting for bevy 0.9. - [x] `bevy_oddio` - [ ] Add support for streaming audio in - [x] `bevy_audio`, ~blocked by bevyengine/bevy#5819~ - [ ] `bevy_kira_audio`, blocked by NiklasEi/bevy_kira_audio#63 - [x] `bevy_oddio` - [ ] Allow setting of parameters in - [ ] `bevy_audio`, blocked by bevyengine/bevy#5828 - [ ] `bevy_kira_audio`, blocked by NiklasEi/bevy_kira_audio#63 - [x] `bevy_oddio` ## Note for Users of this Branch If you are a user of `bevy_fundsp`, please try to test this PR! This currently only works with bevy_audio (EDIT: and bevy_oddio!), because this relies on a branch I made on bevy. --- ## Changelog Reworked the majority of the code. ## Added - A way to play streaming DSP sources. See `SourceType::Dynamic`. - You can play DSP sources using `Audio::play_dsp`. - Two iterators on streaming audio sources: `Iter` and `IterMono`. ### Changed - Adding the DSP plugin. - You must now call `DspPlugin::default()`. - The method on adding DSP sources. - No more initializing using `DspAssets`! - Just add your DSP function using `app.add_dsp_source` - Playing DSP sources require `Audio` to be mutable. (Use `ResMut`) - A lot of internals are shuffled around. ### Removed - `DspAssets` - `FnDspGraph` - `StreamingDspSource`
# Objective - Allow non-`Sync` Decoders - Unblocks bevyengine#5422. - Unblocks harudagondi/bevy_fundsp#1 ## Solution - Remove `Sync` requirement in `Decodable::Decoder` - This aligns with kira's [`Sound`] and majority of [oddio]'s types (like [`Mixer`]). [`Sound`]: https://docs.rs/kira/latest/kira/sound/trait.Sound.html [oddio]: https://docs.rs/oddio/latest/oddio/index.html [`Mixer`]: https://docs.rs/oddio/latest/oddio/struct.Mixer.html --- ## Changelog ### Changed - `Decodable::Decoder` now no longer requires `Sync` types.
Would this issue be required for graphs with dynamic levels? Eg making a graph which has dynamic intensity via Midi velocity? |
I believe the answer is yes. By the way, this issue is mostly solved except for integration with |
Solved how? I wasn't clear on how this could work with Bevy directly, and given the tracking issue is still open on Bevy's side i figured it wasn't possible. For now i'm experimenting with using an external audio thread to manage the DSP. Is there a better way? |
I made an example that stimulates a piano. Maybe check this out? |
Yea i think that would work. At first i wasn't sure, but now that i'm wrapping my head around externally threaded solutions, in theory as long as you can access the Is there a benefit in this model over the externally threaded examples in your mind? Would the performance be better in Bevy for any reason? |
The benefit is that you are not going to eat up any threads in the thread pool that bevy uses. It is better to let bevy handle the threads. Otherwise you are taking away one thread that bevy could use for parallelization. |
Currently, DSP graphs are stored in
DspSource
s, where it has a definite length. Due to howbevy_audio
andbevy_kira_audio
works, this means that there is no way on how to play sounds forever, given a FunDSP graph.Solution
StreamingDspSource
.Blocked by:
bevy_audio
: Add support for real time audio streaming bevyengine/bevy#5422bevy::utils::SyncCell
: [Merged by Bors] - RemoveSync
bound fromLocal
bevyengine/bevy#5483std::sync::Exclusive
Tracking Issue forExclusive
rust-lang/rust#98407Sync
requirement inDecodable::Decoder
bevyengine/bevy#5819bevy_kira_audio
Support playing sounds that implement kira'sSoundData
NiklasEi/bevy_kira_audio#63bevy_oddio
.The text was updated successfully, but these errors were encountered: