Skip to content

Commit

Permalink
Merge pull request #122 from mgi388/rename-spacial-to-spatial
Browse files Browse the repository at this point in the history
Rename spacial to spatial
  • Loading branch information
NiklasEi authored Apr 30, 2024
2 parents 763cd92 + f5483bb commit 02dc1f4
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
12 changes: 6 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@

## v0.16.0
- Update to Bevy `0.11`
- Spacial audio improvements ([#94](https://github.com/NiklasEi/bevy_kira_audio/pull/94))
- Spatial audio improvements ([#94](https://github.com/NiklasEi/bevy_kira_audio/pull/94))
- Check if receiver exists before updating
- Cleanup instances from spacial audio
- Cleanup instances from spatial audio
- Offer iterator over dynamic channel keys and values ([#69](https://github.com/NiklasEi/bevy_kira_audio/issues/69))
- Allow resuming while pausing or stopping ([#98](https://github.com/NiklasEi/bevy_kira_audio/pull/98))

## v0.15.0
- Update to Bevy `0.10`
- Fix: stop spacial audio from getting louder again at large distances ([#88](https://github.com/NiklasEi/bevy_kira_audio/issues/88))
- Fix: stop spatial audio from getting louder again at large distances ([#88](https://github.com/NiklasEi/bevy_kira_audio/issues/88))

## v0.14.0
- Limited support for spacial audio
- Add `Emitter` and `Receiver` components to spacial entities
- Limited support for spatial audio
- Add `Emitter` and `Receiver` components to spatial entities
- Audio volume and panning will be automatically changed
- New example [`spacial.rs`](examples/spacial.rs)
- New example [`spatial.rs`](examples/spatial.rs)
- Support for setting volume in Decibels ([#81](https://github.com/NiklasEi/bevy_kira_audio/issues/81))
- Reexport some used Kira types ([#73](https://github.com/NiklasEi/bevy_kira_audio/issues/73))

Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ features = [
"tonemapping_luts",
"ktx2",
"zstd",
"multi-threaded"
"multi-threaded",
]

[[example]]
Expand Down Expand Up @@ -98,6 +98,6 @@ path = "examples/channel_control.rs"
required-features = ["ogg"]

[[example]]
name = "spacial"
path = "examples/spacial.rs"
name = "spatial"
path = "examples/spatial.rs"
required-features = ["ogg"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ More settings are available. See the [`settings_loader` example](examples/settin

You can either control a whole audio channel and all instances playing in it ([`channel_control` example](examples/channel_control.rs)), or a single audio instance ([`instance_control` example](examples/instance_control.rs)). Both ways offer audio transitions with Tweens supporting multiple easings.

### Spacial audio
### Spatial audio

There is limited spacial audio support. Currently, only the volume of audio and it's panning can be automatically changed based on emitter and receiver positions. Take a look at the [`spacial` example](examples/spacial.rs) for some code.
There is limited spatial audio support. Currently, only the volume of audio and it's panning can be automatically changed based on emitter and receiver positions. Take a look at the [`spatial` example](examples/spatial.rs) for some code.

## Compatible Bevy versions

Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ These examples are simple Bevy Apps illustrating the capabilities of `bevy_kira_
| [`multiple_channels.rs`](/examples/multiple_channels.rs) | GUI application with full control over tree different audio channels |
| [`settings.rs`](/examples/settings.rs) | Demonstrate settings supported when playing a sound |
| [`settings_loader.rs`](/examples/settings_loader.rs) | Loading a sound with applied settings |
| [`spacial.rs`](/examples/spacial.rs) | Demonstration of the limited support for spacial audio |
| [`spatial.rs`](/examples/spatial.rs) | Demonstration of the limited support for spatial audio |
| [`status.rs`](/examples/status.rs) | Continuously get the playback state of a sound |
| [`stress_test.rs`](/examples/stress_test.rs) | Example app playing a high number of sounds every frame |

Expand Down
2 changes: 1 addition & 1 deletion examples/spacial.rs → examples/spatial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy_kira_audio::prelude::*;

fn main() {
App::new()
.insert_resource(SpacialAudio { max_distance: 25. })
.insert_resource(SpatialAudio { max_distance: 25. })
.add_plugins((DefaultPlugins, AudioPlugin, CameraPlugin))
.add_systems(Startup, setup)
.run()
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ mod backend_settings;
mod channel;
mod instance;
mod source;
mod spacial;
mod spatial;

pub use audio::{
AudioApp, AudioEasing, AudioTween, FadeIn, FadeOut, PlayAudioCommand, PlaybackState,
Expand All @@ -51,7 +51,7 @@ use bevy::app::{PostUpdate, PreUpdate};
use bevy::asset::AssetApp;
pub use channel::AudioControl;
pub use source::AudioSource;
use spacial::cleanup_stopped_spacial_instances;
use spatial::cleanup_stopped_spatial_instances;

/// Most commonly used types
pub mod prelude {
Expand All @@ -73,7 +73,7 @@ pub mod prelude {
#[doc(hidden)]
pub use crate::source::AudioSource;
#[doc(hidden)]
pub use crate::spacial::{AudioEmitter, AudioReceiver, SpacialAudio};
pub use crate::spatial::{AudioEmitter, AudioReceiver, SpatialAudio};
#[doc(hidden)]
pub use crate::{Audio, AudioPlugin, MainTrack};
pub use kira::{
Expand All @@ -98,7 +98,7 @@ use crate::source::ogg_loader::OggLoader;
use crate::source::settings_loader::SettingsLoader;
#[cfg(feature = "wav")]
use crate::source::wav_loader::WavLoader;
use crate::spacial::{run_spacial_audio, SpacialAudio};
use crate::spatial::{run_spatial_audio, SpatialAudio};
use bevy::prelude::{resource_exists, App, IntoSystemConfigs, Plugin, Resource, SystemSet};
pub use channel::dynamic::DynamicAudioChannel;
pub use channel::dynamic::DynamicAudioChannels;
Expand Down Expand Up @@ -167,13 +167,13 @@ impl Plugin for AudioPlugin {
.add_audio_channel::<MainTrack>()
.add_systems(
PreUpdate,
cleanup_stopped_spacial_instances
cleanup_stopped_spatial_instances
.in_set(AudioSystemSet::InstanceCleanup)
.run_if(resource_exists::<SpacialAudio>),
.run_if(resource_exists::<SpatialAudio>),
)
.add_systems(
PostUpdate,
run_spacial_audio.run_if(resource_exists::<SpacialAudio>),
run_spatial_audio.run_if(resource_exists::<SpatialAudio>),
);
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/spacial.rs → src/spatial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ pub struct AudioEmitter {
#[derive(Component)]
pub struct AudioReceiver;

/// Configuration resource for spacial audio
/// Configuration resource for spatial audio
///
/// If this resource is not added to the ECS, spacial audio is not applied.
/// If this resource is not added to the ECS, spatial audio is not applied.
#[derive(Resource)]
pub struct SpacialAudio {
pub struct SpatialAudio {
/// The volume will change from `1` at distance `0` to `0` at distance `max_distance`
pub max_distance: f32,
}

impl SpacialAudio {
impl SpatialAudio {
pub(crate) fn update(
&self,
receiver_transform: &GlobalTransform,
Expand All @@ -58,18 +58,18 @@ impl SpacialAudio {
}
}

pub(crate) fn run_spacial_audio(
spacial_audio: Res<SpacialAudio>,
pub(crate) fn run_spatial_audio(
spatial_audio: Res<SpatialAudio>,
receiver: Query<&GlobalTransform, With<AudioReceiver>>,
emitters: Query<(&GlobalTransform, &AudioEmitter)>,
mut audio_instances: ResMut<Assets<AudioInstance>>,
) {
if let Ok(receiver_transform) = receiver.get_single() {
spacial_audio.update(receiver_transform, &emitters, &mut audio_instances);
spatial_audio.update(receiver_transform, &emitters, &mut audio_instances);
}
}

pub(crate) fn cleanup_stopped_spacial_instances(
pub(crate) fn cleanup_stopped_spatial_instances(
mut emitters: Query<&mut AudioEmitter>,
instances: ResMut<Assets<AudioInstance>>,
) {
Expand Down

0 comments on commit 02dc1f4

Please sign in to comment.