Compare commits

..

No commits in common. "7cef2fedd52dc69f0ef439ca4f6f7f0604292fe3" and "96f3457d558402be5bdc8757204aafa8aecaf45f" have entirely different histories.

8 changed files with 72 additions and 104 deletions

47
.drone.yml Normal file
View File

@ -0,0 +1,47 @@
kind: pipeline
type: docker
name: default
environment:
DEPENDENCIES: cmake pkg-config libx11-dev libasound2-dev libudev-dev libxcb-xfixes0-dev libwayland-dev libxkbcommon-dev libvulkan-dev libpulse-dev
steps:
- name: test
image: rust:bullseye
pull: always
commands:
- apt-get update -qq
- apt-get install -qqy $DEPENDENCIES
- rustup component add clippy rustfmt
- cargo fmt --check
- cargo test
- cargo clippy
- name: release
image: rust:bullseye
pull: always
commands:
- apt-get update -qq
- apt-get install -qqy $DEPENDENCIES
- cargo publish
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

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -10,12 +10,11 @@ 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]
bevy = { version = "0.14", default-features = false, features = ["bevy_asset"] }
bevy = { version = "0.13", default-features = false, features = ["bevy_asset"] }
synthizer = "0.5.6"
thiserror = "1"
[dev-dependencies]
bevy = { version = "0.14", default-features = true }
bevy = { version = "0.13", default-features = true }
[package.metadata.release]
publish = false

View File

@ -51,7 +51,7 @@ fn load_and_create(
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();
let angle = f32::consts::PI * 2. * timer.percent();
transform.rotation = Quat::from_rotation_z(angle);
}
}
@ -68,6 +68,9 @@ fn main() {
))
.init_resource::<AssetHandles>()
.add_systems(Startup, setup)
.add_systems(Update, (load_and_create, rotate_listener))
.add_systems(
Update,
(bevy::window::close_on_esc, load_and_create, rotate_listener),
)
.run();
}

View File

@ -35,7 +35,7 @@ fn setup(mut commands: Commands, context: Res<Context>) {
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();
let angle = f32::consts::PI * 2. * timer.percent();
transform.rotation = Quat::from_rotation_z(angle);
}
}
@ -51,6 +51,6 @@ fn main() {
},
))
.add_systems(Startup, setup)
.add_systems(Update, rotate_listener)
.add_systems(Update, (bevy::window::close_on_esc, rotate_listener))
.run();
}

View File

@ -6,9 +6,12 @@ use bevy::{
prelude::*,
reflect::TypePath,
transform::TransformSystem,
utils::{
thiserror::{self, Error},
BoxedFuture,
},
};
pub use synthizer as syz;
use thiserror::Error;
#[derive(Asset, Clone, Debug, Deref, DerefMut, PartialEq, Eq, TypePath)]
pub struct Buffer(syz::Buffer);
@ -30,16 +33,18 @@ impl AssetLoader for BufferAssetLoader {
type Settings = ();
type Error = BufferAssetLoaderError;
async fn load<'a>(
fn load<'a>(
&'a self,
reader: &'a mut Reader<'_>,
reader: &'a mut Reader,
_settings: &'a (),
_load_context: &'a mut LoadContext<'_>,
) -> Result<Self::Asset, Self::Error> {
_load_context: &'a mut LoadContext,
) -> BoxedFuture<'a, Result<Self::Asset, Self::Error>> {
Box::pin(async move {
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] {
@ -702,10 +707,10 @@ pub struct SynthizerPlugin {
impl Plugin for SynthizerPlugin {
fn build(&self, app: &mut App) {
if !app.world().contains_resource::<SynthizerPlugin>() {
if !app.world.contains_resource::<SynthizerPlugin>() {
app.insert_resource(*self);
}
let config = *app.world().get_resource::<SynthizerPlugin>().unwrap();
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 {