diff --git a/Cargo.lock b/Cargo.lock index 6aa7e1d..a0cd1a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -899,7 +899,7 @@ dependencies = [ "bevy_input", "bevy_math", "bevy_utils", - "raw-window-handle 0.4.3", + "raw-window-handle", "web-sys", ] @@ -917,7 +917,7 @@ dependencies = [ "bevy_utils", "bevy_window", "crossbeam-channel", - "raw-window-handle 0.4.3", + "raw-window-handle", "wasm-bindgen", "web-sys", "winit", @@ -1292,32 +1292,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "cpal" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d466b47cf0ea4100186a7c12d7d0166813dda7cf648553554c9c39c6324841b" -dependencies = [ - "alsa", - "core-foundation-sys 0.8.3", - "coreaudio-rs", - "jni", - "js-sys", - "libc", - "mach", - "ndk 0.7.0", - "ndk-context", - "nix 0.23.1", - "oboe", - "once_cell", - "parking_lot 0.12.1", - "stdweb", - "thiserror", - "wasm-bindgen", - "web-sys", - "windows", -] - [[package]] name = "crc32fast" version = "1.3.2" @@ -1940,26 +1914,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" -[[package]] -name = "hexodsp" -version = "0.2.0" -source = "git+https://github.com/WeirdConstructor/HexoDSP#be4e9232cc05b96588b156d1c9f995f7eda41ec0" -dependencies = [ - "hound", - "lazy_static", - "ringbuf", - "serde", - "serde_json", - "synfx-dsp", - "triple_buffer", -] - -[[package]] -name = "hound" -version = "3.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a164bb2ceaeff4f42542bdb847c41517c78a60f5649671b2a07312b6e117549" - [[package]] name = "ident_case" version = "1.0.1" @@ -2440,20 +2394,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "ndk" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "451422b7e4718271c8b5b3aadf5adedba43dc76312454b387e98fae0fc951aa0" -dependencies = [ - "bitflags", - "jni-sys", - "ndk-sys 0.4.0", - "num_enum", - "raw-window-handle 0.5.0", - "thiserror", -] - [[package]] name = "ndk-context" version = "0.1.1" @@ -2519,15 +2459,6 @@ dependencies = [ "jni-sys", ] -[[package]] -name = "ndk-sys" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21d83ec9c63ec5bf950200a8e508bdad6659972187b625469f58ef8c08e29046" -dependencies = [ - "jni-sys", -] - [[package]] name = "nix" version = "0.22.3" @@ -3071,15 +3002,6 @@ dependencies = [ "cty", ] -[[package]] -name = "raw-window-handle" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed7e3d950b66e19e0c372f3fa3fbbcf85b1746b571f74e0c2af6042a5c93420a" -dependencies = [ - "cty", -] - [[package]] name = "rawpointer" version = "0.2.1" @@ -3133,15 +3055,6 @@ version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1382d1f0a252c4bf97dc20d979a2fdd05b024acd7c2ed0f7595d7817666a157" -[[package]] -name = "ringbuf" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f65af18d50f789e74aaf23bbb3f65dcd22a3cb6e029b5bced149f6bd57c5c2a2" -dependencies = [ - "cache-padded", -] - [[package]] name = "robust" version = "0.2.3" @@ -3154,7 +3067,7 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0939e9f626e6c6f1989adb6226a039c855ca483053f0ee7c98b90e41cf731e" dependencies = [ - "cpal 0.13.5", + "cpal", "lewton", ] @@ -3365,14 +3278,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "synfx-dsp" -version = "0.5.3" -source = "git+https://github.com/WeirdConstructor/synfx-dsp#3334a91ee48c009707c0147434a3fc14a929c079" -dependencies = [ - "num-traits", -] - [[package]] name = "taffy" version = "0.1.0" @@ -3538,15 +3443,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "triple_buffer" -version = "5.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "803966e5a8397a70d3d8111afa1597ba8381346d7de4720e9f539471d371a1a3" -dependencies = [ - "cache-padded", -] - [[package]] name = "ttf-parser" version = "0.15.2" @@ -3787,7 +3683,7 @@ dependencies = [ "naga", "parking_lot 0.12.1", "profiling", - "raw-window-handle 0.4.3", + "raw-window-handle", "smallvec", "thiserror", "web-sys", @@ -3824,7 +3720,7 @@ dependencies = [ "parking_lot 0.12.1", "profiling", "range-alloc", - "raw-window-handle 0.4.3", + "raw-window-handle", "renderdoc-sys", "thiserror", "wasm-bindgen", @@ -3897,30 +3793,17 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b543186b344cc61c85b5aab0d2e3adf4e0f99bc076eff9aa5927bcc0b8a647" -dependencies = [ - "windows_aarch64_msvc 0.37.0", - "windows_i686_gnu 0.37.0", - "windows_i686_msvc 0.37.0", - "windows_x86_64_gnu 0.37.0", - "windows_x86_64_msvc 0.37.0", -] - [[package]] name = "windows-sys" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ - "windows_aarch64_msvc 0.36.1", - "windows_i686_gnu 0.36.1", - "windows_i686_msvc 0.36.1", - "windows_x86_64_gnu 0.36.1", - "windows_x86_64_msvc 0.36.1", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", ] [[package]] @@ -3929,60 +3812,30 @@ version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" -[[package]] -name = "windows_aarch64_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2623277cb2d1c216ba3b578c0f3cf9cdebeddb6e66b1b218bb33596ea7769c3a" - [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" -[[package]] -name = "windows_i686_gnu" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3925fd0b0b804730d44d4b6278c50f9699703ec49bcd628020f46f4ba07d9e1" - [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" -[[package]] -name = "windows_i686_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce907ac74fe331b524c1298683efbf598bb031bc84d5e274db2083696d07c57c" - [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" -[[package]] -name = "windows_x86_64_gnu" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2babfba0828f2e6b32457d5341427dcbb577ceef556273229959ac23a10af33d" - [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" -[[package]] -name = "windows_x86_64_msvc" -version = "0.37.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4dd6dc7df2d84cf7b33822ed5b86318fb1781948e9663bacd047fc9dd52259d" - [[package]] name = "winit" version = "0.26.1" @@ -4006,7 +3859,7 @@ dependencies = [ "objc", "parking_lot 0.11.2", "percent-encoding", - "raw-window-handle 0.4.3", + "raw-window-handle", "wasm-bindgen", "web-sys", "winapi", diff --git a/Cargo.toml b/Cargo.toml index 1158949..d47bc94 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,8 +18,8 @@ serde = { version = "1.0.144", features = ["derive"] } [target."cfg(not(target_arch = \"wasm32\"))".dependencies] bevy-inspector-egui = "0.12.1" bevy_mod_picking = "0.9.0" -cpal = "0.14.0" -hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP", default-features = false } +# cpal = "0.14.0" +# hexodsp = { git = "https://github.com/WeirdConstructor/HexoDSP", default-features = false } serde_json = "1.0.85" ticktock = "0.8.0" diff --git a/assets/sound/notes.flp b/assets/sound/notes.flp new file mode 100644 index 0000000..763ff4b Binary files /dev/null and b/assets/sound/notes.flp differ diff --git a/assets/sound/notes/a5.ogg b/assets/sound/notes/a5.ogg new file mode 100644 index 0000000..81bfcac Binary files /dev/null and b/assets/sound/notes/a5.ogg differ diff --git a/assets/sound/notes/cs6.ogg b/assets/sound/notes/cs6.ogg new file mode 100644 index 0000000..885b9b6 Binary files /dev/null and b/assets/sound/notes/cs6.ogg differ diff --git a/assets/sound/notes/e6.ogg b/assets/sound/notes/e6.ogg new file mode 100644 index 0000000..6bf4ce5 Binary files /dev/null and b/assets/sound/notes/e6.ogg differ diff --git a/assets/sound/reverb_notes/a5.ogg b/assets/sound/reverb_notes/a5.ogg new file mode 100644 index 0000000..ab2e6b5 Binary files /dev/null and b/assets/sound/reverb_notes/a5.ogg differ diff --git a/assets/sound/reverb_notes/cs6.ogg b/assets/sound/reverb_notes/cs6.ogg new file mode 100644 index 0000000..33428fd Binary files /dev/null and b/assets/sound/reverb_notes/cs6.ogg differ diff --git a/assets/sound/reverb_notes/e6.ogg b/assets/sound/reverb_notes/e6.ogg new file mode 100644 index 0000000..db15941 Binary files /dev/null and b/assets/sound/reverb_notes/e6.ogg differ diff --git a/assets/sound/warp_notes/a5.ogg b/assets/sound/warp_notes/a5.ogg new file mode 100644 index 0000000..8386719 Binary files /dev/null and b/assets/sound/warp_notes/a5.ogg differ diff --git a/assets/sound/warp_notes/cs6.ogg b/assets/sound/warp_notes/cs6.ogg new file mode 100644 index 0000000..74e0026 Binary files /dev/null and b/assets/sound/warp_notes/cs6.ogg differ diff --git a/assets/sound/warp_notes/e6.ogg b/assets/sound/warp_notes/e6.ogg new file mode 100644 index 0000000..63fcd02 Binary files /dev/null and b/assets/sound/warp_notes/e6.ogg differ diff --git a/src/audio.rs b/src/audio.rs index 767b309..495151b 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -1,5 +1,6 @@ // https://github.com/WeirdConstructor/HexoDSP/blob/master/examples/cpal_demo_node_api.rs +// use bevy::{prelude::*, asset::HandleId}; use crate::game::AudioMsg; use cpal::traits::{DeviceTrait, HostTrait, StreamTrait}; @@ -163,4 +164,4 @@ fn start_backend(node_exec: NodeExecutor, frontend_loop: F) { cpal::SampleFormat::I16 => run::(&device, &config.into(), node_exec, frontend_loop), cpal::SampleFormat::U16 => run::(&device, &config.into(), node_exec, frontend_loop), }; -} +} \ No newline at end of file diff --git a/src/audio_system.rs b/src/audio_system.rs new file mode 100644 index 0000000..9ddd291 --- /dev/null +++ b/src/audio_system.rs @@ -0,0 +1,49 @@ +use bevy::prelude::*; + +pub struct AudioSystemPlugin; + +impl Plugin for AudioSystemPlugin { + fn build(&self, app: &mut App) { + app + .init_resource::() + .add_startup_system(load_audio); + } +} + +#[derive(Default)] +pub struct AudioAssets { + pub notes: [Handle; 3], + pub reverb_notes: [Handle; 3], + pub warp_notes: [Handle; 3], +} + +pub fn play_audio( + audio_set: &[Handle; 3], + audio: &Res