Compare commits
No commits in common. "main" and "c945c8b1ba4bda8f601da07dcdfea6935ac17319" have entirely different histories.
main
...
c945c8b1ba
|
@ -1,39 +0,0 @@
|
||||||
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 }}
|
|
|
@ -1,37 +0,0 @@
|
||||||
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
|
|
|
@ -1,10 +0,0 @@
|
||||||
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
|
|
99
CHANGELOG.md
99
CHANGELOG.md
|
@ -1,99 +0,0 @@
|
||||||
# Changelog
|
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
|
||||||
|
|
||||||
## Version 0.9.0 - 2024-12-06
|
|
||||||
|
|
||||||
### Miscellaneous Tasks
|
|
||||||
|
|
||||||
- Upgrade to Bevy 0.15.
|
|
||||||
|
|
||||||
## Version 0.8.0 - 2024-12-02
|
|
||||||
|
|
||||||
### Bug Fixes
|
|
||||||
|
|
||||||
- Clear generator when source is cleared, and improve handling for changing source types.
|
|
||||||
|
|
||||||
### Features
|
|
||||||
|
|
||||||
- Add `Sound.playback_position` to support initializing new buffers at non-zero playback position.
|
|
||||||
|
|
||||||
### Miscellaneous Tasks
|
|
||||||
|
|
||||||
- Clean up code.
|
|
||||||
|
|
||||||
## 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 -->
|
|
18
Cargo.toml
18
Cargo.toml
|
@ -1,24 +1,16 @@
|
||||||
[package]
|
[package]
|
||||||
name = "bevy_synthizer"
|
name = "bevy_synthizer"
|
||||||
version = "0.9.0"
|
version = "0.1.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"
|
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
edition = "2021"
|
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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bevy = { version = "0.15", default-features = false, features = ["bevy_asset"] }
|
anyhow = "1"
|
||||||
synthizer = "0.5.6"
|
bevy = { version = "0.7", default-features = false }
|
||||||
thiserror = "1"
|
synthizer = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
bevy = { version = "0.15", default-features = true }
|
bevy = { version = "0.7", 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
60
cliff.toml
|
@ -1,60 +0,0 @@
|
||||||
# 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"
|
|
|
@ -1,69 +0,0 @@
|
||||||
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((Transform::default(), Listener, RotationTimer::default()));
|
|
||||||
let handle = asset_server.load("footstep.wav");
|
|
||||||
commands.spawn((
|
|
||||||
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();
|
|
||||||
}
|
|
77
examples/game.rs
Normal file
77
examples/game.rs
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
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();
|
||||||
|
}
|
|
@ -1,52 +0,0 @@
|
||||||
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((Transform::default(), Listener, RotationTimer::default()));
|
|
||||||
let generator: syz::Generator = syz::FastSineBankGenerator::new_sine(&context, 440.)
|
|
||||||
.expect("Failed to create generator")
|
|
||||||
.into();
|
|
||||||
commands.spawn((
|
|
||||||
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();
|
|
||||||
}
|
|
889
src/lib.rs
889
src/lib.rs
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user