Skip to content

Commit

Permalink
🐛 audio settings ext
Browse files Browse the repository at this point in the history
previously multiple settings would only be taken into account if different from default
  • Loading branch information
Roms1383 committed Dec 8, 2024
1 parent b525868 commit d0171d3
Showing 1 changed file with 14 additions and 21 deletions.
35 changes: 14 additions & 21 deletions crates/audioware/src/abi/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,28 +157,21 @@ impl ToSettings for Ref<AudioSettingsExt> {
playback_rate,
affected_by_time_dilation,
} = unsafe { self.fields() }?.clone();
let mut settings = Settings::default();
if start_position != 0.0 {
settings.start_position = Some(Duration::from_secs_f32(start_position));
}
settings.region = region.into_region();
if r#loop {
settings.r#loop = Some(true);
}
if volume != 1.0 {
settings.volume = Some(volume as f64);
}
settings.fade_in_tween = fade_in.into_interpolation();
if panning != 0.5 {
settings.panning = Some(panning as f64);
}
if playback_rate != 1.0 {
settings.playback_rate = Some(kira::sound::PlaybackRate::Factor(playback_rate as f64));
}
if !affected_by_time_dilation {
settings.affected_by_time_dilation = Some(false);
if let Err(e) = Duration::try_from_secs_f32(start_position) {
fails!("invalid start position: {e}");
return None;
}
Some(settings)
Some(Settings {
start_time: Default::default(),
start_position: Some(Duration::from_secs_f32(start_position)),
region: region.into_region(),
r#loop: Some(r#loop),
volume: Some(volume as f64),
fade_in_tween: fade_in.into_interpolation(),
panning: Some(panning as f64),
playback_rate: Some(kira::sound::PlaybackRate::Factor(playback_rate as f64)),
affected_by_time_dilation: Some(affected_by_time_dilation),
})
}
}

Expand Down

0 comments on commit d0171d3

Please sign in to comment.