From cad6b3028436198ddd1525ca02c42048def2713e Mon Sep 17 00:00:00 2001 From: RedTrainer97 Date: Fri, 24 Mar 2017 17:47:53 +0100 Subject: [PATCH] Merged commit --- src/audio_core/hle/dsp.cpp | 15 +++++++++++++-- src/citra/config.cpp | 1 + src/citra/default_ini.h | 4 ++++ src/citra_qt/config.cpp | 2 ++ src/citra_qt/configure_audio.cpp | 3 +++ src/citra_qt/configure_audio.ui | 27 +++++++++++++++++++++++++++ src/core/settings.h | 1 + 7 files changed, 51 insertions(+), 2 deletions(-) diff --git a/src/audio_core/hle/dsp.cpp b/src/audio_core/hle/dsp.cpp index 31421fdc6..24a8d90af 100644 --- a/src/audio_core/hle/dsp.cpp +++ b/src/audio_core/hle/dsp.cpp @@ -10,6 +10,7 @@ #include "audio_core/hle/source.h" #include "audio_core/sink.h" #include "audio_core/time_stretch.h" +#include "core/settings.h" namespace DSP { namespace HLE { @@ -89,6 +90,15 @@ static bool perform_time_stretching = true; static std::unique_ptr sink; static AudioCore::TimeStretcher time_stretcher; +static StereoFrame16 ChangeVolume(const StereoFrame16& frame) { + StereoFrame16 new_frame = StereoFrame16(); + for (int i = 0; i < frame.size(); i++) { + new_frame[i][0] = frame[i][0] * Settings::values.volume; + new_frame[i][1] = frame[i][1] * Settings::values.volume; + } + return new_frame; +} + static void FlushResidualStretcherAudio() { time_stretcher.Flush(); while (true) { @@ -100,8 +110,9 @@ static void FlushResidualStretcherAudio() { } static void OutputCurrentFrame(const StereoFrame16& frame) { + StereoFrame16 new_frame = ChangeVolume(frame); if (perform_time_stretching) { - time_stretcher.AddSamples(&frame[0][0], frame.size()); + time_stretcher.AddSamples(&new_frame[0][0], frame.size()); std::vector stretched_samples = time_stretcher.Process(sink->SamplesInQueue()); sink->EnqueueSamples(stretched_samples.data(), stretched_samples.size() / 2); } else { @@ -112,7 +123,7 @@ static void OutputCurrentFrame(const StereoFrame16& frame) { return; } - sink->EnqueueSamples(&frame[0][0], frame.size()); + sink->EnqueueSamples(&new_frame[0][0], frame.size()); } } diff --git a/src/citra/config.cpp b/src/citra/config.cpp index ef1229912..e5e6d216a 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -100,6 +100,7 @@ void Config::ReadValues() { Settings::values.enable_audio_stretching = sdl2_config->GetBoolean("Audio", "enable_audio_stretching", true); Settings::values.audio_device_id = sdl2_config->Get("Audio", "output_device", "auto"); + Settings::values.volume = sdl2_config->GetReal("Audio", "volume", 1); // Data Storage Settings::values.use_virtual_sd = diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index af9f7aa2a..5f5dabd52 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -108,6 +108,10 @@ enable_audio_stretching = # auto (default): Auto-select output_device = +# Output volume. +# 1.0 (default): 100%, 0.0; mute +volume = + [Data Storage] # Whether to create a virtual SD card. # 1 (default): Yes, 0: No diff --git a/src/citra_qt/config.cpp b/src/citra_qt/config.cpp index 6ccfa1577..b9ec351fc 100644 --- a/src/citra_qt/config.cpp +++ b/src/citra_qt/config.cpp @@ -87,6 +87,7 @@ void Config::ReadValues() { qt_config->value("enable_audio_stretching", true).toBool(); Settings::values.audio_device_id = qt_config->value("output_device", "auto").toString().toStdString(); + Settings::values.volume = qt_config->value("volume", 1).toFloat(); qt_config->endGroup(); using namespace Service::CAM; @@ -213,6 +214,7 @@ void Config::SaveValues() { qt_config->setValue("output_engine", QString::fromStdString(Settings::values.sink_id)); qt_config->setValue("enable_audio_stretching", Settings::values.enable_audio_stretching); qt_config->setValue("output_device", QString::fromStdString(Settings::values.audio_device_id)); + qt_config->setValue("volume", Settings::values.volume); qt_config->endGroup(); using namespace Service::CAM; diff --git a/src/citra_qt/configure_audio.cpp b/src/citra_qt/configure_audio.cpp index 3ddcf9232..0247cac1d 100644 --- a/src/citra_qt/configure_audio.cpp +++ b/src/citra_qt/configure_audio.cpp @@ -51,6 +51,7 @@ void ConfigureAudio::setConfiguration() { } } ui->audio_device_combo_box->setCurrentIndex(new_device_index); + ui->volume_slider->setValue(Settings::values.volume * ui->volume_slider->maximum()); } void ConfigureAudio::applyConfiguration() { @@ -61,6 +62,8 @@ void ConfigureAudio::applyConfiguration() { Settings::values.audio_device_id = ui->audio_device_combo_box->itemText(ui->audio_device_combo_box->currentIndex()) .toStdString(); + Settings::values.volume = (float)ui->volume_slider->value() / ui->volume_slider->maximum(); + Settings::Apply(); } diff --git a/src/citra_qt/configure_audio.ui b/src/citra_qt/configure_audio.ui index dd870eb61..b72def8a6 100644 --- a/src/citra_qt/configure_audio.ui +++ b/src/citra_qt/configure_audio.ui @@ -46,6 +46,33 @@ + + + + + + + + + + Volume: + + + + + + + 1023 + + + 1 + + + 0 + + + Qt::Horizontal + diff --git a/src/core/settings.h b/src/core/settings.h index d1a9f0da8..713696e7a 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -110,6 +110,7 @@ struct Values { std::string sink_id; bool enable_audio_stretching; std::string audio_device_id; + float volume; // Camera std::array camera_name;