Store and update PannerStrategy
directly in config.
This commit is contained in:
parent
6b4daf5764
commit
58e2c9b860
|
@ -63,7 +63,9 @@ fn rotate_listener(time: Res<Time>, mut query: Query<(&mut RotationTimer, &mut T
|
|||
fn main() {
|
||||
App::new()
|
||||
.add_plugins(DefaultPlugins)
|
||||
.insert_resource(SynthizerConfig { hrtf: true })
|
||||
.insert_resource(SynthizerConfig {
|
||||
default_panner_strategy: bevy_synthizer::syz::PannerStrategy::Hrtf,
|
||||
})
|
||||
.add_plugin(SynthizerPlugin)
|
||||
.add_system(bevy::input::system::exit_on_esc_system)
|
||||
.init_resource::<AssetHandles>()
|
||||
|
|
27
src/lib.rs
27
src/lib.rs
|
@ -329,9 +329,17 @@ fn remove_sound(mut last_buffer: ResMut<LastBuffer>, removed: RemovedComponents<
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct SynthizerConfig {
|
||||
pub hrtf: bool,
|
||||
pub default_panner_strategy: syz::PannerStrategy,
|
||||
}
|
||||
|
||||
impl Default for SynthizerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
default_panner_strategy: syz::PannerStrategy::Stereo,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SynthizerPlugin;
|
||||
|
@ -344,17 +352,10 @@ impl Plugin for SynthizerPlugin {
|
|||
app.insert_resource(SynthizerConfig::default());
|
||||
}
|
||||
let config = *app.world.get_resource::<SynthizerConfig>().unwrap();
|
||||
if config.hrtf {
|
||||
context
|
||||
.default_panner_strategy()
|
||||
.set(syz::PannerStrategy::Hrtf)
|
||||
.expect("Failed to set panner strategy");
|
||||
} else {
|
||||
context
|
||||
.default_panner_strategy()
|
||||
.set(syz::PannerStrategy::Stereo)
|
||||
.expect("Failed to set panner strategy");
|
||||
}
|
||||
context
|
||||
.default_panner_strategy()
|
||||
.set(config.default_panner_strategy)
|
||||
.expect("Failed to set panner strategy");
|
||||
app.add_asset::<Buffer>()
|
||||
.init_asset_loader::<BufferAssetLoader>()
|
||||
.register_type::<Listener>()
|
||||
|
|
Loading…
Reference in New Issue
Block a user