Skip to content
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 equivalent to kira's Handle or oddio's Controlled in bevy_audio::Decodable #5828

Open
harudagondi opened this issue Aug 29, 2022 · 1 comment
Labels
A-Audio Sounds playback and modification C-Feature A new feature, making something new possible

Comments

@harudagondi
Copy link
Member

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

  • There should be a way to control a playing sound externally, outside of what is possible using AudioSink.
  • kira achieved this by returning a Handle in SoundData.
  • oddio achieved this by implementing Controlled for some Signal types.

What solution would you like?

  • In Decodable, add another associated type called Control (Handle is taken)
  • This Control is returned from Decodable::decoder(), alongside Decoder.
  • The Control is returned to the user when using Audio::play or other related functions.

What alternative(s) have you considered?

  • Just do not do this. lol
  • Embed Control in AudioSink.

Additional context

@harudagondi harudagondi added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Aug 29, 2022
@Weibye Weibye added A-Audio Sounds playback and modification and removed S-Needs-Triage This issue needs to be labelled labels Aug 29, 2022
harudagondi added a commit to harudagondi/bevy_fundsp that referenced this issue Nov 14, 2022
# 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`
@harudagondi harudagondi moved this to Open in Audio Nov 17, 2022
@SolarLiner
Copy link
Contributor

FWIW, rodio::Sink is already a kind of Handle, where control over the sound is done from the Sink and communicates to the audio thread to perform the requested changes. It's not a particularly good one, but I don't think there's much else to do from bevy_audio's side anyway, since with rodio it's the only way we have of controlling sounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Audio Sounds playback and modification C-Feature A new feature, making something new possible
Projects
Status: Open
Development

No branches or pull requests

3 participants