From 386cd45f07b83824fc539f8a72429ebf73f5daf4 Mon Sep 17 00:00:00 2001 From: ameerj <52414509+ameerj@users.noreply.github.com> Date: Thu, 8 Jul 2021 20:58:38 -0400 Subject: [PATCH] configure_audio: Use u8 for volume value --- src/common/settings.cpp | 2 +- src/common/settings.h | 2 +- src/yuzu/configuration/configure_audio.cpp | 13 ++++++------- src/yuzu_cmd/default_ini.h | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 0061e29cc..c56d14b81 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp @@ -103,7 +103,7 @@ float Volume() { if (values.audio_muted) { return 0.0f; } - return values.volume.GetValue(); + return values.volume.GetValue() / 100.0f; } void RestoreGlobalState(bool is_powered_on) { diff --git a/src/common/settings.h b/src/common/settings.h index bf83186f5..5305f1ed8 100644 --- a/src/common/settings.h +++ b/src/common/settings.h @@ -278,7 +278,7 @@ struct Values { BasicSetting sink_id{"auto", "output_engine"}; BasicSetting audio_muted{false, "audio_muted"}; Setting enable_audio_stretching{true, "enable_audio_stretching"}; - Setting volume{1.0f, "volume"}; + Setting volume{100, "volume"}; // Core Setting use_multi_core{true, "use_multi_core"}; diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 5aba1a3b2..d8ba939d2 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp @@ -47,7 +47,8 @@ void ConfigureAudio::SetConfiguration() { SetAudioDeviceFromDeviceID(); - ui->volume_slider->setValue(Settings::values.volume.GetValue() * ui->volume_slider->maximum()); + const auto volume_value = Settings::values.volume.GetValue() * ui->volume_slider->maximum(); + ui->volume_slider->setValue(volume_value / 100); ui->toggle_audio_stretching->setChecked(Settings::values.enable_audio_stretching.GetValue()); @@ -112,18 +113,16 @@ void ConfigureAudio::ApplyConfiguration() { // Guard if during game and set to game-specific value if (Settings::values.volume.UsingGlobal()) { - Settings::values.volume.SetValue( - static_cast(ui->volume_slider->sliderPosition()) / - ui->volume_slider->maximum()); + const s32 volume = ui->volume_slider->sliderPosition() / ui->volume_slider->maximum(); + Settings::values.volume.SetValue(static_cast(100 * volume)); } } else { if (ui->volume_combo_box->currentIndex() == 0) { Settings::values.volume.SetGlobal(true); } else { Settings::values.volume.SetGlobal(false); - Settings::values.volume.SetValue( - static_cast(ui->volume_slider->sliderPosition()) / - ui->volume_slider->maximum()); + const s32 volume = ui->volume_slider->sliderPosition() / ui->volume_slider->maximum(); + Settings::values.volume.SetValue(static_cast(100 * volume)); } } } diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h index cc9850aad..d2a7cd024 100644 --- a/src/yuzu_cmd/default_ini.h +++ b/src/yuzu_cmd/default_ini.h @@ -281,7 +281,7 @@ enable_audio_stretching = output_device = # Output volume. -# 1.0 (default): 100%, 0.0; mute +# 100 (default): 100%, 0; mute volume = [Data Storage]