Compare commits
No commits in common. "main" and "v0.8.0" have entirely different histories.
|
@ -6,7 +6,11 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
strategy:
|
||||||
|
matrix:
|
||||||
|
# os: [windows-latest, ubuntu-latest, macos-latest]
|
||||||
|
os: [ubuntu-latest]
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions/cache@v4
|
- uses: actions/cache@v4
|
||||||
|
@ -22,7 +26,12 @@ jobs:
|
||||||
~/.cargo/git/db/
|
~/.cargo/git/db/
|
||||||
target/
|
target/
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
- name: Install Nix
|
- uses: dtolnay/rust-toolchain@master
|
||||||
uses: https://github.com/cachix/install-nix-action@v31
|
with:
|
||||||
- name: Test
|
toolchain: stable
|
||||||
run: nix develop --command pre-commit run -a
|
components: rustfmt, clippy
|
||||||
|
- name: install Linux build dependencies
|
||||||
|
run: sudo apt-get update; sudo apt-get install -y --no-install-recommends libasound2-dev libudev-dev libwayland-dev libclang-dev cmake
|
||||||
|
if: runner.os == 'linux'
|
||||||
|
- uses: actions/setup-python@v3
|
||||||
|
- uses: pre-commit/action@v3.0.1
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
/target
|
/target
|
||||||
*.dll
|
*.dll
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
.direnv
|
|
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -2,25 +2,6 @@
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
## Version 0.10.0 - 2025-05-16
|
|
||||||
|
|
||||||
### Miscellaneous Tasks
|
|
||||||
|
|
||||||
- Add Nix-based build and CI configuration.
|
|
||||||
- Update to Bevy 0.16.
|
|
||||||
|
|
||||||
## Version 0.9.1 - 2025-01-07
|
|
||||||
|
|
||||||
### Miscellaneous Tasks
|
|
||||||
|
|
||||||
- Don't set position if values are NaN.
|
|
||||||
|
|
||||||
## Version 0.9.0 - 2024-12-06
|
|
||||||
|
|
||||||
### Miscellaneous Tasks
|
|
||||||
|
|
||||||
- Upgrade to Bevy 0.15.
|
|
||||||
|
|
||||||
## Version 0.8.0 - 2024-12-02
|
## Version 0.8.0 - 2024-12-02
|
||||||
|
|
||||||
### Bug Fixes
|
### Bug Fixes
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bevy_synthizer"
|
name = "bevy_synthizer"
|
||||||
version = "0.10.0"
|
version = "0.8.0"
|
||||||
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
|
||||||
description = "A Bevy plugin for Synthizer, a library for 3D audio and synthesis with a focus on games and VR applications"
|
description = "A Bevy plugin for Synthizer, a library for 3D audio and synthesis with a focus on games and VR applications"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
@ -10,12 +10,12 @@ repository = "https://labs.lightsout.games/projects/bevy_synthizer"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.16", default-features = false, features = ["bevy_asset"] }
|
bevy = { version = "0.14", default-features = false, features = ["bevy_asset"] }
|
||||||
synthizer = "0.5.6"
|
synthizer = "0.5.6"
|
||||||
thiserror = "2"
|
thiserror = "1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bevy = { version = "0.16", default-features = true }
|
bevy = { version = "0.14", default-features = true }
|
||||||
|
|
||||||
[package.metadata.release]
|
[package.metadata.release]
|
||||||
publish = false
|
publish = false
|
||||||
|
|
|
@ -31,10 +31,14 @@ fn load_and_create(
|
||||||
if !listeners.is_empty() {
|
if !listeners.is_empty() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
commands.spawn((Transform::default(), Listener, RotationTimer::default()));
|
commands.spawn((
|
||||||
|
TransformBundle::default(),
|
||||||
|
Listener,
|
||||||
|
RotationTimer::default(),
|
||||||
|
));
|
||||||
let handle = asset_server.load("footstep.wav");
|
let handle = asset_server.load("footstep.wav");
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Transform::from_translation(Vec3::new(10., 0., 0.)),
|
TransformBundle::from(Transform::from_translation(Vec3::new(10., 0., 0.))),
|
||||||
Source::default(),
|
Source::default(),
|
||||||
Sound {
|
Sound {
|
||||||
audio: handle.into(),
|
audio: handle.into(),
|
||||||
|
|
|
@ -13,12 +13,16 @@ impl Default for RotationTimer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup(mut commands: Commands, context: Res<Context>) {
|
fn setup(mut commands: Commands, context: Res<Context>) {
|
||||||
commands.spawn((Transform::default(), Listener, RotationTimer::default()));
|
commands.spawn((
|
||||||
|
TransformBundle::default(),
|
||||||
|
Listener,
|
||||||
|
RotationTimer::default(),
|
||||||
|
));
|
||||||
let generator: syz::Generator = syz::FastSineBankGenerator::new_sine(&context, 440.)
|
let generator: syz::Generator = syz::FastSineBankGenerator::new_sine(&context, 440.)
|
||||||
.expect("Failed to create generator")
|
.expect("Failed to create generator")
|
||||||
.into();
|
.into();
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
Transform::from_translation(Vec3::new(10., 0., 0.)),
|
TransformBundle::from(Transform::from_translation(Vec3::new(10., 0., 0.))),
|
||||||
Source::default(),
|
Source::default(),
|
||||||
Sound {
|
Sound {
|
||||||
audio: generator.into(),
|
audio: generator.into(),
|
||||||
|
|
61
flake.lock
61
flake.lock
|
@ -1,61 +0,0 @@
|
||||||
{
|
|
||||||
"nodes": {
|
|
||||||
"nixpkgs": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1747312588,
|
|
||||||
"narHash": "sha256-MmJvj6mlWzeRwKGLcwmZpKaOPZ5nJb/6al5CXqJsgjo=",
|
|
||||||
"owner": "NixOS",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"rev": "b1bebd0fe266bbd1820019612ead889e96a8fa2d",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "NixOS",
|
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": {
|
|
||||||
"inputs": {
|
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"utils": "utils"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"systems": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1681028828,
|
|
||||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "nix-systems",
|
|
||||||
"repo": "default",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"utils": {
|
|
||||||
"inputs": {
|
|
||||||
"systems": "systems"
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1731533236,
|
|
||||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"root": "root",
|
|
||||||
"version": 7
|
|
||||||
}
|
|
54
flake.nix
54
flake.nix
|
@ -1,54 +0,0 @@
|
||||||
{
|
|
||||||
inputs = {
|
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
||||||
utils.url = "github:numtide/flake-utils";
|
|
||||||
};
|
|
||||||
|
|
||||||
outputs =
|
|
||||||
{
|
|
||||||
self,
|
|
||||||
nixpkgs,
|
|
||||||
utils,
|
|
||||||
}:
|
|
||||||
utils.lib.eachDefaultSystem (
|
|
||||||
system:
|
|
||||||
let
|
|
||||||
pkgs = import nixpkgs { inherit system; };
|
|
||||||
in
|
|
||||||
{
|
|
||||||
devShell =
|
|
||||||
with pkgs;
|
|
||||||
mkShell.override { stdenv = pkgs.clangStdenv; } rec {
|
|
||||||
nativeBuildInputs = [
|
|
||||||
cargo
|
|
||||||
rustc
|
|
||||||
rustfmt
|
|
||||||
rustPackages.clippy
|
|
||||||
cmake
|
|
||||||
pkg-config
|
|
||||||
pre-commit
|
|
||||||
git-cliff
|
|
||||||
cargo-release
|
|
||||||
cargo-outdated
|
|
||||||
];
|
|
||||||
buildInputs = [
|
|
||||||
udev
|
|
||||||
alsa-lib
|
|
||||||
vulkan-loader
|
|
||||||
xorg.libX11
|
|
||||||
xorg.libXcursor
|
|
||||||
xorg.libXi
|
|
||||||
xorg.libXrandr
|
|
||||||
libxkbcommon
|
|
||||||
wayland
|
|
||||||
];
|
|
||||||
shellHook = ''
|
|
||||||
export LIBCLANG_PATH="${pkgs.libclang.lib}/lib"
|
|
||||||
export RUSTFLAGS="-C link-arg=-Wl,-rpath,${lib.makeLibraryPath buildInputs}"
|
|
||||||
pre-commit install
|
|
||||||
'';
|
|
||||||
RUST_SRC_PATH = rustPlatform.rustLibSrc;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
51
src/lib.rs
51
src/lib.rs
|
@ -2,8 +2,9 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
asset::{io::Reader, AssetLoader, LoadContext},
|
asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
|
reflect::TypePath,
|
||||||
transform::TransformSystem,
|
transform::TransformSystem,
|
||||||
};
|
};
|
||||||
pub use synthizer as syz;
|
pub use synthizer as syz;
|
||||||
|
@ -29,11 +30,11 @@ impl AssetLoader for BufferAssetLoader {
|
||||||
type Settings = ();
|
type Settings = ();
|
||||||
type Error = BufferAssetLoaderError;
|
type Error = BufferAssetLoaderError;
|
||||||
|
|
||||||
async fn load(
|
async fn load<'a>(
|
||||||
&self,
|
&'a self,
|
||||||
reader: &mut dyn Reader,
|
reader: &'a mut Reader<'_>,
|
||||||
_settings: &(),
|
_settings: &'a (),
|
||||||
_load_context: &mut LoadContext<'_>,
|
_load_context: &'a mut LoadContext<'_>,
|
||||||
) -> Result<Self::Asset, Self::Error> {
|
) -> Result<Self::Asset, Self::Error> {
|
||||||
let mut bytes = Vec::new();
|
let mut bytes = Vec::new();
|
||||||
reader.read_to_end(&mut bytes).await?;
|
reader.read_to_end(&mut bytes).await?;
|
||||||
|
@ -188,7 +189,7 @@ fn update_listener(
|
||||||
context: ResMut<Context>,
|
context: ResMut<Context>,
|
||||||
listener: Query<Option<&GlobalTransform>, With<Listener>>,
|
listener: Query<Option<&GlobalTransform>, With<Listener>>,
|
||||||
) {
|
) {
|
||||||
if let Ok(transform) = listener.single() {
|
if let Ok(transform) = listener.get_single() {
|
||||||
let transform: Transform = transform
|
let transform: Transform = transform
|
||||||
.map(|v| {
|
.map(|v| {
|
||||||
let transform: Transform = (*v).into();
|
let transform: Transform = (*v).into();
|
||||||
|
@ -272,9 +273,9 @@ fn add_source_handle(
|
||||||
fn add_generator(
|
fn add_generator(
|
||||||
context: Res<Context>,
|
context: Res<Context>,
|
||||||
buffers: Res<Assets<Buffer>>,
|
buffers: Res<Assets<Buffer>>,
|
||||||
mut query: Query<(Entity, Option<&ChildOf>, &mut Sound)>,
|
mut query: Query<(Entity, Option<&Parent>, &mut Sound)>,
|
||||||
mut sources: Query<&mut Source>,
|
mut sources: Query<&mut Source>,
|
||||||
parents: Query<&ChildOf>,
|
parents: Query<&Parent>,
|
||||||
) {
|
) {
|
||||||
for (entity, parent, mut sound) in &mut query {
|
for (entity, parent, mut sound) in &mut query {
|
||||||
if sound.generator.is_some() {
|
if sound.generator.is_some() {
|
||||||
|
@ -286,11 +287,11 @@ fn add_generator(
|
||||||
let mut parent = parent;
|
let mut parent = parent;
|
||||||
let mut target = None;
|
let mut target = None;
|
||||||
while let Some(p) = parent {
|
while let Some(p) = parent {
|
||||||
if sources.get(p.parent()).is_ok() {
|
if sources.get(**p).is_ok() {
|
||||||
target = Some(p.parent());
|
target = Some(**p);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
parent = parents.get(p.parent()).ok();
|
parent = parents.get(**p).ok();
|
||||||
}
|
}
|
||||||
target.map(|v| sources.get_mut(v).unwrap())
|
target.map(|v| sources.get_mut(v).unwrap())
|
||||||
} else {
|
} else {
|
||||||
|
@ -341,7 +342,7 @@ fn add_generator(
|
||||||
fn add_sound_without_source(
|
fn add_sound_without_source(
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
query: Query<Entity, (Added<Sound>, Without<Source>)>,
|
query: Query<Entity, (Added<Sound>, Without<Source>)>,
|
||||||
parents: Query<(&ChildOf, Option<&Source>)>,
|
parents: Query<(&Parent, Option<&Source>)>,
|
||||||
) {
|
) {
|
||||||
for entity in &query {
|
for entity in &query {
|
||||||
let mut has_source = false;
|
let mut has_source = false;
|
||||||
|
@ -351,7 +352,7 @@ fn add_sound_without_source(
|
||||||
has_source = true;
|
has_source = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
target = parent.parent();
|
target = **parent;
|
||||||
}
|
}
|
||||||
if !has_source {
|
if !has_source {
|
||||||
commands.entity(entity).insert(Source::default());
|
commands.entity(entity).insert(Source::default());
|
||||||
|
@ -441,16 +442,14 @@ fn update_source_properties(
|
||||||
if let Some(source) = handle.cast_to::<syz::Source3D>().expect("Failed to cast") {
|
if let Some(source) = handle.cast_to::<syz::Source3D>().expect("Failed to cast") {
|
||||||
if let Some(transform) = transform {
|
if let Some(transform) = transform {
|
||||||
let translation = transform.translation();
|
let translation = transform.translation();
|
||||||
if !translation.x.is_nan() && !translation.y.is_nan() && !translation.z.is_nan() {
|
source
|
||||||
source
|
.position()
|
||||||
.position()
|
.set((
|
||||||
.set((
|
translation.x as f64,
|
||||||
translation.x as f64,
|
translation.y as f64,
|
||||||
translation.y as f64,
|
translation.z as f64,
|
||||||
translation.z as f64,
|
))
|
||||||
))
|
.expect("Failed to set position");
|
||||||
.expect("Failed to set position");
|
|
||||||
}
|
|
||||||
let distance_model = distance_model
|
let distance_model = distance_model
|
||||||
.cloned()
|
.cloned()
|
||||||
.map(|v| *v)
|
.map(|v| *v)
|
||||||
|
@ -709,10 +708,10 @@ fn events(
|
||||||
if *generator.handle() == event.source {
|
if *generator.handle() == event.source {
|
||||||
match event.r#type {
|
match event.r#type {
|
||||||
syz::EventType::Finished => {
|
syz::EventType::Finished => {
|
||||||
output.write(SynthizerEvent::Finished(entity));
|
output.send(SynthizerEvent::Finished(entity));
|
||||||
}
|
}
|
||||||
syz::EventType::Looped => {
|
syz::EventType::Looped => {
|
||||||
output.write(SynthizerEvent::Looped(entity));
|
output.send(SynthizerEvent::Looped(entity));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user