From 90d67b31c3618a55f22b01b248ecf7bfd22e32c6 Mon Sep 17 00:00:00 2001 From: Roms1383 Date: Fri, 29 Nov 2024 19:29:03 +0700 Subject: [PATCH] :bug: volume default --- crates/audioware/reds/Settings.reds | 2 +- crates/audioware/src/abi/types.rs | 4 ++-- crates/audioware/src/engine/mod.rs | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/audioware/reds/Settings.reds b/crates/audioware/reds/Settings.reds index a0f9b8a72..2c7c8f950 100644 --- a/crates/audioware/reds/Settings.reds +++ b/crates/audioware/reds/Settings.reds @@ -9,7 +9,7 @@ public class AudioSettingsExt { public let startPosition: Float = 0.; public let region: ref; public let loop: Bool = false; - public let volume: Float = 100.; + public let volume: Float = 1.; public let fadeIn: ref; public let panning: Float = 0.5; public let playbackRate: Float = 1.; diff --git a/crates/audioware/src/abi/types.rs b/crates/audioware/src/abi/types.rs index f0dff2c29..cd3efdbb7 100644 --- a/crates/audioware/src/abi/types.rs +++ b/crates/audioware/src/abi/types.rs @@ -47,7 +47,7 @@ impl Default for AudioSettingsExt { start_position: 0., region: Ref::default(), r#loop: false, - volume: 100., + volume: 1., fade_in: Ref::default(), panning: 0.5, playback_rate: 1., @@ -165,7 +165,7 @@ impl ToSettings for Ref { if r#loop { settings.r#loop = Some(true); } - if volume != 100. { + if volume != 1.0 { settings.volume = Some(volume as f64); } settings.fade_in_tween = fade_in.into_interpolation(); diff --git a/crates/audioware/src/engine/mod.rs b/crates/audioware/src/engine/mod.rs index 98e2224b8..1822a1915 100644 --- a/crates/audioware/src/engine/mod.rs +++ b/crates/audioware/src/engine/mod.rs @@ -1,4 +1,4 @@ -use std::fmt::Debug; +use std::{fmt::Debug, ops::Div}; use audioware_bank::{BankData, Banks, Id, Initialization, InitializationOutcome}; use audioware_core::With; @@ -536,6 +536,8 @@ where } pub fn set_volume(&mut self, setting: CName, value: f64) { + // default volume from game settings is 100. + let value = value.div(100.).clamp(0., 1.); match setting.as_str() { "MasterVolume" => self.manager.main_track().set_volume(value, DEFAULT), "SfxVolume" => self.modulators.sfx_volume.update(value, DEFAULT),