Bevy FunDSP

August 17, 2023 · View on GitHub

Bevy tracking CI Crates.io Crates.io docs.rs

A third party Bevy plugin that integrates FunDSP into Bevy.

bevy_fundsp supports integration for bevy_audio, bevy_kira_audio, and bevy_oddio.

WARNING: Lower your volume before testing your sounds!

Remember to lower the volume by passing the settings with DspManager::add_graph_with_settings or multiplying your DSP graph with a low constant (lower than 1.0).

Usage

#![allow(clippy::precedence)]

use {bevy::prelude::*, bevy_fundsp::prelude::*};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins(DspPlugin::default())
        .add_dsp_source(white_noise, SourceType::Dynamic)
        .add_systems(PostStartup, play_noise)
        .run();
}

fn white_noise() -> impl AudioUnit32 {
    white() >> split::<U2>() * 0.2
}

fn play_noise(
    mut commands: Commands,
    mut assets: ResMut<Assets<DspSource>>,
    dsp_manager: Res<DspManager>,
) {
    let source = assets.add(
        dsp_manager
            .get_graph(white_noise)
            .unwrap_or_else(|| panic!("DSP source not found!"))
            .clone(),
    );
    commands.spawn(AudioSourceBundle {
        source,
        ..default()
    });
}

Compatibility

bevy_fundspbevybevy_kira_audiobevy_oddiofundsp
bevy_mainmainbevy_mainbevy_mainmain
0.3.00.100.150.40.12
0.2.00.90.130.30.9
0.1.00.80.110.6

License

bevy_fundsp is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Acknowledgement

I'd like to say thanks to the authors of FunDSP and Bevy for making this plugin possible.

Ko-fi

ko-fi