Compare commits

...

87 Commits

Author SHA1 Message Date
2364f638db Release
All checks were successful
Release / release (push) Successful in 2m57s
Test / test (ubuntu-latest) (push) Successful in 2m7s
2024-07-07 10:59:01 -05:00
3bcf232f1e Update changelog. 2024-07-07 10:58:49 -05:00
7cef2fedd5 chore: Upgrade to Bevy 0.14.
All checks were successful
Test / test (ubuntu-latest) (push) Successful in 2m8s
2024-07-07 10:44:14 -05:00
6cf5d92cb8 chore: Switch to Gitea Actions. 2024-07-07 09:52:51 -05:00
3d422dc9e4 chore: Add pre-commit. 2024-07-07 09:50:30 -05:00
96f3457d55 Release 2024-03-14 12:45:20 -05:00
6b19103d5a Update changelog. 2024-03-14 12:45:11 -05:00
3cd68ddcbe chore: Upgrade Bevy to v0.13. 2024-03-14 12:44:32 -05:00
d34c3d6e96 Release 2024-02-09 13:43:14 -06:00
d7e9b1b70c Update changelog. 2024-02-09 13:41:51 -06:00
2080019421 chore: Bump dependencies. 2024-02-09 13:41:01 -06:00
4c1471c2ab feat!: Removed Sound.restart. Clear Sound.generator for equivalent functionality. 2023-10-16 07:32:10 -05:00
04372328c8 feat!: Renamed SynthizerSets::First to SynthizerSets::PreUpdate and moved remaining systems into PostUpdate. 2023-10-16 07:29:49 -05:00
1fb0aa763a fix: Clean up LastAudio when Sound is removed, not Source. 2023-10-16 07:25:36 -05:00
53891eeaa8 chore: Clean up code. 2023-10-16 07:23:15 -05:00
2553ea9bc2 Release 2023-07-16 13:24:40 -05:00
d6e3ba6a89 Update CHANGELOG. 2023-07-16 13:24:31 -05:00
e605495d9f chore: Update to Bevy 0.11. 2023-07-16 13:24:12 -05:00
b76ca95495 Release
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-04 15:03:59 -05:00
9f684880ed Update changelog. 2023-05-04 15:03:37 -05:00
4f972e3bd4 fix: Instantiate sources for sounds without a source in PreUpdate. 2023-05-04 15:03:07 -05:00
c739219a70 Release
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-04 07:26:39 -05:00
f69758164b Update CHANGELOG. 2023-04-04 07:26:26 -05:00
459d074040 chore: Only update_source_properties and update_listener need to run after transform propagation. 2023-04-04 07:20:43 -05:00
c14f94eb76 Release
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-03 14:49:32 -05:00
3e0b0a3e7f Update CHANGELOG. 2023-04-03 14:49:12 -05:00
855fb714da chore: Restructure system schedule to more idiomatic Bevy 0.10 style.
All checks were successful
continuous-integration/drone/push Build is passing
2023-04-03 14:48:05 -05:00
b1c1e82866 feat!: Renamed SynthizerSystems to SynthizerSets. 2023-04-03 14:24:29 -05:00
18dd994077 Release
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-06 14:26:06 -06:00
f23edf1136 Update changelog. 2023-03-06 14:25:35 -06:00
b381e1501f chore: Update to Bevy 0.10.
All checks were successful
continuous-integration/drone/push Build is passing
2023-03-06 14:24:23 -06:00
35f132d858 feat: Sound components can now get audio from either buffers or generators. 2023-03-06 13:59:53 -06:00
f498565215 Add description.
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-12-17 10:38:48 -06:00
ef7649bc01 Release
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-17 10:28:55 -06:00
40e1bc6fcd Verify on publish.
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-17 10:19:41 -06:00
5606c69bb7 Update changelog. 2022-12-17 10:18:09 -06:00
1aaa6a80c6 chore: Initial release. 2022-12-17 10:17:09 -06:00
ba3e3ad410 Add git-cliff configuration. 2022-12-17 10:16:02 -06:00
7a6d40d28a Drop version in preparation for initial release via cargo-release. 2022-12-17 10:14:10 -06:00
274c18b8ff Back to released Synthizer.
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-17 10:12:32 -06:00
08815a3c29 Make plugin struct Copy.
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-15 16:37:34 -06:00
47429c2df2 Use environment variable for dependencies.
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-15 14:05:14 -06:00
5f2881d1c8 Use plugin struct for settings. 2022-12-15 14:04:57 -06:00
32734f31d5 Update CI configuration.
All checks were successful
continuous-integration/drone/push Build is passing
2022-12-15 10:50:03 -06:00
cabc938ab7 Temporarily switch back to synthizer-rs master. 2022-12-15 10:48:29 -06:00
36f7c62836 Reorder type registrations and remove comments for unsupported reflection type. 2022-12-07 11:18:26 -06:00
6ef9d3a56a Add cargo-release metadata.
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-06 17:48:57 -06:00
b6407a7366 Switch to bullseye Rust image. 2022-12-06 17:48:13 -06:00
8cc4c0ee94 Add Drone configuration.
Some checks failed
continuous-integration/drone/push Build is failing
2022-12-06 17:11:09 -06:00
b4d298636d Reflection integration for more types. 2022-12-06 16:59:49 -06:00
3fecb314f6 Upgrade to Bevy 0.9. 2022-12-06 16:43:37 -06:00
9cb1d1d447 Back to released Synthizer. 2022-09-28 09:33:55 -05:00
298012455a Store a plain Generator in Sound component. 2022-09-09 08:23:54 -05:00
b60183c448 Remove unused variables. 2022-09-09 08:14:15 -05:00
0f4aa54612 Remove logging. 2022-09-07 20:23:22 -05:00
d69ef38486 Add printlns around source creation, handle-setting and event dispatch. 2022-09-06 09:00:47 -05:00
07d6d99ba7 Did a dumb.
Revert "If any source components exist on a sound without a source, assume the source should be created there and skip ancestry checks."

