bevyengine / bevyengine/bevy

Add Spatial/Positional Audio in Rust

Open
#5,832 5 comments 1 reaction 0 assignees View on GitHub
A-Audio C-Feature
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

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

- Other game engines have the capability for positional audio sources:
- [Godot](https://docs.godotengine.org/en/stable/tutorials/audio/audio_streams.html)
- [Unreal Engine](https://docs.unrealengine.com/4.27/en-US/WorkingWithAudio/DistanceModelAttenuation/)
- [Unity](https://docs.unity3d.com/Manual/AudioOverview.html)
- Bevy currently do not have support for spatial audio.

## What solution would you like?

Create two `Component`s:
- `AudioEmitter`: Emits sound from the current position of the entity.
- `AudioListener`: Listens for sounds from `AudioEmitter`. Has its own (potentially same) position.

`AudioEmitter`'s API should be similar to `bevy_audio::Audio`, while `AudioListener` works similar to `AudioOutput` internally, or computes the resulting sound wave and send it to the mixer.

These components should probably have its own thread, as the sample rate (the number of audio samples per second) is usually around 44100 Hz, so systems dealing with audio components should be able to run for at least 44100 times a second to avoid underruns.

## What alternative(s) have you considered?

- None so far.

## Additional context

See the discussion in the bevy discord in the #audio-dev channel for more info.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.