Merged commit

This commit is contained in:
RedTrainer97 2017-03-28 16:13:20 +02:00
commit d78c87e3db
7 changed files with 51 additions and 2 deletions

View File

@ -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<AudioCore::Sink> 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<s16> 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());
}
}

View File

@ -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 =

View File

@ -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

View File

@ -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;

View File

@ -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();
}

View File

@ -46,6 +46,33 @@
</item>
<item>
<widget class="QComboBox" name="audio_device_combo_box">
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Volume:</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="volume_slider">
<property name="maximum">
<number>1023</number>
</property>
<property name="pageStep">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>

View File

@ -110,6 +110,7 @@ struct Values {
std::string sink_id;
bool enable_audio_stretching;
std::string audio_device_id;
float volume;
// Camera
std::array<std::string, Service::CAM::NumCameras> camera_name;