Skip to content

dtaralla/bevy-rrise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy-rrise

Crates.io MIT/Apache 2.0 Crates.io

What is bevy-rrise?

It's a plugin for the Bevy engine that integrates the Wwise sound engine.

It relies on my Rrise crate for the Rust bindings of Wwise.

PRs welcomed!

Usage

First, take a look at the system requirements for Rrise: they are the same for bevy-rrise!

Definitely take a look at the examples for the best way to learn how this crate works. To be able to compile and run the examples, you should generate the example Wwise project soundbanks first (located in examples/WwiseProject).

Examples also show how you can use the rrise_headers::rr auto-generated module to get your events, busses etc defined as Rust constants (generated from the soundbank definition files). More info here.

To start using the plugin, just add it to your Bevy app. That's it, you can now spawn RrEmitter components, RrEmitterBundles or RrDynamicEmitterBundles!

// ... 'use' directives...

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        // Use Rrise with default settings 
        .add_plugin(RrisePlugin::default())
        .add_startup_system(setup_scene)
        .add_system(update)
        .run();
}

fn setup_scene(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<StandardMaterial>>,
) {
    // Load soundbank containing our PlayHelloWorld event structure and media
    if let Err(akr) = load_bank_by_name("TheBank.bnk") {
        panic!("Couldn't load TheBank: {}", akr);
    }

    // Setup mesh audio emitter
    commands
        .spawn(PbrBundle {
            mesh: meshes.add(Mesh::from(shape::Icosphere::default())),
            material: materials.add(Color::RED.into()),
            ..default()
        })
        .with_children(|parent| {
            // Attach dynamic emitter in the center of the parent
            parent.spawn(
                RrDynamicEmitterBundle::new(Vec3::default())
                    .with_event("PlayHelloWorld", true),
            );
        });

    // ... setup rest of scene
}

fn update(/* ... */) {
    // ... update scene
}

RrDynamicEmitterBundle (or RrEmitter components sitting on entities with a TransformBundle) will get their transform updates forwarded to Wwise automatically.

If they have a bevy:core::Name component, emitters will send their entity's name to Wwise for easy monitoring.

Before you can hear anything, make sure you generate your soundbanks from the Wwise authoring tool and place the resulting assets where bevy-rrise can find them. Again, look at how the provided examples are configured to get started 😉

Don't hesitate to enable logging at the debug level for bevy-rrise to get an idea of what's happening under the hood! It can also help diagnose why your sounds might not be working. For instance, bevy-rrise will output where it expects your bank files to be.

If you encounter an error about the Init.bnk that couldn't be loaded, enable debug-level logging and check you placed your .bnk files in the folder where bevy-rrise expect them to be based on your configuration.

Plugin Configuration

Starting in v0.2.1 (and Bevy 0.9), configuration is more ergonomic than ever! Start from RrisePlugin::default(), then use a chain of any of the with_*_settings(...) functions to customize the sound engine & plugin behaviors:

  • with_plugin_settings(RriseBasicSettings)
  • with_mem_settings(AkMemSettings)
  • with_music_settings(AkMusicSettings)
  • with_engine_settings(AkInitSettings)
  • with_stream_settings(AkStreamMgrSettings)
  • with_dev_settings(AkDeviceSettings)
  • with_platform_settings(AkPlatformInitSettings)
  • with_comms_settings(AkCommSettings)

All *Settings classes have detailed documentation for all their members and implement the Default trait, for maximum ergonomics when you want to override just a handful of values.

Bevy Compat Table

Bevy rrise bevy-rrise
0.7 0.2 0.1
0.8 0.2 0.2
0.9 0.2 0.2.1

Legal stuff

Wwise and the Wwise logo are trademarks of Audiokinetic Inc., registered in the U.S. and other countries.

This project is in no way affiliated to Audiokinetic.

You still need a licensed version of Wwise installed to compile and run this project. You need a valid Wwise license to distribute any project based on this crate.

About

A Wwise Bevy integration

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages