Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Live update #38

Merged
merged 6 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ libfmod = "2.206.2"
bevy = { version = "0.11.2", default-features = true }
smooth-bevy-cameras = "0.9.0"

[features]
default = []
live-update = []

[[example]]
name = "minimal"

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ FMOD Studio comes with an Examples project. Open it and build the project. Then
You can also configure FMOD Studio to build to a folder you specify.
Run examples with `cargo run --example`. See the source code of the examples for more details.

## Live Update

> Live update is a way of connecting FMOD Studio to your game as it runs,
> allowing you to update and monitor audio content in real time.
>
> <https://www.fmod.com/docs/2.02/studio/editing-during-live-update.html>

To enable live update, you need to enable the `live-update` feature. While you can do so in Cargo.toml, I recommend
to explicitly enable it with the `--features` flag. This way, you won't accidentally include it in your release builds.

```sh
cargo run --example minimal --features live-update
```

## Versioning

| bevy_fmod | Bevy | FMOD (tested version, newer may work) |
Expand Down
16 changes: 10 additions & 6 deletions src/fmod_studio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::path::{Path, PathBuf};

use bevy::ecs::system::Resource;
use bevy::log::{debug, trace};
#[cfg(feature = "live-update")]
use libfmod::ffi::FMOD_STUDIO_INIT_LIVEUPDATE;
use libfmod::ffi::{
FMOD_INIT_3D_RIGHTHANDED, FMOD_STUDIO_INIT_NORMAL, FMOD_STUDIO_LOAD_BANK_NORMAL,
};
Expand Down Expand Up @@ -52,13 +54,15 @@ impl FmodStudio {
fn init_studio() -> Studio {
let studio = Studio::create().expect("Failed to create FMOD studio");

let studio_flags = FMOD_STUDIO_INIT_NORMAL;

#[cfg(feature = "live-update")]
let studio_flags = studio_flags | FMOD_STUDIO_INIT_LIVEUPDATE;

debug!("Initializing FMOD studio with flags: {}", studio_flags);

studio
.initialize(
1024,
FMOD_STUDIO_INIT_NORMAL,
FMOD_INIT_3D_RIGHTHANDED,
None,
)
.initialize(1024, studio_flags, FMOD_INIT_3D_RIGHTHANDED, None)
.expect("Failed to initialize FMOD studio");

studio
Expand Down