Audio effects
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
Currently, `bevy_audio` doesn't support audio effects, which could be useful for creating a better experience for players.
## What solution would you like?
Extending `bevy_audio` crate with an `Effects` struct that contains settings for audio effects. These effects could then be applied in [`played_queued_audio_system`](https://github.com/bevyengine/bevy/blob/main/crates/bevy_audio/src/audio_output.rs#L101-L237). `rodio` (which is used by `bevy_audio`) already exposes effects such as: [fade in](https://github.com/RustAudio/rodio/blob/4973f330e07be8480c35f145c9da84dc60e2184c/src/source/fadein.rs), [high pass filter](https://github.com/RustAudio/rodio/blob/4973f330e07be8480c35f145c9da84dc60e2184c/src/source/blt.rs#L16-L21), [low pass filter](https://github.com/RustAudio/rodio/blob/4973f330e07be8480c35f145c9da84dc60e2184c/src/source/blt.rs#L9-L14), [amplify](https://github.com/RustAudio/rodio/blob/4973f330e07be8480c35f145c9da84dc60e2184c/src/source/amplify.rs), [delay](https://github.com/RustAudio/rodio/blob/4973f330e07be8480c35f145c9da84dc60e2184c/src/source/delay.rs), [reverb](https://github.com/RustAudio/rodio/blob/4973f330e07be8480c35f145c9da84dc60e2184c/src/source/mod.rs#L290-L296).
Example of how `Effects` struct could look like:
```rust
pub struct Effects {
fade_in: Option,
high_pass_filter: Option,
low_pass_filter: Option,
amplify: Option,
delay: Option,
reverb: Option<(Duration, f32)>,
}
```
This struct could be added to [`PlaybackSettings`](https://github.com/bevyengine/bevy/blob/main/crates/bevy_audio/src/audio.rs#L78-L96) struct:
```rust
pub struct PlaybackSettings {
...
pub effects: Effects,
}
```
## What alternative(s) have you considered?
Implementing effects as enum, but that wouldn't allow chaining effects.
## Additional context
When an effect is applied, rodio wraps it in a struct. For example, if we use the `fade_in()` effect on a `Source`, it returns `FadeIn`. This makes it harder for implementation (or at least to my limited knowledge of rust).
Contributor guide
Research direction
Start by reading crates/bevy_audio/src/audio.rs, especially PlaybackSettings, and the played_queued_audio_system entry point in crates/bevy_audio/src/audio_output.rs. Review the rodio effect links in the issue and determine how chained effects can be represented. Done means bevy_audio exposes the requested effect settings and applies them during queued audio playback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100