This reverts commit ed38b30843.
2022-09-05 18:25:00 -05:00
ed38b30843 If any source components exist on a sound without a source, assume the source should be created there and skip ancestry checks. 2022-09-05 13:36:36 -05:00
fe63521737 Move event system closer to state updates. 2022-09-05 13:23:33 -05:00
ba45547038 Only clear source handles if PannerStrategy is actually changed (I.e. mutated, not added.) 2022-09-05 12:24:06 -05:00
72c63af910 No longer concern ourselves with transforms when dynamically creating sources. 2022-09-05 10:37:35 -05:00
7906d93277 Add/tighten up assertions. 2022-09-04 17:28:18 -05:00
9b7fb16ee5 Set gain and pitch on generators before connecting them. 2022-09-04 12:01:32 -05:00
aa60e1d70f Add assertion limiting pitch to 0..2. 2022-08-25 12:19:17 -05:00
e4b1df13ce Replace unwrap with expect, and make logging configuration work. 2022-08-15 10:53:59 -05:00
d500c9c445 Add logging configuration and commented-out code for new APIs. 2022-08-13 08:48:31 -05:00
9d65ed0f68 Switch dependency back to working branch. 2022-08-13 08:47:26 -05:00
6e34161f6f cargo fmt 2022-08-06 11:07:43 -05:00
28b31c5be9 Track whether bundles without sources have transforms in their ancestry, and add transforms if needed. 2022-08-05 21:00:36 -05:00
b443390d62 Attempt to reorder systems more logically. 2022-08-05 20:08:25 -05:00
37c7793ad2 If a sound doesn't have a source, create a default. 2022-08-05 17:53:48 -05:00
7afa509228 Refactor Sound into Source to minimize Synthizer source use. 2022-08-05 17:04:40 -05:00
def95dcccb Update to Bevy 0.8. 2022-08-01 11:02:05 -05:00
5615a28ece Reset source when panner strategy changes or is removed. 2022-06-13 09:24:30 -05:00
28718d2e85 Add ability to set panner strategy on source creation. 2022-06-13 09:14:11 -05:00
4e6c01d654 Back to synthizer-rs master. 2022-06-07 17:58:17 -05:00
14235e0a68 Add assertions to ensure parameter ranges are clamped, and add ScalarPan::center(). 2022-06-03 11:23:03 -05:00
4f45cb6ee6 Make fields public. 2022-06-02 19:28:09 -05:00
3c094e3b89 Rename and make public. 2022-06-02 18:37:08 -05:00
8dad8d41e0 Derive Debug. 2022-06-01 14:45:48 -05:00
5eb557afc1 Bump Synthizer version. 2022-05-24 12:38:42 -05:00
1c8b9b1865 Use exponential distance model in example. 2022-05-24 11:18:09 -05:00
9391238bdc Set both source and generator gains for now. 2022-05-24 11:17:09 -05:00
c6bf921a72 Create correct source types based on presence of panning components. 2022-05-24 10:28:19 -05:00
7d3a0ba156 Break, don't continue. 2022-05-23 17:29:59 -05:00
2e55e0b4dc Add support for events. 2022-05-23 17:17:58 -05:00
10325cdbc6 Make fields public. 2022-05-23 12:47:01 -05:00
10 changed files with 861 additions and 288 deletions

View File

@ -0,0 +1,39 @@
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
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
- name: Publish
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

37
.gitea/workflows/test.yml Normal file
View File

@ -0,0 +1,37 @@
name: Test
on:
pull_request:
push:
jobs:
test:
strategy:
matrix:
# os: [windows-latest, ubuntu-latest, macos-latest]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
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

10
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,10 @@
fail_fast: true
repos:
- repo: https://github.com/doublify/pre-commit-rust
rev: v1.0
hooks:
- id: fmt
args: [--, --check]
- id: cargo-check
args: [--bins, --examples]
- id: clippy

79
CHANGELOG.md Normal file
View File

@ -0,0 +1,79 @@
# Changelog
All notable changes to this project will be documented in this file.
## Version 0.7.0 - 2024-07-07
### Miscellaneous Tasks
- Add pre-commit.
- Switch to Gitea Actions.
- Upgrade to Bevy 0.14.
## Version 0.6.0 - 2024-03-14
### Miscellaneous Tasks
- Upgrade Bevy to v0.13.
## Version 0.5.0 - 2024-02-09
### Bug Fixes
- Clean up `LastAudio` when `Sound` is removed, not `Source`.
### Features
- [**breaking**] Renamed `SynthizerSets::First` to `SynthizerSets::PreUpdate` and moved remaining systems into `PostUpdate`.
- [**breaking**] Removed `Sound.restart`. Clear `Sound.generator` for equivalent functionality.
### Miscellaneous Tasks
- Clean up code.
- Bump dependencies.
## Version 0.4.0 - 2023-07-16
### Miscellaneous Tasks
- Update to Bevy 0.11.
## Version 0.3.2 - 2023-05-04
### Bug Fixes
- Instantiate sources for sounds without a source in `PreUpdate`.
## Version 0.3.1 - 2023-04-04
### Miscellaneous Tasks
- Only `update_source_properties` and `update_listener` need to run after transform propagation.
## Version 0.3.0 - 2023-04-03
### Features
- [**breaking**] Renamed `SynthizerSystems` to `SynthizerSets`.
### Miscellaneous Tasks
- Restructure system schedule to more idiomatic Bevy 0.10 style.
## Version 0.2.0 - 2023-03-06
### Features
- `Sound` components can now get audio from either buffers or generators.
### Miscellaneous Tasks
- Update to Bevy 0.10.
## Version 0.1.0 - 2022-12-17
### Miscellaneous Tasks
- Initial release.
<!-- generated by git-cliff -->

