From 2acc6b0e22898c7cb1ac77fbec4f1282a6e34306 Mon Sep 17 00:00:00 2001 From: Niklas Eicker Date: Sat, 4 Nov 2023 20:41:05 +0100 Subject: [PATCH 1/2] Update to bevy main --- CHANGELOG.md | 2 ++ Cargo.toml | 11 ++++++-- README.md | 5 ++-- examples/spacial.rs | 2 +- examples/stress_test.rs | 7 +++-- src/audio.rs | 9 ++++-- src/audio_output.rs | 39 ++++++++++++++------------ src/channel/dynamic.rs | 52 +++++++++++++++++++++-------------- src/channel/typed.rs | 39 ++++++++++++++++---------- src/instance.rs | 5 ++-- src/lib.rs | 9 +++--- src/source/flac_loader.rs | 35 +++++++++++++++++------ src/source/mod.rs | 6 ++-- src/source/mp3_loader.rs | 35 +++++++++++++++++------ src/source/ogg_loader.rs | 35 +++++++++++++++++------ src/source/settings_loader.rs | 45 ++++++++++++++++++++++++------ src/source/wav_loader.rs | 36 +++++++++++++++++------- 17 files changed, 251 insertions(+), 121 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3d4bef..fe3c25e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Changelog +- Update to Bevy `0.12` + ## v0.17.0 - Multiply instance volume with channel volume ([#103](https://github.com/NiklasEi/bevy_kira_audio/issues/103)) - Allow playing a paused sound using `.play(...).paused()` ([#105](https://github.com/NiklasEi/bevy_kira_audio/issues/105)) diff --git a/Cargo.toml b/Cargo.toml index 08f6f4e..49f7abc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,8 +22,9 @@ wav = ["kira/wav"] settings_loader = ["dep:ron", "dep:serde", "kira/serde"] [dependencies] -bevy = { version = "0.11", default-features = false, features = ["bevy_asset"] } +bevy = { git = "https://github.com/bevyengine/bevy", default-features = false, features = ["bevy_asset"] } anyhow = "1.0" +uuid = { version = "1", features = ["fast-rng"] } kira = { version = "0.8", default-features = false, features = ["cpal"] } ron = { version = "0.8", optional = true } serde = { version = "1.0", features = ["derive"], optional = true } @@ -31,7 +32,7 @@ parking_lot = "0.12" thiserror = "1.0" [dev-dependencies.bevy] -version = "0.11" +git = "https://github.com/bevyengine/bevy" default-features = false features = [ "bevy_asset", @@ -44,7 +45,11 @@ features = [ "bevy_sprite", "bevy_gltf", "bevy_scene", - "bevy_pbr","tonemapping_luts", "ktx2" , "zstd" + "bevy_pbr", + "tonemapping_luts", + "ktx2", + "zstd", + "multi-threaded" ] [[example]] diff --git a/README.md b/README.md index 8cf5e2f..af6a8c5 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Sound can be played in channels. Each channel has controls to pause or stop play ## Usage -*Note: the Bevy feature `bevy_audio` is enabled by default and not compatible with this plugin. Make sure to not have the `bevy_audio` feature enabled if you want to use `bevy_kira_audio`. The same goes for Bevy's `vorbis` feature. See [Bevys' Cargo file](https://github.com/bevyengine/bevy/blob/v0.9.0/Cargo.toml#L27-L40) for a list of all default features of version `0.9` and list them manually in your Cargo file excluding the ones you do not want. Make sure to set `default-features` to `false` for the Bevy dependency. You can take a look at [bevy_game_template's cargo file as an example](https://github.com/NiklasEi/bevy_game_template/blob/main/Cargo.toml).* +*Note: the Bevy feature `bevy_audio` is enabled by default and not compatible with this plugin. Make sure to not have the `bevy_audio` feature enabled if you want to use `bevy_kira_audio`. The same goes for Bevy's `vorbis` feature. See [Bevys' Cargo file](https://github.com/bevyengine/bevy/blob/v0.12.0/Cargo.toml#L33-L57) for a list of all default features of version `0.12` and list them manually in your Cargo file excluding the ones you do not want. Make sure to set `default-features` to `false` for the Bevy dependency. You can take a look at [bevy_game_template's cargo file as an example](https://github.com/NiklasEi/bevy_game_template/blob/main/Cargo.toml).* To play audio, you usually want to load audio files as assets. This requires `AssetLoaders`. `bevy_kira_audio` comes with loaders for most common audio formats. You can enable them with the features `ogg` (enabled by default), `mp3`, `wav`, or `flac`. The following example assumes that the feature `ogg` is enabled. @@ -90,6 +90,7 @@ The main branch is compatible with the latest Bevy release. Compatibility of `bevy_kira_audio` versions: | `bevy_kira_audio` | `bevy` | | :-- | :-- | +| `0.18` | `0.12` | | `0.16` - `0.17` | `0.11` | | `0.15` | `0.10` | | `0.13` - `0.14` | `0.9` | @@ -98,7 +99,7 @@ Compatibility of `bevy_kira_audio` versions: | `0.8` | `0.6` | | `0.4` - `0.7` | `0.5` | | `0.3` | `0.4` | -| `main` | `0.10` | +| `main` | `0.12` | | `bevy_main` | `main` | ## License diff --git a/examples/spacial.rs b/examples/spacial.rs index 4533985..dccc986 100644 --- a/examples/spacial.rs +++ b/examples/spacial.rs @@ -212,7 +212,7 @@ fn player_look( if let Ok(window) = primary_window.get_single() { let delta_state = state.as_mut(); for mut transform in query.iter_mut() { - for ev in delta_state.reader_motion.iter(&motion) { + for ev in delta_state.reader_motion.read(&motion) { match window.cursor.grab_mode { CursorGrabMode::None => (), _ => { diff --git a/examples/stress_test.rs b/examples/stress_test.rs index 8451130..7be1848 100644 --- a/examples/stress_test.rs +++ b/examples/stress_test.rs @@ -43,7 +43,7 @@ fn check( mut commands: Commands, ) { if let Some(handle) = handle { - if asset_server.get_load_state(handle.0.id()) == LoadState::Loaded { + if asset_server.get_load_state(handle.0.id()) == Some(LoadState::Loaded) { commands.insert_resource(AudioHandle(handle.0.clone())); commands.remove_resource::(); } @@ -52,8 +52,9 @@ fn check( fn play(handle: Option>, audio: Res