From e06bf236bcb2f49f5821c06721c725948f7025ca Mon Sep 17 00:00:00 2001 From: Pimeng Date: Mon, 20 Jul 2026 22:31:06 +0800 Subject: [PATCH 1/3] fix: apply configured audio volumes --- phira/src/page/offset.rs | 5 ++++- phira/src/page/settings.rs | 3 ++- phira/src/scene/main.rs | 1 + phira/src/scene/song.rs | 2 +- prpr/src/ui.rs | 15 +++++++++++---- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/phira/src/page/offset.rs b/phira/src/page/offset.rs index dcb46ee33..189d903d1 100644 --- a/phira/src/page/offset.rs +++ b/phira/src/page/offset.rs @@ -41,6 +41,7 @@ impl OffsetPage { let cali = audio.create_music( AudioClip::new(load_file("cali.ogg").await?)?, MusicParams { + amplifier: get_data().config.volume_music, loop_mix_time: 0., ..Default::default() }, @@ -179,7 +180,9 @@ impl Page for OffsetPage { if self.cali_last { let g = ui.to_global(ct); self.emitter.emit_at(vec2(g.0, g.1), 0., self.color); - let _ = self.cali_hit.play(PlaySfxParams::default()); + let _ = self.cali_hit.play(PlaySfxParams { + amplifier: config.volume_sfx, + }); } self.cali_last = false; } diff --git a/phira/src/page/settings.rs b/phira/src/page/settings.rs index 3a01bf47b..9fd6f36fe 100644 --- a/phira/src/page/settings.rs +++ b/phira/src/page/settings.rs @@ -19,7 +19,7 @@ use prpr::{ ext::{open_url, poll_future, semi_white, LocalTask, RectExt, SafeTexture}, scene::{request_input, return_input, show_error, show_message, take_input}, task::Task, - ui::{DRectButton, Scroll, Slider, Ui, PREFER_REDUCED_MOTION}, + ui::{DRectButton, Scroll, Slider, Ui, PREFER_REDUCED_MOTION, UI_SFX_VOLUME}, }; use prpr_l10n::{LanguageIdentifier, LANG_IDENTS, LANG_NAMES}; use reqwest::Url; @@ -701,6 +701,7 @@ impl AudioList { return Ok(wt); } if let wt @ Some(_) = self.sfx_slider.touch(touch, t, &mut config.volume_sfx) { + UI_SFX_VOLUME.store(config.volume_sfx.to_bits(), Ordering::Relaxed); return Ok(wt); } let old = config.volume_bgm; diff --git a/phira/src/scene/main.rs b/phira/src/scene/main.rs index 01bdc65a1..0b23e41b4 100644 --- a/phira/src/scene/main.rs +++ b/phira/src/scene/main.rs @@ -116,6 +116,7 @@ impl MainScene { } async fn init() -> Result<()> { + prpr::ui::UI_SFX_VOLUME.store(get_data().config.volume_sfx.to_bits(), Ordering::Relaxed); // init button hitsound macro_rules! load_sfx { ($name:ident, $path:literal) => {{ diff --git a/phira/src/scene/song.rs b/phira/src/scene/song.rs index baf86cbd4..cc6a0532a 100644 --- a/phira/src/scene/song.rs +++ b/phira/src/scene/song.rs @@ -157,7 +157,7 @@ fn create_music(clip: AudioClip) -> Result { it.borrow_mut().create_music( clip, MusicParams { - amplifier: 0.7, + amplifier: get_data().config.volume_music, loop_mix_time: 0., ..Default::default() }, diff --git a/prpr/src/ui.rs b/prpr/src/ui.rs index 51cc7a142..dbd0abfd1 100644 --- a/prpr/src/ui.rs +++ b/prpr/src/ui.rs @@ -47,10 +47,11 @@ use std::{ cell::RefCell, collections::HashMap, ops::Range, - sync::atomic::{AtomicBool, Ordering}, + sync::atomic::{AtomicBool, AtomicU32, Ordering}, }; pub static PREFER_REDUCED_MOTION: AtomicBool = AtomicBool::new(false); +pub static UI_SFX_VOLUME: AtomicU32 = AtomicU32::new(1.0f32.to_bits()); #[derive(Default, Clone, Copy)] pub struct Gravity(u8); @@ -1348,7 +1349,9 @@ thread_local! { pub fn button_hit() { UI_BTN_HITSOUND.with(|it| { if let Some(sfx) = it.borrow_mut().as_mut() { - let _ = sfx.play(PlaySfxParams::default()); + let _ = sfx.play(PlaySfxParams { + amplifier: f32::from_bits(UI_SFX_VOLUME.load(Ordering::Relaxed)), + }); } }); } @@ -1356,7 +1359,9 @@ pub fn button_hit() { pub fn button_hit_large() { UI_BTN_HITSOUND_LARGE.with(|it| { if let Some(sfx) = it.borrow_mut().as_mut() { - let _ = sfx.play(PlaySfxParams::default()); + let _ = sfx.play(PlaySfxParams { + amplifier: f32::from_bits(UI_SFX_VOLUME.load(Ordering::Relaxed)), + }); } }); } @@ -1364,7 +1369,9 @@ pub fn button_hit_large() { pub fn list_switch() { UI_SWITCH_SOUND.with(|it| { if let Some(sfx) = it.borrow_mut().as_mut() { - let _ = sfx.play(PlaySfxParams::default()); + let _ = sfx.play(PlaySfxParams { + amplifier: f32::from_bits(UI_SFX_VOLUME.load(Ordering::Relaxed)), + }); } }); } From 30260afb0f5506c98a31dd22502226039ebada34 Mon Sep 17 00:00:00 2001 From: Pimeng Date: Tue, 21 Jul 2026 17:31:28 +0800 Subject: [PATCH 2/3] fix: apply SFX volume to respack page --- phira/src/page/respack.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phira/src/page/respack.rs b/phira/src/page/respack.rs index 2241fd045..e86fdb2cf 100644 --- a/phira/src/page/respack.rs +++ b/phira/src/page/respack.rs @@ -382,7 +382,9 @@ impl Page for ResPackPage { emitter.emit_at(vec2(cx, line), 0., pack.info.fx_perfect()); } if let Some(sfxs) = &mut self.sfxs { - let _ = sfxs[(irnd % 3) as usize].play(PlaySfxParams::default()); + let _ = sfxs[(irnd % 3) as usize].play(PlaySfxParams { + amplifier: get_data().config.volume_sfx, + }); } self.last_round = irnd; } From f72db59ae6b4f5439378b38d86ea1379cc41d2d7 Mon Sep 17 00:00:00 2001 From: Pimeng Date: Wed, 29 Jul 2026 18:26:21 +0800 Subject: [PATCH 3/3] chore: update volume_music config to setting *0.7 --- phira/src/scene/song.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phira/src/scene/song.rs b/phira/src/scene/song.rs index cc6a0532a..62a911642 100644 --- a/phira/src/scene/song.rs +++ b/phira/src/scene/song.rs @@ -157,7 +157,7 @@ fn create_music(clip: AudioClip) -> Result { it.borrow_mut().create_music( clip, MusicParams { - amplifier: get_data().config.volume_music, + amplifier: get_data().config.volume_music * 0.7, loop_mix_time: 0., ..Default::default() },