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