Skip to content

Commit 9f11a7e

Browse files
cartharudagondi
andcommitted
Add sections for spatial and custom audio sources (#548)
Draft of the "Spatial Audio" and "Custom Audio Sources" sections. [Rendered.](https://github.com/harudagondi/bevy-website/blob/audio-sections/content/news/2023-03-04-bevy-0.10/index.md#spatial-audio) Co-authored-by: harudagondi <[email protected]>
1 parent afd9b83 commit 9f11a7e

File tree

1 file changed

+41
-0
lines changed
  • content/news/2023-03-04-bevy-0.10

1 file changed

+41
-0
lines changed

content/news/2023-03-04-bevy-0.10/index.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,47 @@ Since our last release a few months ago we've added a _ton_ of new features, bug
2323

2424
Description here.
2525

26+
## Spatial Audio
27+
28+
<div class="release-feature-authors">authors: @mockersf, @DGriffin91, @harudagondi, @alice-i-cecile</div>
29+
30+
The library Bevy uses for audio, [`rodio`], contains support for spatial audio. In this version, we now support spatial audio (with certain caveats, like no HRTF and no first class support for `Emitter` and `Listener` components).
31+
32+
Interestingly, during the development of this specific feature, `@harudagondi` found a [bug][reverse-channels-bug] where the audio channels reverse when running the app in either debug or release mode. This turns out to be a `rodio` issue, and this also affects previous versions of Bevy. Thanks to `@dis-da-moe`, the bug has been [fixed upstream][rodio-pr]. See the linked PR for interesting details about audio programming quirks and performance issues.
33+
34+
You can now have spatial audio in your game! Clone the `bevy` repository and invoke `cargo run --example spatial_audio_3d --release` in the command line for a showcase of 3D spatial audio in Bevy.
35+
36+
[`rodio`]: https://crates.io/crates/rodio
37+
[reverse-channels-bug]: https://github.com/RustAudio/rodio/issues/444
38+
[rodio-pr]: https://github.com/RustAudio/rodio/pull/455
39+
40+
## Custom Audio Sources
41+
42+
<div class="release-feature-authors">authors: @dis-da-moe</div>
43+
44+
Bevy supports custom audio sources through the [`Decodable`] trait, but the way to register to the bevy app is very boilerplatey and sparsely documented. In **Bevy 0.10**, a new extension trait for `App` is added and the documentation for [`Decodable`] has vastly improved.
45+
46+
As such, instead of doing this:
47+
48+
```rust
49+
struct MyCustomAudioSource { /* ... */ }
50+
51+
app.add_asset::<MyCustomAudioSource>()
52+
.init_resource::<Audio<MyCustomAudioSource>>()
53+
.init_resource::<AudioOutput<MyCustomAudioSource>>()
54+
.add_system(play_queued_audio_system::<MyCustomAudioSource>.in_base_set(CoreSet::PostUpdate))
55+
```
56+
57+
You only have to do this:
58+
59+
```rust
60+
app.add_audio_source::<MyCustomAudioSource>()
61+
```
62+
63+
Much cleaner!
64+
65+
[`Decodable`]: https://docs.rs/bevy_audio/latest/bevy_audio/trait.Decodable.html
66+
2667
## `Ref<T>` Queries
2768

2869
<div class="release-feature-authors">authors: @Guvante, @JoJoJet</div>

0 commit comments

Comments
 (0)