View File

@ -1,16 +1,24 @@
[package]
name = "bevy_synthizer"
version = "0.1.0"
version = "0.7.0"
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"
license = "MIT OR Apache-2.0"
edition = "2021"
repository = "https://labs.lightsout.games/projects/bevy_synthizer"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1"
bevy = { version = "0.7", default-features = false }
synthizer = "0.4"
bevy = { version = "0.14", default-features = false, features = ["bevy_asset"] }
synthizer = "0.5.6"
thiserror = "1"
[dev-dependencies]
bevy = { version = "0.7", default-features = true }
bevy = { version = "0.14", default-features = true }
[package.metadata.release]
publish = false
push = false
pre-release-hook = ["git-cliff", "-o", "CHANGELOG.md", "--tag", "{{version}}"]
pre-release-commit-message = "Release"

60
cliff.toml Normal file
View File

@ -0,0 +1,60 @@
# configuration file for git-cliff (0.1.0)
[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.\n
"""
# template for the changelog body
# https://tera.netlify.app/docs/#introduction
body = """
{% if version %}\
## Version {{ version | trim_start_matches(pat="v") }} - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## Unreleased
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\
{% endfor %}
{% endfor %}\n
"""
# remove the leading and trailing whitespace from the template
trim = true
# changelog footer
footer = """
<!-- generated by git-cliff -->
"""
[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^feat", group = "Features"},
{ message = "^fix", group = "Bug Fixes"},
{ message = "^doc", group = "Documentation"},
{ message = "^perf", group = "Performance"},
{ message = "^refactor", group = "Refactor"},
{ message = "^style", group = "Styling"},
{ message = "^test", group = "Testing"},
{ message = "^chore\\(release\\): prepare for", skip = true},
{ message = "^chore", group = "Miscellaneous Tasks"},
{ body = ".*security", group = "Security"},
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# glob pattern for matching git tags
tag_pattern = "v[0-9]*"
# regex for skipping tags
skip_tags = ""
# regex for ignoring tags
ignore_tags = ""
# sort the tags chronologically
date_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"

73
examples/buffer.rs Normal file
View File

@ -0,0 +1,73 @@
use std::f32;
use bevy::{asset::LoadedFolder, prelude::*};
use bevy_synthizer::*;
#[derive(Component, Deref, DerefMut)]
struct RotationTimer(Timer);
impl Default for RotationTimer {
fn default() -> Self {
Self(Timer::from_seconds(30., TimerMode::Repeating))
}
}
#[derive(Resource, Default, Deref, DerefMut)]
struct AssetHandles(Handle<LoadedFolder>);
fn setup(asset_server: Res<AssetServer>, mut handles: ResMut<AssetHandles>) {
**handles = asset_server.load_folder(".");
}
fn load_and_create(
mut commands: Commands,
asset_server: Res<AssetServer>,
handles: Res<AssetHandles>,
listeners: Query<&Listener>,
) {
if !asset_server.is_loaded_with_dependencies(&**handles) {
return;
}
if !listeners.is_empty() {
return;
}
commands.spawn((
TransformBundle::default(),
Listener,
RotationTimer::default(),
));
let handle = asset_server.load("footstep.wav");
commands.spawn((
TransformBundle::from(Transform::from_translation(Vec3::new(10., 0., 0.))),
Source::default(),
Sound {
audio: handle.into(),
looping: true,
..default()
},
));
}
fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut Transform)>) {
for (mut timer, mut transform) in query.iter_mut() {
timer.tick(time.delta());
let angle = f32::consts::PI * 2. * timer.fraction();
transform.rotation = Quat::from_rotation_z(angle);
}
}
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
SynthizerPlugin {
default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf),
default_distance_model: Some(bevy_synthizer::syz::DistanceModel::Inverse),
..default()
},
))
.init_resource::<AssetHandles>()
.add_systems(Startup, setup)
.add_systems(Update, (load_and_create, rotate_listener))
.run();
}

View File

@ -1,77 +0,0 @@
use std::f32;
use bevy::{asset::LoadState, prelude::*};
use bevy_synthizer::*;
#[derive(Component, Deref, DerefMut)]
struct RotationTimer(Timer);
impl Default for RotationTimer {
fn default() -> Self {
Self(Timer::from_seconds(30., true))
}
}
#[derive(Default)]
struct AssetHandles {
sounds: Vec<HandleUntyped>,
loaded: bool,
}
fn setup(asset_server: Res<AssetServer>, mut handles: ResMut<AssetHandles>) {
handles.sounds = asset_server.load_folder(".").expect("Failed to load sfx");
}
fn load_and_create(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut handles: ResMut<AssetHandles>,
) {
if handles.loaded {
return;
}
handles.loaded = asset_server
.get_group_load_state(handles.sounds.iter().map(|handle| handle.id))
== LoadState::Loaded;
if handles.loaded {
commands
.spawn()
.insert(Listener)
.insert(Transform::default())
.insert(RotationTimer::default());
let handle = handles.sounds[0].clone();
let buffer = asset_server.get_handle(handle);
commands
.spawn()
.insert(Transform::from_translation(Vec3::new(45., 0., 0.)))
.insert(Sound {
buffer,
looping: true,
..default()
});
}
}
fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut Transform)>) {
for (mut timer, mut transform) in query.iter_mut() {
timer.tick(time.delta());
let angle = f32::consts::PI * 2. * timer.percent();
transform.rotation = Quat::from_rotation_z(angle);
}
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.insert_resource(SynthizerConfig {
default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf),
..default()
})
.add_plugin(SynthizerPlugin)
.add_system(bevy::input::system::exit_on_esc_system)
.init_resource::<AssetHandles>()
.add_startup_system(setup)
.add_system(load_and_create)
.add_system(rotate_listener)
.run();
}

56
examples/generator.rs Normal file
View File

@ -0,0 +1,56 @@
use std::f32;
use bevy::prelude::*;
use bevy_synthizer::*;
#[derive(Component, Deref, DerefMut)]
struct RotationTimer(Timer);
impl Default for RotationTimer {
fn default() -> Self {
Self(Timer::from_seconds(30., TimerMode::Repeating))
}
}
fn setup(mut commands: Commands, context: Res<Context>) {
commands.spawn((
TransformBundle::default(),
Listener,
RotationTimer::default(),
));
let generator: syz::Generator = syz::FastSineBankGenerator::new_sine(&context, 440.)
.expect("Failed to create generator")
.into();
commands.spawn((
TransformBundle::from(Transform::from_translation(Vec3::new(10., 0., 0.))),
Source::default(),
Sound {
audio: generator.into(),
looping: true,
..default()
},
));
}
fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut Transform)>) {
for (mut timer, mut transform) in query.iter_mut() {
timer.tick(time.delta());
let angle = f32::consts::PI * 2. * timer.fraction();
transform.rotation = Quat::from_rotation_z(angle);
}
}
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
SynthizerPlugin {
default_panner_strategy: Some(bevy_synthizer::syz::PannerStrategy::Hrtf),
default_distance_model: Some(bevy_synthizer::syz::DistanceModel::Inverse),
..default()
},
))
.add_systems(Startup, setup)
.add_systems(Update, rotate_listener)
.run();
}

View File

@ -2,40 +2,44 @@
use std::collections::HashMap;
use bevy::{
asset::{AssetLoader, LoadContext, LoadedAsset},
asset::{io::Reader, AssetLoader, AsyncReadExt, LoadContext},
prelude::*,
reflect::TypeUuid,
reflect::TypePath,
transform::TransformSystem,
utils::BoxedFuture,
};
pub use synthizer as syz;
use thiserror::Error;
#[derive(Clone, Deref, DerefMut, PartialEq, TypeUuid)]
#[uuid = "6b6b533a-bb1f-11ec-bda2-00155d8fdde9"]
#[derive(Asset, Clone, Debug, Deref, DerefMut, PartialEq, Eq, TypePath)]
pub struct Buffer(syz::Buffer);
#[derive(Clone, Copy, Debug, Default)]
struct BufferAssetLoader;
#[non_exhaustive]
#[derive(Debug, Error)]
pub enum BufferAssetLoaderError {
#[error("Could not load asset: {0}")]
Io(#[from] std::io::Error),
#[error("Synthizer error: {0}")]
SynthizerError(#[from] synthizer::Error),
}
impl AssetLoader for BufferAssetLoader {
fn load<'a>(
type Asset = Buffer;
type Settings = ();
type Error = BufferAssetLoaderError;
async fn load<'a>(
&'a self,
bytes: &'a [u8],
load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<(), anyhow::Error>> {
Box::pin(async move {
let buffer: Option<Buffer> =
match load_context.path().extension().unwrap().to_str().unwrap() {
"flac" | "mp3" | "wav" => {
syz::Buffer::from_encoded_data(bytes).map(Buffer).ok()
}
_ => None,
};
if let Some(buffer) = buffer {
load_context.set_default_asset(LoadedAsset::new(buffer));
}
Ok(())
})
reader: &'a mut Reader<'_>,
_settings: &'a (),
_load_context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
let mut bytes = Vec::new();
reader.read_to_end(&mut bytes).await?;
let buffer = syz::Buffer::from_encoded_data(&bytes).map(Buffer)?;
Ok(buffer)
}
fn extensions(&self) -> &[&str] {
@ -43,58 +47,59 @@ impl AssetLoader for BufferAssetLoader {
}
}
#[derive(Resource, Clone, Debug, Deref, DerefMut)]
pub struct Context(syz::Context);
#[derive(Component, Clone, Debug, Reflect)]
#[reflect(Component)]
pub struct Sound {
pub buffer: Handle<Buffer>,
pub struct Source {
pub gain: f64,
pub pitch: f64,
pub looping: bool,
pub paused: bool,
pub restart: bool,
#[reflect(ignore)]
pub source: Option<syz::Source>,
#[reflect(ignore)]
pub generator: Option<syz::BufferGenerator>,
pub handle: Option<syz::Source>,
}
impl Default for Sound {
impl Default for Source {
fn default() -> Self {
Self {
buffer: Default::default(),
gain: 1.,
pitch: 1.,
looping: false,
paused: false,
restart: false,
source: None,
generator: None,
handle: None,
}
}
}
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut)]
pub struct DistanceModel(syz::DistanceModel);
pub struct PannerStrategy(pub syz::PannerStrategy);
impl Default for PannerStrategy {
fn default() -> Self {
Self(syz::PannerStrategy::Delegate)
}
}
#[derive(Component, Clone, Copy, Debug, Deref, DerefMut)]
pub struct DistanceModel(pub syz::DistanceModel);
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
#[reflect(Component)]
pub struct DistanceRef(f64);
pub struct DistanceRef(pub f64);
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
#[reflect(Component)]
pub struct DistanceMax(f64);
pub struct DistanceMax(pub f64);
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
#[reflect(Component)]
pub struct Rolloff(f64);
pub struct Rolloff(pub f64);
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
#[reflect(Component)]
pub struct ClosenessBoost(f64);
pub struct ClosenessBoost(pub f64);
#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)]
#[reflect(Component)]
pub struct ClosenessBoostDistance(f64);
pub struct ClosenessBoostDistance(pub f64);
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
#[reflect(Component)]
@ -112,77 +117,283 @@ impl ScalarPan {
Self(-1.)
}
pub fn center() -> Self {
Self(0.)
}
pub fn right() -> Self {
Self(1.)
}
}
#[derive(Component, Clone, Debug, PartialEq, Eq)]
pub enum Audio {
Buffer(Handle<Buffer>),
Generator(syz::Generator),
}
impl Default for Audio {
fn default() -> Self {
Self::Buffer(default())
}
}
impl From<Handle<Buffer>> for Audio {
fn from(value: Handle<Buffer>) -> Self {
Audio::Buffer(value)
}
}
impl From<syz::Generator> for Audio {
fn from(value: syz::Generator) -> Self {
Self::Generator(value)
}
}
#[derive(Component, Clone, Debug)]
pub struct Sound {
pub audio: Audio,
pub gain: f64,
pub pitch: f64,
pub looping: bool,
pub paused: bool,
pub generator: Option<syz::Generator>,
}
impl Default for Sound {
fn default() -> Self {
Self {
audio: default(),
gain: 1.,
pitch: 1.,
looping: false,
paused: false,
generator: None,
}
}
}
#[derive(Event, Debug)]
pub enum SynthizerEvent {
Finished(Entity),
Looped(Entity),
}
#[derive(Component, Clone, Copy, Debug, Default, Reflect)]
#[reflect(Component)]
pub struct Listener;
pub fn update_listener(
context: ResMut<syz::Context>,
listener: Query<(Option<&Transform>, Option<&GlobalTransform>), With<Listener>>,
fn update_listener(
context: ResMut<Context>,
listener: Query<Option<&GlobalTransform>, With<Listener>>,
) {
if let Ok((transform, global_transform)) = listener.get_single() {
let transform: Option<Transform> = global_transform
if let Ok(transform) = listener.get_single() {
let transform: Transform = transform
.map(|v| {
let transform: Transform = (*v).into();
transform
})
.or_else(|| transform.cloned());
if let Some(transform) = transform {
let look = transform.local_x();
let up = transform.local_z();
if let Err(e) = context.position().set((
.unwrap_or_default();
let look = transform.local_x();
let up = transform.local_z();
context
.position()
.set((
transform.translation.x as f64,
transform.translation.y as f64,
transform.translation.z as f64,
)) {
error!("Error setting listener position: {:?}", e);
}
if let Err(e) = context.orientation().set((
))
.expect("Failed to set listener position");
context
.orientation()
.set((
look.x as f64,
look.y as f64,
look.z as f64,
up.x as f64,
up.y as f64,
up.z as f64,
)) {
error!("Error setting listener orientation: {:?}", e);
}
} else {
context.position().set((0., 0., 0.)).ok();
context.orientation().set((0., 0., 1., 0., 1., 0.)).ok();
}
} else {
context.position().set((0., 0., 0.)).ok();
context.orientation().set((0., 0., 1., 0., 1., 0.)).ok();
))
.expect("Failed to set listener orientation");
}
}
#[derive(Default, Deref, DerefMut)]
struct LastBuffer(HashMap<Entity, Handle<Buffer>>);
fn add_source_handle(
context: Res<Context>,
mut query: Query<(
&mut Source,
Option<&PannerStrategy>,
Option<&GlobalTransform>,
Option<&AngularPan>,
Option<&ScalarPan>,
)>,
) {
for (mut source, panner_strategy, transform, angular_pan, scalar_pan) in &mut query {
if source.handle.is_none() {
let panner_strategy = panner_strategy.cloned().unwrap_or_default();
let handle: syz::Source = if let Some(transform) = transform {
let translation = transform.translation();
syz::Source3D::new(
&context,
*panner_strategy,
(
translation.x as f64,
translation.y as f64,
translation.z as f64,
),
)
.expect("Failed to create source")
.into()
} else if let Some(scalar_pan) = scalar_pan {
syz::ScalarPannedSource::new(&context, *panner_strategy, **scalar_pan)
.expect("Failed to create source")
.into()
} else if let Some(angular_pan) = angular_pan {
syz::AngularPannedSource::new(
&context,
*panner_strategy,
angular_pan.azimuth,
angular_pan.elevation,
)
.expect("Failed to create source")
.into()
} else {
syz::DirectSource::new(&context)
.expect("Failed to create source")
.into()
};
source.handle = Some(handle);
}
}
}
fn swap_buffers(mut last_buffer: ResMut<LastBuffer>, mut query: Query<(Entity, &mut Sound)>) {
for (entity, mut sound) in query.iter_mut() {
let buffer = sound.buffer.clone();
if let Some(l) = last_buffer.get(&entity) {
if buffer != *l {
sound.source = None;
fn add_generator(
context: Res<Context>,
buffers: Res<Assets<Buffer>>,
mut query: Query<(Entity, Option<&Parent>, &mut Sound)>,
mut sources: Query<&mut Source>,
parents: Query<&Parent>,
) {
for (entity, parent, mut sound) in &mut query {
if sound.generator.is_none() {
let mut source = if let Ok(s) = sources.get_mut(entity) {
Some(s)
} else if parent.is_some() {
let mut parent = parent;
let mut target = None;
while let Some(p) = parent {
if sources.get(**p).is_ok() {
target = Some(**p);
break;
}
parent = parents.get(**p).ok();
}
target.map(|v| sources.get_mut(v).unwrap())
} else {
None
};
if let Some(source) = source.as_mut() {
if let Some(handle) = source.handle.as_mut() {
let generator: Option<syz::Generator> = match &sound.audio {
Audio::Buffer(buffer) => {
if let Some(b) = buffers.get(buffer) {
let generator = syz::BufferGenerator::new(&context)
.expect("Failed to create generator");
generator.buffer().set(&**b).expect("Unable to set buffer");
Some(generator.into())
} else {
None
}
}
Audio::Generator(generator) => Some(generator.clone()),
};
if let Some(generator) = generator {
assert!(sound.gain >= 0.);
generator
.gain()
.set(sound.gain)
.expect("Failed to set gain");
assert!(sound.pitch > 0. && sound.pitch <= 2.);
generator
.pitch_bend()
.set(sound.pitch)
.expect("Failed to set pitch");
handle
.add_generator(generator.handle())
.expect("Unable to add generator");
sound.generator = Some(generator);
}
}
}
}
}
}
fn add_sound_without_source(
mut commands: Commands,
query: Query<Entity, (Added<Sound>, Without<Source>)>,
parents: Query<(&Parent, Option<&Source>)>,
) {
for entity in &query {
let mut has_source = false;
let mut target = entity;
while let Ok((parent, source)) = parents.get(target) {
if source.is_some() {
has_source = true;
break;
}
target = **parent;
}
if !has_source {
commands.entity(entity).insert(Source::default());
}
}
}
#[derive(Resource, Default, Deref, DerefMut)]
struct LastAudio(HashMap<Entity, Audio>);
fn swap_buffers(
mut last_audio: ResMut<LastAudio>,
mut query: Query<(Entity, &mut Sound), Changed<Sound>>,
) {
for (entity, mut sound) in &mut query {
if let Some(l) = last_audio.get(&entity) {
if sound.generator.is_some() && sound.audio != *l {
sound.generator = None;
}
}
last_buffer.insert(entity, buffer);
last_audio.insert(entity, sound.audio.clone());
}
}
pub fn update_sound_properties(
context: Res<syz::Context>,
buffers: Res<Assets<Buffer>>,
fn change_panner_strategy(
changed: Query<(Entity, Ref<PannerStrategy>)>,
mut removed: RemovedComponents<PannerStrategy>,
mut sources: Query<&mut Source>,
) {
let mut check = vec![];
for (entity, change) in &changed {
if !change.is_added() && change.is_changed() {
check.push(entity);
}
}
for entity in removed.read() {
check.push(entity);
}
for entity in check.iter() {
if let Ok(mut source) = sources.get_mut(*entity) {
if source.handle.is_some() {
source.handle = None;
}
}
}
}
fn update_source_properties(
context: Res<Context>,
mut query: Query<(
&mut Sound,
&mut Source,
Option<&DistanceModel>,
Option<&DistanceRef>,
Option<&DistanceMax>,
@ -191,12 +402,11 @@ pub fn update_sound_properties(
Option<&ClosenessBoostDistance>,
Option<&AngularPan>,
Option<&ScalarPan>,
Option<&Transform>,
Option<&GlobalTransform>,
)>,
) {
for (
mut sound,
mut source,
distance_model,
distance_ref,
distance_max,
@ -206,77 +416,16 @@ pub fn update_sound_properties(
angular_pan,
scalar_pan,
transform,
global_transform,
) in query.iter_mut()
) in &mut query
{
let Sound {
gain,
pitch,
looping,
..
} = *sound;
if sound.restart {
if let Some(generator) = sound.generator.as_mut() {
generator
.playback_position()
.set(0.)
.expect("Failed to restart");
}
sound.restart = false;
}
if sound.generator.is_none() {
let generator =
syz::BufferGenerator::new(&context).expect("Failed to create generator");
sound.generator = Some(generator);
}
let translation = global_transform
.map(|v| v.translation)
.or_else(|| transform.map(|v| v.translation));
if sound.source.is_none() {
if let Some(b) = buffers.get(sound.buffer.clone()) {
if let Some(generator) = sound.generator.as_mut() {
generator.buffer().set(&**b).expect("Unable to set buffer");
if let Some(translation) = translation {
let source = syz::Source3D::new(
&context,
syz::PannerStrategy::Delegate,
(
translation.x as f64,
translation.y as f64,
translation.z as f64,
),
)
.expect("Failed to create source");
source
.add_generator(generator)
.expect("Unable to add generator");
sound.source = Some(source.into());
} else {
let source =
syz::DirectSource::new(&context).expect("Failed to create source");
source
.add_generator(generator)
.expect("Failed to add generator");
sound.source = Some(source.into());
}
}
}
}
if let Some(generator) = sound.generator.as_mut() {
generator
.pitch_bend()
.set(pitch)
.expect("Failed to set pitch");
generator
.looping()
.set(looping)
.expect("Failed to set looping");
}
if let Some(source) = sound.source.as_mut() {
source.gain().set(gain).expect("Failed to set gain");
let Source { gain, .. } = *source;
assert!(gain >= 0.);
if let Some(handle) = source.handle.as_mut() {
handle.gain().set(gain).expect("Failed to set gain");
let mut clear_source = false;
if let Some(translation) = translation {
if let Some(source) = source.cast_to::<syz::Source3D>().unwrap() {
if let Some(transform) = transform {
if let Some(source) = handle.cast_to::<syz::Source3D>().expect("Failed to cast") {
let translation = transform.translation();
source
.position()
.set((
@ -288,7 +437,7 @@ pub fn update_sound_properties(
let distance_model = distance_model
.cloned()
.map(|v| *v)
.unwrap_or_else(|| context.default_distance_modle().get().unwrap());
.unwrap_or_else(|| context.default_distance_model().get().unwrap());
source
.distance_model()
.set(distance_model)
@ -296,6 +445,7 @@ pub fn update_sound_properties(
let distance_ref = distance_ref
.map(|v| **v)
.unwrap_or_else(|| context.default_distance_ref().get().unwrap());
assert!(distance_ref >= 0.);
source
.distance_ref()
.set(distance_ref)
@ -303,6 +453,7 @@ pub fn update_sound_properties(
let distance_max = distance_max
.map(|v| **v)
.unwrap_or_else(|| context.default_distance_max().get().unwrap());
assert!(distance_max >= 0.);
source
.distance_max()
.set(distance_max)
@ -310,6 +461,7 @@ pub fn update_sound_properties(
let rolloff = rolloff
.map(|v| **v)
.unwrap_or_else(|| context.default_rolloff().get().unwrap());
assert!(rolloff >= 0.);
source
.rolloff()
.set(rolloff)
@ -317,6 +469,7 @@ pub fn update_sound_properties(
let closeness_boost = closeness_boost
.map(|v| **v)
.unwrap_or_else(|| context.default_closeness_boost().get().unwrap());
assert!(closeness_boost >= 0.);
source
.closeness_boost()
.set(closeness_boost)
@ -325,6 +478,7 @@ pub fn update_sound_properties(
closeness_boost_distance.map(|v| **v).unwrap_or_else(|| {
context.default_closeness_boost_distance().get().unwrap()
});
assert!(closeness_boost_distance >= 0.);
source
.closeness_boost_distance()
.set(closeness_boost_distance)
@ -333,11 +487,16 @@ pub fn update_sound_properties(
clear_source = true;
}
} else if let Some(angular_pan) = angular_pan {
if let Some(source) = source.cast_to::<syz::AngularPannedSource>().unwrap() {
if let Some(source) = handle
.cast_to::<syz::AngularPannedSource>()
.expect("Failed to cast")
{
assert!(angular_pan.azimuth >= 0. && angular_pan.azimuth <= 360.);
source
.azimuth()
.set(angular_pan.azimuth)
.expect("Failed to set azimuth");
assert!(angular_pan.elevation >= -90. && angular_pan.elevation <= 90.);
source
.elevation()
.set(angular_pan.elevation)
@ -346,7 +505,11 @@ pub fn update_sound_properties(
clear_source = true;
}
} else if let Some(scalar_pan) = scalar_pan {
if let Some(source) = source.cast_to::<syz::ScalarPannedSource>().unwrap() {
if let Some(source) = handle
.cast_to::<syz::ScalarPannedSource>()
.expect("Failed to cast")
{
assert!(**scalar_pan >= -1. && **scalar_pan <= 1.);
source
.panning_scalar()
.set(**scalar_pan)
@ -356,14 +519,55 @@ pub fn update_sound_properties(
}
}
if clear_source {
sound.source = None;
source.handle = None;
}
}
}
}
pub fn update_playback_state(query: Query<&Sound>) {
for sound in query.iter() {
fn update_sound_properties(mut query: Query<&mut Sound>) {
for mut sound in &mut query {
let Sound {
gain,
pitch,
looping,
..
} = *sound;
assert!(gain >= 0.);
assert!(pitch > 0. && pitch <= 2.);
if let Some(generator) = sound.generator.as_mut() {
generator.gain().set(gain).expect("Failed to set gain");
generator
.pitch_bend()
.set(pitch)
.expect("Failed to set pitch");
if let Some(generator) = generator
.cast_to::<syz::BufferGenerator>()
.expect("Failed to cast")
{
generator
.looping()
.set(looping)
.expect("Failed to set looping");
}
}
}
}
fn update_source_playback_state(query: Query<&Source>) {
for source in &query {
if let Some(handle) = &source.handle {
if source.paused {
handle.pause().expect("Failed to pause");
} else {
handle.play().expect("Failed to play");
}
}
}
}
fn update_sound_playback_state(query: Query<&Sound>) {
for sound in &query {
if let Some(generator) = &sound.generator {
if sound.paused {
generator.pause().expect("Failed to pause");
@ -374,35 +578,28 @@ pub fn update_playback_state(query: Query<&Sound>) {
}
}
fn remove_sound(mut last_buffer: ResMut<LastBuffer>, removed: RemovedComponents<Sound>) {
for entity in removed.iter() {
fn remove_sound(mut last_buffer: ResMut<LastAudio>, mut removed: RemovedComponents<Sound>) {
for entity in removed.read() {
last_buffer.remove(&entity);
}
}
#[derive(Clone, Copy, Default, Debug)]
pub struct SynthizerConfig {
pub default_panner_strategy: Option<syz::PannerStrategy>,
pub default_distance_model: Option<syz::DistanceModel>,
pub default_distance_ref: Option<f64>,
pub default_distance_max: Option<f64>,
pub default_rolloff: Option<f64>,
pub default_closeness_boost: Option<f64>,
pub default_closeness_boost_distance: Option<f64>,
#[derive(Resource, Debug)]
pub struct SynthizerDefaults {
pub panner_strategy: syz::PannerStrategy,
pub distance_model: syz::DistanceModel,
pub distance_ref: f64,
pub distance_max: f64,
pub rolloff: f64,
pub closeness_boost: f64,
pub closeness_boost_distance: f64,
}
#[derive(Debug)]
struct Defaults {
panner_strategy: syz::PannerStrategy,
distance_model: syz::DistanceModel,
distance_ref: f64,
distance_max: f64,
rolloff: f64,
closeness_boost: f64,
closeness_boost_distance: f64,
}
fn sync_config(context: Res<syz::Context>, config: Res<SynthizerConfig>, defaults: Res<Defaults>) {
fn sync_config(
context: Res<Context>,
config: Res<SynthizerPlugin>,
defaults: Res<SynthizerDefaults>,
) {
if config.is_changed() {
context
.default_panner_strategy()
@ -413,7 +610,7 @@ fn sync_config(context: Res<syz::Context>, config: Res<SynthizerConfig>, default
)
.expect("Failed to set panner strategy");
context
.default_distance_modle()
.default_distance_model()
.set(
config
.default_distance_model
@ -451,49 +648,140 @@ fn sync_config(context: Res<syz::Context>, config: Res<SynthizerConfig>, default
}
}
pub struct SynthizerPlugin;
fn events(
context: Res<Context>,
sounds: Query<(Entity, &Sound)>,
mut output: EventWriter<SynthizerEvent>,
) {
context.get_events().for_each(|event| {
if let Ok(event) = event {
for (entity, sound) in &sounds {
if let Some(generator) = &sound.generator {
if *generator.handle() == event.source {
match event.r#type {
syz::EventType::Finished => {
output.send(SynthizerEvent::Finished(entity));
}
syz::EventType::Looped => {
output.send(SynthizerEvent::Looped(entity));
}
_ => {}
}
break;
}
}
}
}
});
}
#[derive(SystemSet, Clone, Hash, Debug, PartialEq, Eq)]
pub enum SynthizerSets {
PreUpdate,
UpdateHandles,
UpdateProperties,
UpdateState,
Last,
}
#[derive(Resource)]
struct InitializationGuard(syz::InitializationGuard);
#[derive(Resource, Clone, Copy, Default, Debug)]
pub struct SynthizerPlugin {
pub default_panner_strategy: Option<syz::PannerStrategy>,
pub default_distance_model: Option<syz::DistanceModel>,
pub default_distance_ref: Option<f64>,
pub default_distance_max: Option<f64>,
pub default_rolloff: Option<f64>,
pub default_closeness_boost: Option<f64>,
pub default_closeness_boost_distance: Option<f64>,
pub log_level: syz::LogLevel,
pub log_to_stderr: bool,
}
impl Plugin for SynthizerPlugin {
fn build(&self, app: &mut App) {
let guard = syz::initialize().expect("Failed to initialize Synthizer");
let context = syz::Context::new().expect("Failed to create Synthizer context");
if !app.world.contains_resource::<SynthizerConfig>() {
app.insert_resource(SynthizerConfig::default());
if !app.world().contains_resource::<SynthizerPlugin>() {
app.insert_resource(*self);
}
let defaults = Defaults {
let config = *app.world().get_resource::<SynthizerPlugin>().unwrap();
let mut syz_config = syz::LibraryConfig::new();
syz_config.log_level(config.log_level);
if config.log_to_stderr {
syz_config.log_to_stderr();
}
let guard = syz_config
.initialize()
.expect("Failed to initialize Synthizer");
let guard = InitializationGuard(guard);
let context = syz::Context::new().expect("Failed to create Synthizer context");
let defaults = SynthizerDefaults {
panner_strategy: context.default_panner_strategy().get().unwrap(),
distance_model: context.default_distance_modle().get().unwrap(),
distance_model: context.default_distance_model().get().unwrap(),
distance_ref: context.default_distance_ref().get().unwrap(),
distance_max: context.default_distance_max().get().unwrap(),
rolloff: context.default_rolloff().get().unwrap(),
closeness_boost: context.default_closeness_boost().get().unwrap(),
closeness_boost_distance: context.default_closeness_boost_distance().get().unwrap(),
};
app.add_asset::<Buffer>()
context.enable_events().expect("Failed to enable events");
let context = Context(context);
app.init_asset::<Buffer>()
.init_asset_loader::<BufferAssetLoader>()
.register_type::<DistanceRef>()
.register_type::<DistanceMax>()
.register_type::<Rolloff>()
.register_type::<ClosenessBoostDistance>()
.register_type::<AngularPan>()
.register_type::<ScalarPan>()
.register_type::<Source>()
.register_type::<Listener>()
.insert_resource(guard)
.insert_resource(context)
.init_resource::<LastBuffer>()
.init_resource::<LastAudio>()
.insert_resource(defaults)
.add_system_to_stage(CoreStage::PreUpdate, sync_config)
.add_system_to_stage(
CoreStage::PostUpdate,
swap_buffers.before(update_sound_properties),
.add_event::<SynthizerEvent>()
.add_systems(
PreUpdate,
(sync_config, swap_buffers, change_panner_strategy)
.in_set(SynthizerSets::PreUpdate),
)
.add_system_to_stage(
CoreStage::PostUpdate,
update_listener
.after(TransformSystem::TransformPropagate)
.before(update_playback_state),
.add_systems(
PostUpdate,
(add_sound_without_source, add_source_handle, add_generator)
.in_set(SynthizerSets::UpdateHandles),
)
.add_system_to_stage(
CoreStage::PostUpdate,
update_sound_properties
.after(TransformSystem::TransformPropagate)
.before(update_playback_state),
.configure_sets(
PostUpdate,
SynthizerSets::UpdateHandles.before(SynthizerSets::UpdateProperties),
)
.add_system_to_stage(CoreStage::PostUpdate, update_playback_state)
.add_system_to_stage(CoreStage::PostUpdate, remove_sound);
.add_systems(
PostUpdate,
update_sound_properties.in_set(SynthizerSets::UpdateProperties),
)
.add_systems(
PostUpdate,
(update_listener, update_source_properties)
.in_set(SynthizerSets::UpdateProperties)
.after(TransformSystem::TransformPropagate),
)
.configure_sets(
PostUpdate,
SynthizerSets::UpdateProperties.before(SynthizerSets::UpdateState),
)
.add_systems(
PostUpdate,
(update_source_playback_state, update_sound_playback_state)
.in_set(SynthizerSets::UpdateState),
)
.configure_sets(
PostUpdate,
SynthizerSets::UpdateState.before(SynthizerSets::Last),
)
.add_systems(
PostUpdate,
(remove_sound, events).in_set(SynthizerSets::Last),
);
}
}