configure_audio: Use u8 for volume value

This commit is contained in:
ameerj 2021-07-08 20:58:38 -04:00
parent 5edc96f4a4
commit 386cd45f07
4 changed files with 9 additions and 10 deletions

View file

@ -103,7 +103,7 @@ float Volume() {
if (values.audio_muted) { if (values.audio_muted) {
return 0.0f; return 0.0f;
} }
return values.volume.GetValue(); return values.volume.GetValue() / 100.0f;
} }
void RestoreGlobalState(bool is_powered_on) { void RestoreGlobalState(bool is_powered_on) {

View file

@ -278,7 +278,7 @@ struct Values {
BasicSetting<std::string> sink_id{"auto", "output_engine"}; BasicSetting<std::string> sink_id{"auto", "output_engine"};
BasicSetting<bool> audio_muted{false, "audio_muted"}; BasicSetting<bool> audio_muted{false, "audio_muted"};
Setting<bool> enable_audio_stretching{true, "enable_audio_stretching"}; Setting<bool> enable_audio_stretching{true, "enable_audio_stretching"};
Setting<float> volume{1.0f, "volume"}; Setting<u8> volume{100, "volume"};
// Core // Core
Setting<bool> use_multi_core{true, "use_multi_core"}; Setting<bool> use_multi_core{true, "use_multi_core"};

View file

@ -47,7 +47,8 @@ void ConfigureAudio::SetConfiguration() {
SetAudioDeviceFromDeviceID(); 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()); 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 // Guard if during game and set to game-specific value
if (Settings::values.volume.UsingGlobal()) { if (Settings::values.volume.UsingGlobal()) {
Settings::values.volume.SetValue( const s32 volume = ui->volume_slider->sliderPosition() / ui->volume_slider->maximum();
static_cast<float>(ui->volume_slider->sliderPosition()) / Settings::values.volume.SetValue(static_cast<u8>(100 * volume));
ui->volume_slider->maximum());
} }
} else { } else {
if (ui->volume_combo_box->currentIndex() == 0) { if (ui->volume_combo_box->currentIndex() == 0) {
Settings::values.volume.SetGlobal(true); Settings::values.volume.SetGlobal(true);
} else { } else {
Settings::values.volume.SetGlobal(false); Settings::values.volume.SetGlobal(false);
Settings::values.volume.SetValue( const s32 volume = ui->volume_slider->sliderPosition() / ui->volume_slider->maximum();
static_cast<float>(ui->volume_slider->sliderPosition()) / Settings::values.volume.SetValue(static_cast<u8>(100 * volume));
ui->volume_slider->maximum());
} }
} }
} }

View file

@ -281,7 +281,7 @@ enable_audio_stretching =
output_device = output_device =
# Output volume. # Output volume.
# 1.0 (default): 100%, 0.0; mute # 100 (default): 100%, 0; mute
volume = volume =
[Data Storage] [Data Storage]