Qt/settings: add new audio buffering options

This commit is contained in:
Megamouse 2018-12-27 00:58:27 +01:00 committed by kd-11
parent 48db0430d4
commit 5e3311746c
5 changed files with 144 additions and 7 deletions

View file

@ -5,7 +5,11 @@
"audioDump": "Saves all audio as a raw wave file. If unsure, leave this unchecked.", "audioDump": "Saves all audio as a raw wave file. If unsure, leave this unchecked.",
"convert": "Uses 16-bit audio samples instead of default 32-bit floating point.\nUse with buggy audio drivers if you have no sound or completely broken sound.", "convert": "Uses 16-bit audio samples instead of default 32-bit floating point.\nUse with buggy audio drivers if you have no sound or completely broken sound.",
"downmix": "Uses stereo audio output instead of default 7.1 surround sound.\nUse with stereo audio devices. Disable it only if you are using a surround sound audio system.", "downmix": "Uses stereo audio output instead of default 7.1 surround sound.\nUse with stereo audio devices. Disable it only if you are using a surround sound audio system.",
"masterVolume": "Controls the overall volume of the emulation.\nValues above 100% might reduce the audio quality." "masterVolume": "Controls the overall volume of the emulation.\nValues above 100% might reduce the audio quality.",
"enableBuffering": "Enables the new audio buffering features - if supported by the backend (XAudio2, OpenAL).",
"audioBufferDuration": "Target buffer duration in milliseconds.\nHigher values make the algorithm's job easier, but may introduce noticeable audio latency.",
"enableTimeStretching": "Enables time stretching - requires buffering to be enabled.\nReduces crackle/stutter further, but may cause a very noticeable reduction in audio quality on slower CPUs.",
"timeStretchingThreshold": "Buffer fill level (in percentage) below which time stretching will start."
}, },
"cpu": { "cpu": {
"PPU": { "PPU": {

View file

@ -102,6 +102,10 @@ public:
ConvertTo16Bit, ConvertTo16Bit,
DownmixStereo, DownmixStereo,
MasterVolume, MasterVolume,
EnableBuffering,
AudioBufferDuration,
EnableTimeStretching,
TimeStretchingThreshold,
// Input / Output // Input / Output
PadHandler, PadHandler,
@ -301,11 +305,15 @@ private:
{ ShaderLoadBgBlur, { "Video", "Shader Loading Dialog", "Blur effect strength" } }, { ShaderLoadBgBlur, { "Video", "Shader Loading Dialog", "Blur effect strength" } },
// Audio // Audio
{ AudioRenderer, { "Audio", "Renderer"}}, { AudioRenderer, { "Audio", "Renderer"}},
{ DumpToFile, { "Audio", "Dump to file"}}, { DumpToFile, { "Audio", "Dump to file"}},
{ ConvertTo16Bit, { "Audio", "Convert to 16 bit"}}, { ConvertTo16Bit, { "Audio", "Convert to 16 bit"}},
{ DownmixStereo, { "Audio", "Downmix to Stereo"}}, { DownmixStereo, { "Audio", "Downmix to Stereo"}},
{ MasterVolume, { "Audio", "Master Volume"}}, { MasterVolume, { "Audio", "Master Volume"}},
{ EnableBuffering, { "Audio", "Enable Buffering"}},
{ AudioBufferDuration, { "Audio", "Desired Audio Buffer Duration"}},
{ EnableTimeStretching, { "Audio", "Enable Time Stretching"}},
{ TimeStretchingThreshold, { "Audio", "Time Stretching Threshold"}},
// Input / Output // Input / Output
{ PadHandler, { "Input/Output", "Pad"}}, { PadHandler, { "Input/Output", "Pad"}},

View file

@ -711,6 +711,25 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
// / ____ \ |_| | (_| | | (_) | | | (_| | |_) | // / ____ \ |_| | (_| | | (_) | | | (_| | |_) |
// /_/ \_\__,_|\__,_|_|\___/ |_|\__,_|_.__/ // /_/ \_\__,_|\__,_|_|\___/ |_|\__,_|_.__/
auto EnableTimeStretchingOptions = [this](bool enabled)
{
ui->timeStretchingThresholdLabel->setEnabled(enabled);
ui->timeStretchingThreshold->setEnabled(enabled);
};
auto EnableBufferingOptions = [this, EnableTimeStretchingOptions](bool enabled)
{
ui->audioBufferDuration->setEnabled(enabled);
ui->audioBufferDurationLabel->setEnabled(enabled);
ui->enableTimeStretching->setEnabled(enabled);
EnableTimeStretchingOptions(enabled && ui->enableTimeStretching->isChecked());
};
auto EnableBuffering = [this, EnableBufferingOptions](const QString& text)
{
const bool enabled = text == "XAudio2" || text == "OpenAL";
ui->enableBuffering->setEnabled(enabled);
EnableBufferingOptions(enabled && ui->enableBuffering->isChecked());
};
// Comboboxes // Comboboxes
xemu_settings->EnhanceComboBox(ui->audioOutBox, emu_settings::AudioRenderer); xemu_settings->EnhanceComboBox(ui->audioOutBox, emu_settings::AudioRenderer);
@ -721,6 +740,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
#endif #endif
// Change displayed backend names // Change displayed backend names
ui->audioOutBox->setItemText(ui->renderBox->findData("Null"), tr("Disable Audio Output")); ui->audioOutBox->setItemText(ui->renderBox->findData("Null"), tr("Disable Audio Output"));
connect(ui->audioOutBox, &QComboBox::currentTextChanged, EnableBuffering);
// Checkboxes // Checkboxes
@ -733,11 +753,27 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> guiSettings, std:
xemu_settings->EnhanceCheckBox(ui->downmix, emu_settings::DownmixStereo); xemu_settings->EnhanceCheckBox(ui->downmix, emu_settings::DownmixStereo);
SubscribeTooltip(ui->downmix, json_audio["downmix"].toString()); SubscribeTooltip(ui->downmix, json_audio["downmix"].toString());
xemu_settings->EnhanceCheckBox(ui->enableBuffering, emu_settings::EnableBuffering);
SubscribeTooltip(ui->enableBuffering, json_audio["enableBuffering"].toString());
connect(ui->enableBuffering, &QCheckBox::clicked, EnableBufferingOptions);
xemu_settings->EnhanceCheckBox(ui->enableTimeStretching, emu_settings::EnableTimeStretching);
SubscribeTooltip(ui->enableTimeStretching, json_audio["enableTimeStretching"].toString());
connect(ui->enableTimeStretching, &QCheckBox::clicked, EnableTimeStretchingOptions);
EnableBuffering(ui->audioOutBox->currentText());
// Sliders // Sliders
EnhanceSlider(emu_settings::MasterVolume, ui->masterVolume, ui->masterVolumeLabel, tr("Master: %0 %")); EnhanceSlider(emu_settings::MasterVolume, ui->masterVolume, ui->masterVolumeLabel, tr("Master: %0 %"));
SubscribeTooltip(ui->masterVolume, json_audio["masterVolume"].toString()); SubscribeTooltip(ui->masterVolume, json_audio["masterVolume"].toString());
EnhanceSlider(emu_settings::AudioBufferDuration, ui->audioBufferDuration, ui->audioBufferDurationLabel, tr("Audio Buffer Duration: %0 ms"));
SubscribeTooltip({ ui->audioBufferDuration, ui->audioBufferDurationLabel }, json_audio["audioBufferDuration"].toString());
EnhanceSlider(emu_settings::TimeStretchingThreshold, ui->timeStretchingThreshold, ui->timeStretchingThresholdLabel, tr("Time Stretching Threshold: %0 %"));
SubscribeTooltip({ ui->timeStretchingThreshold, ui->timeStretchingThresholdLabel }, json_audio["timeStretchingThreshold"].toString());
// _____ __ ____ _______ _ // _____ __ ____ _______ _
// |_ _| / / / __ \ |__ __| | | // |_ _| / / / __ \ |__ __| | |
// | | / / | | | | | | __ _| |__ // | | / / | | | | | | __ _| |__
@ -1435,6 +1471,14 @@ void settings_dialog::SubscribeTooltip(QObject* object, const QString& tooltip)
object->installEventFilter(this); object->installEventFilter(this);
} }
void settings_dialog::SubscribeTooltip(QList<QObject*> objects, const QString& tooltip)
{
for (auto obj : objects)
{
SubscribeTooltip(obj, tooltip);
}
}
// Thanks Dolphin // Thanks Dolphin
bool settings_dialog::eventFilter(QObject* object, QEvent* event) bool settings_dialog::eventFilter(QObject* object, QEvent* event)
{ {

View file

@ -58,5 +58,6 @@ private:
QHash<QObject*, QString> m_descriptions; QHash<QObject*, QString> m_descriptions;
void SubscribeDescription(QLabel* description); void SubscribeDescription(QLabel* description);
void SubscribeTooltip(QObject* object, const QString& tooltip); void SubscribeTooltip(QObject* object, const QString& tooltip);
void SubscribeTooltip(QList<QObject*> objects, const QString& tooltip);
bool eventFilter(QObject* object, QEvent* event) override; bool eventFilter(QObject* object, QEvent* event) override;
}; };

View file

@ -823,6 +823,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -878,7 +894,71 @@
</layout> </layout>
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_71"/> <layout class="QVBoxLayout" name="verticalLayout_71">
<item>
<widget class="QGroupBox" name="groupBox_8">
<property name="title">
<string>Buffering</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_75">
<item>
<widget class="QCheckBox" name="enableBuffering">
<property name="text">
<string>Enable Buffering</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="audioBufferDurationLabel">
<property name="text">
<string>Audio Buffer Duration: 0ms</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="audioBufferDuration">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="enableTimeStretching">
<property name="text">
<string>Enable Time Stretching</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="timeStretchingThresholdLabel">
<property name="text">
<string>Time Stretching Threshold: 0%</string>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="timeStretchingThreshold">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksBelow</enum>
</property>
<property name="tickInterval">
<number>10</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>