diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 115dd2b..d3a968e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,107 +1,44 @@ -on: [push, pull_request] +name: CI -name: Continuous integration +on: + push: + branches: [main] + pull_request: + branches: [main] -jobs: - check_bevy_audio: - name: check bevy_audio - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - - uses: actions-rs/cargo@v1 - with: - command: check - - test_bevy_audio: - name: test bevy_audio - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - - uses: actions-rs/cargo@v1 - with: - command: test +env: + CARGO_TERM_COLOR: always - check_kira: - name: check kira - runs-on: ubuntu-latest +jobs: + test: + strategy: + fail-fast: false + matrix: + feature: [bevy_audio, kira, oddio] + os: [windows-latest, ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 - - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: stable - override: true - - name: Install alsa and udev - run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - - uses: actions-rs/cargo@v1 + - uses: actions/checkout@v2 + - uses: actions/cache@v2 with: - command: check - args: --no-default-features --features kira - - test_kira: - name: test kira - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + key: ${{ runner.os }}-cargo-build-${{ matrix.toolchain }}-${{ hashFiles('**/Cargo.toml') }} - uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: stable override: true - name: Install alsa and udev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + if: runner.os == 'linux' - uses: actions-rs/cargo@v1 with: command: test - args: --no-default-features --features kira - - # check_oddio: - # name: check oddio - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: stable - # override: true - # - name: Install alsa and udev - # run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - # - uses: actions-rs/cargo@v1 - # with: - # command: check - # args: --no-default-features --features oddio - - # test_oddio: - # name: test oddio - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - uses: actions-rs/toolchain@v1 - # with: - # profile: minimal - # toolchain: stable - # override: true - # - name: Install alsa and udev - # run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev - # - uses: actions-rs/cargo@v1 - # with: - # command: test - # args: --no-default-features --features oddio + args: --no-default-features --features ${{ matrix.feature }} fmt: name: fmt @@ -138,3 +75,22 @@ jobs: with: command: clippy args: -- -D warnings + + miri: + name: miri + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + feature: [bevy_audio, kira, oddio] + steps: + - uses: actions/checkout@v3 + - name: Install Miri + run: | + rustup toolchain install nightly --component miri + rustup override set nightly + cargo miri setup + - name: Install alsa and udev + run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev + - name: Test with Miri + run: cargo miri test --no-default-features --features ${{ matrix.feature }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..65fa299 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,41 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.2.0] - 14-11-2022 + +Reworked the majority of the internals. + +## Added + +- A way to play streaming DSP sources. See `SourceType::Dynamic`. +- You can play DSP sources using `Audio::play_dsp`. +- Two iterators on streaming audio sources: `Iter` and `IterMono`. + +### Changed + +- Adding the DSP plugin. + - You must now call `DspPlugin::default()`. +- The method on adding DSP sources. + - No more initializing using `DspAssets`! + - Just add your DSP function using `app.add_dsp_source` +- Playing DSP sources require `Audio` to be mutable. (Use `ResMut`) +- A lot of internals are shuffled around. + +### Removed + +- `DspAssets`. Initialize DSP graphs using `App::add_dsp_source` instead. +- `FnDspGraph`. This is now reworked to the trait `DspGraph` and can work with any type now. +- `StreamingDspSource`. This is now reworked to `Iter` (`bevy_kira_audio` and `bevy_oddio`) and `IterMono` (`bevy_audio`). + +## [0.1.0] - 01-08-22 + +- New bevy plugin! `bevy_fundsp` integrates fundsp with bevy. + +[Unreleased]: https://github.com/harudagondi/bevy_fundsp/compare/v0.2.0...HEAD +[0.2.0]: https://github.com/harudagondi/bevy_fundsp/compare/v0.1.0...v0.2.0 +[0.1.0]: https://github.com/harudagondi/bevy_fundsp/releases/tag/v0.1.0 \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index f472392..b97ecd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_fundsp" authors = ["Gio Genre De Asis"] -version = "0.1.0" +version = "0.2.0" edition = "2021" description = "A Bevy plugin that integrates FunDSP into Bevy." homepage = "https://github.com/harudagondi/bevy_fundsp" @@ -12,36 +12,52 @@ categories = ["game-development", "multimedia::audio"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +default = ["bevy_audio"] +kira = ["dep:kira", "bevy_kira_audio"] +bevy_audio = ["bevy/bevy_audio", "bevy/wav", "rodio"] +oddio = ["bevy_oddio"] + [dependencies] fundsp = "0.9" -kira = { version = "0.6", default-features = false, features = ["wav"], optional = true } -# bevy_oddio = { git = "https://github.com/harudagondi/bevy_oddio.git", optional = true } +cpal = "0.14" +once_cell = "1.13" +rodio = { version = "0.16", default-features = false, features = ["wav"], optional = true } +kira = { version = "0.7", default-features = false, features = ["wav"], optional = true } +ringbuf = "0.3" +parking_lot = "0.12" -atomic = "0.5" +[dependencies.uuid] +version = "1.1" +features = [ + "v5" +] [dependencies.bevy] # git = "https://github.com/bevyengine/bevy" -version = "0.8" +version = "0.9" default-features = false features = ["bevy_asset"] [dependencies.bevy_kira_audio] # git = "https://github.com/NiklasEi/bevy_kira_audio.git" # branch = "bevy_main" -version = "0.11" +version = "0.13" default-features = false features = ["wav"] optional = true -[features] -default = ["bevy_audio"] -kira = ["dep:kira", "bevy_kira_audio"] -bevy_audio = ["bevy/bevy_audio", "bevy/wav"] -# oddio = ["bevy_oddio"] +[dependencies.bevy_oddio] +# git = "https://github.com/harudagondi/bevy_oddio" +# branch = "bevy_main" +version = "0.3" +default-features = false +optional = true +features = ["wav"] [dev-dependencies.bevy] # git = "https://github.com/bevyengine/bevy" -version = "0.8" +version = "0.9" default-features = false features = [ "render", @@ -76,7 +92,17 @@ name = "kira_interactive" path = "examples/kira/interactive.rs" required-features = ["kira"] -# [[example]] -# name = "oddio_noise" -# path = "examples/oddio/noise.rs" -# required-features = ["oddio"] \ No newline at end of file +[[example]] +name = "oddio_noise" +path = "examples/oddio/noise.rs" +required-features = ["oddio"] + +[[example]] +name = "oddio_interactive" +path = "examples/oddio/interactive.rs" +required-features = ["oddio"] + +[[example]] +name = "oddio_controlled" +path = "examples/oddio/controlled.rs" +required-features = ["oddio"] \ No newline at end of file diff --git a/README.md b/README.md index 941ac52..535304d 100644 --- a/README.md +++ b/README.md @@ -20,18 +20,15 @@ or multiplying your DSP graph with a low constant (lower than 1.0). ```rust no_run #![allow(clippy::precedence)] -use bevy_fundsp::prelude::*; use bevy::prelude::*; +use bevy_fundsp::prelude::*; fn main() { App::new() .add_plugins(DefaultPlugins) - .add_plugin(DspPlugin) - .add_startup_system(init_dsp) - .add_startup_system_to_stage( - StartupStage::PostStartup, - play_noise - ) + .add_plugin(DspPlugin::default()) + .add_dsp_source(white_noise, SourceType::Dynamic) + .add_startup_system_to_stage(StartupStage::PostStartup, play_noise) .run(); } @@ -39,23 +36,26 @@ fn white_noise() -> impl AudioUnit32 { white() >> split::() * 0.2 } -fn init_dsp(mut dsp_manager: ResMut) { - dsp_manager.add_graph(white_noise, 30.0); // length is in seconds -} - -fn play_noise(dsp_assets: Res, audio: Res