Compare commits

..

No commits in common. "8cc4c0ee9420de175c0425f7b90ed288736a3ebe" and "9cb1d1d4473e3c146b17638ac53e3558b17e44cc" have entirely different histories.

4 changed files with 25 additions and 86 deletions

View File

@ -1,44 +0,0 @@
kind: pipeline
type: docker
name: default
steps:
- name: test
image: rust
pull: always
commands:
- rustup component add clippy rustfmt
- apt-get update -qq
- apt-get install -qqy llvm-dev libclang-dev clang cmake pkg-config libx11-dev libasound2-dev libudev-dev libxcb-xfixes0-dev libwayland-dev libxkbcommon-dev libvulkan-dev libpulse-dev
- cargo fmt --check
- cargo test
- cargo clippy
- name: release
image: rust
pull: always
commands:
- apt-get update -qq
- apt-get install -qqy llvm-dev libclang-dev clang cmake pkg-config libx11-dev libasound2-dev libudev-dev libxcb-xfixes0-dev libwayland-dev libxkbcommon-dev libvulkan-dev libpulse-dev
- cargo publish --no-verify
when:
ref:
- refs/tags/v*
environment:
CARGO_REGISTRY_TOKEN:
from_secret: cargo_registry_token
- name: discord notification
image: appleboy/drone-discord
when:
status: [success, failure]
settings:
webhook_id:
from_secret: discord_webhook_id
webhook_token:
from_secret: discord_webhook_token
tts: true
message: >
{{#success build.status}}
{{repo.name}} build {{build.number}} succeeded: <{{build.link}}>
{{else}}
{{repo.name}} build {{build.number}} failed: <{{build.link}}>
{{/success}}

View File

@ -4,14 +4,13 @@ version = "0.1.0"
authors = ["Nolan Darilek <nolan@thewordnerd.info>"]
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.9", default-features = false, features = ["bevy_asset"] }
bevy = { version = "0.8", default-features = false, features = ["bevy_asset"] }
synthizer = "0.5"
[dev-dependencies]
bevy = { version = "0.9", default-features = true }
bevy = { version = "0.8", default-features = true }

View File

@ -8,11 +8,11 @@ struct RotationTimer(Timer);
impl Default for RotationTimer {
fn default() -> Self {
Self(Timer::from_seconds(30., TimerMode::Repeating))
Self(Timer::from_seconds(30., true))
}
}
#[derive(Resource, Default)]
#[derive(Default)]
struct AssetHandles {
sounds: Vec<HandleUntyped>,
loaded: bool,
@ -34,22 +34,22 @@ fn load_and_create(
.get_group_load_state(handles.sounds.iter().map(|handle| handle.id))
== LoadState::Loaded;
if handles.loaded {
commands.spawn((
TransformBundle::default(),
Listener,
RotationTimer::default(),
));
commands
.spawn_bundle(TransformBundle::default())
.insert(Listener)
.insert(RotationTimer::default());
let handle = handles.sounds[0].clone();
let buffer = asset_server.get_handle(handle);
commands.spawn((
TransformBundle::from(Transform::from_translation(Vec3::new(10., 0., 0.))),
Source::default(),
Sound {
commands
.spawn_bundle(TransformBundle::from(Transform::from_translation(
Vec3::new(10., 0., 0.),
)))
.insert(Source::default())
.insert(Sound {
buffer,
looping: true,
..default()
},
));
});
}
}

View File

@ -10,7 +10,7 @@ use bevy::{
};
pub use synthizer as syz;
#[derive(Clone, Debug, Deref, DerefMut, PartialEq, Eq, TypeUuid)]
#[derive(Clone, Debug, Deref, DerefMut, PartialEq, TypeUuid)]
#[uuid = "6b6b533a-bb1f-11ec-bda2-00155d8fdde9"]
pub struct Buffer(syz::Buffer);
@ -43,9 +43,6 @@ impl AssetLoader for BufferAssetLoader {
}
}
#[derive(Resource, Clone, Debug, Deref, DerefMut)]
pub struct Context(syz::Context);
#[derive(Component, Clone, Debug, Reflect)]
#[reflect(Component)]
pub struct Source {
@ -160,7 +157,7 @@ pub enum SynthizerEvent {
pub struct Listener;
fn update_listener(
context: ResMut<Context>,
context: ResMut<syz::Context>,
listener: Query<Option<&GlobalTransform>, With<Listener>>,
) {
if let Ok(transform) = listener.get_single() {
@ -195,7 +192,7 @@ fn update_listener(
}
fn add_source_handle(
context: Res<Context>,
context: Res<syz::Context>,
mut query: Query<(
&mut Source,
Option<&PannerStrategy>,
@ -244,7 +241,7 @@ fn add_source_handle(
}
fn add_generator(
context: Res<Context>,
context: Res<syz::Context>,
buffers: Res<Assets<Buffer>>,
mut query: Query<(Entity, Option<&Parent>, &mut Sound)>,
mut sources: Query<&mut Source>,
@ -316,7 +313,7 @@ fn add_sound_without_source(
}
}
#[derive(Resource, Default, Deref, DerefMut)]
#[derive(Default, Deref, DerefMut)]
struct LastBuffer(HashMap<Entity, Handle<Buffer>>);
fn swap_buffers(
@ -357,7 +354,7 @@ fn change_panner_strategy(
}
fn update_source_properties(
context: Res<Context>,
context: Res<syz::Context>,
mut query: Query<(
&mut Source,
Option<&DistanceModel>,
@ -564,7 +561,7 @@ fn remove_sound(mut last_buffer: ResMut<LastBuffer>, removed: RemovedComponents<
}
}
#[derive(Resource, Clone, Default, Debug)]
#[derive(Clone, Default, Debug)]
pub struct SynthizerConfig {
pub default_panner_strategy: Option<syz::PannerStrategy>,
pub default_distance_model: Option<syz::DistanceModel>,
@ -577,7 +574,7 @@ pub struct SynthizerConfig {
pub log_to_stderr: bool,
}
#[derive(Resource, Debug)]
#[derive(Debug)]
pub struct SynthizerDefaults {
pub panner_strategy: syz::PannerStrategy,
pub distance_model: syz::DistanceModel,
@ -589,7 +586,7 @@ pub struct SynthizerDefaults {
}
fn sync_config(
context: Res<Context>,
context: Res<syz::Context>,
config: Res<SynthizerConfig>,
defaults: Res<SynthizerDefaults>,
) {
@ -642,7 +639,7 @@ fn sync_config(
}
fn events(
context: Res<Context>,
context: Res<syz::Context>,
sounds: Query<(Entity, &Sound)>,
mut output: EventWriter<SynthizerEvent>,
) {
@ -680,9 +677,6 @@ pub enum SynthizerSystems {
UpdateState,
}
#[derive(Resource)]
struct InitializationGuard(syz::InitializationGuard);
pub struct SynthizerPlugin;
impl Plugin for SynthizerPlugin {
@ -699,7 +693,6 @@ impl Plugin for SynthizerPlugin {
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(),
@ -711,17 +704,8 @@ impl Plugin for SynthizerPlugin {
closeness_boost_distance: context.default_closeness_boost_distance().get().unwrap(),
};
context.enable_events().expect("Failed to enable events");
let context = Context(context);
app.add_asset::<Buffer>()
.init_asset_loader::<BufferAssetLoader>()
.register_type::<Source>()
.register_type::<DistanceRef>()
.register_type::<DistanceMax>()
.register_type::<Rolloff>()
.register_type::<ClosenessBoostDistance>()
.register_type::<AngularPan>()
.register_type::<ScalarPan>()
.register_type::<Sound>()
.register_type::<Listener>()
.insert_resource(guard)
.insert_resource(context)