Compare commits
2 Commits
0f4aa54612
...
298012455a
Author | SHA1 | Date | |
---|---|---|---|
298012455a | |||
b60183c448 |
35
src/lib.rs
35
src/lib.rs
|
@ -130,7 +130,7 @@ pub struct Sound {
|
|||
pub paused: bool,
|
||||
pub restart: bool,
|
||||
#[reflect(ignore)]
|
||||
pub generator: Option<syz::BufferGenerator>,
|
||||
pub generator: Option<syz::Generator>,
|
||||
}
|
||||
|
||||
impl Default for Sound {
|
||||
|
@ -194,7 +194,6 @@ fn update_listener(
|
|||
fn add_source_handle(
|
||||
context: Res<syz::Context>,
|
||||
mut query: Query<(
|
||||
Entity,
|
||||
&mut Source,
|
||||
Option<&PannerStrategy>,
|
||||
Option<&GlobalTransform>,
|
||||
|
@ -202,7 +201,7 @@ fn add_source_handle(
|
|||
Option<&ScalarPan>,
|
||||
)>,
|
||||
) {
|
||||
for (entity, mut source, panner_strategy, transform, angular_pan, scalar_pan) in &mut query {
|
||||
for (mut source, panner_strategy, transform, angular_pan, scalar_pan) in &mut query {
|
||||
if source.handle.is_none() {
|
||||
let panner_strategy = panner_strategy.cloned().unwrap_or_default();
|
||||
let handle: syz::Source = if let Some(transform) = transform {
|
||||
|
@ -285,7 +284,7 @@ fn add_generator(
|
|||
handle
|
||||
.add_generator(&generator)
|
||||
.expect("Unable to add generator");
|
||||
sound.generator = Some(generator);
|
||||
sound.generator = Some(generator.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +356,6 @@ fn change_panner_strategy(
|
|||
fn update_source_properties(
|
||||
context: Res<syz::Context>,
|
||||
mut query: Query<(
|
||||
Entity,
|
||||
&mut Source,
|
||||
Option<&DistanceModel>,
|
||||
Option<&DistanceRef>,
|
||||
|
@ -371,7 +369,6 @@ fn update_source_properties(
|
|||
)>,
|
||||
) {
|
||||
for (
|
||||
entity,
|
||||
mut source,
|
||||
distance_model,
|
||||
distance_ref,
|
||||
|
@ -503,10 +500,15 @@ fn update_sound_properties(mut query: Query<&mut Sound>) {
|
|||
assert!(pitch > 0. && pitch <= 2.);
|
||||
if sound.restart {
|
||||
if let Some(generator) = sound.generator.as_mut() {
|
||||
generator
|
||||
.playback_position()
|
||||
.set(0.)
|
||||
.expect("Failed to restart");
|
||||
if let Some(generator) = generator
|
||||
.cast_to::<syz::BufferGenerator>()
|
||||
.expect("Failed to cast")
|
||||
{
|
||||
generator
|
||||
.playback_position()
|
||||
.set(0.)
|
||||
.expect("Failed to restart");
|
||||
}
|
||||
}
|
||||
sound.restart = false;
|
||||
}
|
||||
|
@ -516,10 +518,15 @@ fn update_sound_properties(mut query: Query<&mut Sound>) {
|
|||
.pitch_bend()
|
||||
.set(pitch)
|
||||
.expect("Failed to set pitch");
|
||||
generator
|
||||
.looping()
|
||||
.set(looping)
|
||||
.expect("Failed to set looping");
|
||||
if let Some(generator) = generator
|
||||
.cast_to::<syz::BufferGenerator>()
|
||||
.expect("Failed to cast")
|
||||
{
|
||||
generator
|
||||
.looping()
|
||||
.set(looping)
|
||||
.expect("Failed to set looping");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user