2017-06-21 08:27:21 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-06-21 08:27:21 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Settings/AudioPane.h"
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QComboBox>
|
2019-03-21 13:25:57 +00:00
|
|
|
#include <QFontMetrics>
|
2017-06-21 08:27:21 +00:00
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QGroupBox>
|
2021-05-20 18:25:05 +00:00
|
|
|
#include <QHBoxLayout>
|
2017-06-21 08:27:21 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QRadioButton>
|
|
|
|
#include <QSlider>
|
|
|
|
#include <QSpacerItem>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
#include "AudioCommon/AudioCommon.h"
|
2019-03-18 11:22:27 +00:00
|
|
|
#include "AudioCommon/Enums.h"
|
2018-02-10 20:03:27 +00:00
|
|
|
#include "AudioCommon/WASAPIStream.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-07-19 22:10:37 +00:00
|
|
|
#include "Core/Config/MainSettings.h"
|
2017-09-04 18:12:13 +00:00
|
|
|
#include "Core/Core.h"
|
2022-10-13 19:01:55 +00:00
|
|
|
#include "Core/System.h"
|
2018-05-28 01:48:04 +00:00
|
|
|
|
2018-07-06 22:40:15 +00:00
|
|
|
#include "DolphinQt/Config/SettingsWindow.h"
|
|
|
|
#include "DolphinQt/Settings.h"
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
AudioPane::AudioPane()
|
|
|
|
{
|
2017-11-07 09:55:44 +00:00
|
|
|
CheckNeedForLatencyControl();
|
2017-06-21 08:27:21 +00:00
|
|
|
CreateWidgets();
|
|
|
|
LoadSettings();
|
|
|
|
ConnectWidgets();
|
|
|
|
|
|
|
|
connect(&Settings::Instance(), &Settings::VolumeChanged, this, &AudioPane::OnVolumeChanged);
|
2022-08-08 01:25:19 +00:00
|
|
|
connect(&Settings::Instance(), &Settings::EmulationStateChanged, this, [this](Core::State state) {
|
|
|
|
OnEmulationStateChanged(state != Core::State::Uninitialized);
|
|
|
|
});
|
2019-10-26 15:50:54 +00:00
|
|
|
|
|
|
|
OnEmulationStateChanged(Core::GetState() != Core::State::Uninitialized);
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::CreateWidgets()
|
|
|
|
{
|
2017-11-02 13:32:16 +00:00
|
|
|
auto* dsp_box = new QGroupBox(tr("DSP Emulation Engine"));
|
2017-06-21 08:27:21 +00:00
|
|
|
auto* dsp_layout = new QVBoxLayout;
|
|
|
|
|
|
|
|
dsp_box->setLayout(dsp_layout);
|
2021-07-23 00:11:32 +00:00
|
|
|
m_dsp_hle = new QRadioButton(tr("DSP HLE (recommended)"));
|
|
|
|
m_dsp_lle = new QRadioButton(tr("DSP LLE Recompiler (slow)"));
|
|
|
|
m_dsp_interpreter = new QRadioButton(tr("DSP LLE Interpreter (very slow)"));
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
dsp_layout->addStretch(1);
|
|
|
|
dsp_layout->addWidget(m_dsp_hle);
|
|
|
|
dsp_layout->addWidget(m_dsp_lle);
|
|
|
|
dsp_layout->addWidget(m_dsp_interpreter);
|
|
|
|
dsp_layout->addStretch(1);
|
|
|
|
|
|
|
|
auto* volume_box = new QGroupBox(tr("Volume"));
|
|
|
|
auto* volume_layout = new QVBoxLayout;
|
|
|
|
m_volume_slider = new QSlider;
|
|
|
|
m_volume_indicator = new QLabel();
|
|
|
|
|
|
|
|
volume_box->setLayout(volume_layout);
|
|
|
|
|
|
|
|
m_volume_slider->setMinimum(0);
|
|
|
|
m_volume_slider->setMaximum(100);
|
|
|
|
|
|
|
|
m_volume_indicator->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
2019-03-21 13:25:57 +00:00
|
|
|
m_volume_indicator->setFixedWidth(QFontMetrics(font()).boundingRect(tr("%1 %").arg(100)).width());
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
volume_layout->addWidget(m_volume_slider, 0, Qt::AlignHCenter);
|
|
|
|
volume_layout->addWidget(m_volume_indicator, 0, Qt::AlignHCenter);
|
|
|
|
|
|
|
|
auto* backend_box = new QGroupBox(tr("Backend Settings"));
|
|
|
|
auto* backend_layout = new QFormLayout;
|
|
|
|
backend_box->setLayout(backend_layout);
|
|
|
|
m_backend_label = new QLabel(tr("Audio Backend:"));
|
|
|
|
m_backend_combo = new QComboBox();
|
2017-11-02 13:32:16 +00:00
|
|
|
m_dolby_pro_logic = new QCheckBox(tr("Dolby Pro Logic II Decoder"));
|
2017-06-21 08:27:21 +00:00
|
|
|
|
2017-11-07 09:55:44 +00:00
|
|
|
if (m_latency_control_supported)
|
|
|
|
{
|
|
|
|
m_latency_label = new QLabel(tr("Latency:"));
|
|
|
|
m_latency_spin = new QSpinBox();
|
|
|
|
m_latency_spin->setMinimum(0);
|
|
|
|
m_latency_spin->setMaximum(200);
|
2021-09-08 20:08:43 +00:00
|
|
|
m_latency_spin->setToolTip(
|
|
|
|
tr("Sets the latency in milliseconds. Higher values may reduce audio "
|
|
|
|
"crackling. Certain backends only."));
|
2017-11-07 09:55:44 +00:00
|
|
|
}
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
m_dolby_pro_logic->setToolTip(
|
|
|
|
tr("Enables Dolby Pro Logic II emulation using 5.1 surround. Certain backends only."));
|
|
|
|
|
2019-03-18 11:22:27 +00:00
|
|
|
auto* dolby_quality_layout = new QHBoxLayout;
|
|
|
|
|
|
|
|
m_dolby_quality_label = new QLabel(tr("Decoding Quality:"));
|
|
|
|
|
|
|
|
m_dolby_quality_slider = new QSlider(Qt::Horizontal);
|
|
|
|
m_dolby_quality_slider->setMinimum(0);
|
|
|
|
m_dolby_quality_slider->setMaximum(3);
|
|
|
|
m_dolby_quality_slider->setPageStep(1);
|
|
|
|
m_dolby_quality_slider->setTickPosition(QSlider::TicksBelow);
|
|
|
|
m_dolby_quality_slider->setToolTip(
|
|
|
|
tr("Quality of the DPLII decoder. Audio latency increases with quality."));
|
|
|
|
m_dolby_quality_slider->setTracking(true);
|
|
|
|
|
2019-06-15 11:36:47 +00:00
|
|
|
m_dolby_quality_low_label = new QLabel(GetDPL2QualityLabel(AudioCommon::DPL2Quality::Lowest));
|
2019-03-18 11:22:27 +00:00
|
|
|
m_dolby_quality_highest_label =
|
|
|
|
new QLabel(GetDPL2QualityLabel(AudioCommon::DPL2Quality::Highest));
|
|
|
|
m_dolby_quality_latency_label =
|
|
|
|
new QLabel(GetDPL2ApproximateLatencyLabel(AudioCommon::DPL2Quality::Highest));
|
|
|
|
|
|
|
|
dolby_quality_layout->addWidget(m_dolby_quality_low_label);
|
|
|
|
dolby_quality_layout->addWidget(m_dolby_quality_slider);
|
|
|
|
dolby_quality_layout->addWidget(m_dolby_quality_highest_label);
|
|
|
|
|
2018-06-12 13:45:33 +00:00
|
|
|
backend_layout->setFormAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
backend_layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
2017-06-21 08:27:21 +00:00
|
|
|
backend_layout->addRow(m_backend_label, m_backend_combo);
|
2017-11-07 09:55:44 +00:00
|
|
|
if (m_latency_control_supported)
|
|
|
|
backend_layout->addRow(m_latency_label, m_latency_spin);
|
2018-02-10 20:03:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
m_wasapi_device_label = new QLabel(tr("Device:"));
|
|
|
|
m_wasapi_device_combo = new QComboBox;
|
|
|
|
|
|
|
|
backend_layout->addRow(m_wasapi_device_label, m_wasapi_device_combo);
|
|
|
|
#endif
|
|
|
|
|
2017-06-21 08:27:21 +00:00
|
|
|
backend_layout->addRow(m_dolby_pro_logic);
|
2019-03-18 11:22:27 +00:00
|
|
|
backend_layout->addRow(m_dolby_quality_label);
|
|
|
|
backend_layout->addRow(dolby_quality_layout);
|
|
|
|
backend_layout->addRow(m_dolby_quality_latency_label);
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
auto* stretching_box = new QGroupBox(tr("Audio Stretching Settings"));
|
|
|
|
auto* stretching_layout = new QGridLayout;
|
|
|
|
m_stretching_enable = new QCheckBox(tr("Enable Audio Stretching"));
|
|
|
|
m_stretching_buffer_slider = new QSlider(Qt::Horizontal);
|
|
|
|
m_stretching_buffer_indicator = new QLabel();
|
|
|
|
m_stretching_buffer_label = new QLabel(tr("Buffer Size:"));
|
|
|
|
stretching_box->setLayout(stretching_layout);
|
|
|
|
|
|
|
|
m_stretching_buffer_slider->setMinimum(5);
|
|
|
|
m_stretching_buffer_slider->setMaximum(300);
|
|
|
|
|
|
|
|
m_stretching_enable->setToolTip(tr("Enables stretching of the audio to match emulation speed."));
|
|
|
|
m_stretching_buffer_slider->setToolTip(tr("Size of stretch buffer in milliseconds. "
|
|
|
|
"Values too low may cause audio crackling."));
|
|
|
|
|
|
|
|
stretching_layout->addWidget(m_stretching_enable, 0, 0, 1, -1);
|
|
|
|
stretching_layout->addWidget(m_stretching_buffer_label, 1, 0);
|
|
|
|
stretching_layout->addWidget(m_stretching_buffer_slider, 1, 1);
|
|
|
|
stretching_layout->addWidget(m_stretching_buffer_indicator, 1, 2);
|
|
|
|
|
2018-05-12 21:29:54 +00:00
|
|
|
dsp_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
2021-05-20 18:25:05 +00:00
|
|
|
auto* const main_vbox_layout = new QVBoxLayout;
|
|
|
|
main_vbox_layout->addWidget(dsp_box);
|
|
|
|
main_vbox_layout->addWidget(backend_box);
|
|
|
|
main_vbox_layout->addWidget(stretching_box);
|
|
|
|
|
|
|
|
m_main_layout = new QHBoxLayout;
|
|
|
|
m_main_layout->addLayout(main_vbox_layout);
|
|
|
|
m_main_layout->addWidget(volume_box);
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
setLayout(m_main_layout);
|
2021-05-20 18:25:05 +00:00
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::ConnectWidgets()
|
|
|
|
{
|
2019-07-30 13:35:46 +00:00
|
|
|
connect(m_backend_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
|
|
|
&AudioPane::SaveSettings);
|
2017-06-21 08:27:21 +00:00
|
|
|
connect(m_volume_slider, &QSlider::valueChanged, this, &AudioPane::SaveSettings);
|
2017-11-07 09:55:44 +00:00
|
|
|
if (m_latency_control_supported)
|
|
|
|
{
|
2019-07-30 13:35:46 +00:00
|
|
|
connect(m_latency_spin, qOverload<int>(&QSpinBox::valueChanged), this,
|
2017-11-07 09:55:44 +00:00
|
|
|
&AudioPane::SaveSettings);
|
|
|
|
}
|
2017-06-21 08:27:21 +00:00
|
|
|
connect(m_stretching_buffer_slider, &QSlider::valueChanged, this, &AudioPane::SaveSettings);
|
|
|
|
connect(m_dolby_pro_logic, &QCheckBox::toggled, this, &AudioPane::SaveSettings);
|
2019-03-18 11:22:27 +00:00
|
|
|
connect(m_dolby_quality_slider, &QSlider::valueChanged, this, &AudioPane::SaveSettings);
|
2017-06-21 08:27:21 +00:00
|
|
|
connect(m_stretching_enable, &QCheckBox::toggled, this, &AudioPane::SaveSettings);
|
|
|
|
connect(m_dsp_hle, &QRadioButton::toggled, this, &AudioPane::SaveSettings);
|
|
|
|
connect(m_dsp_lle, &QRadioButton::toggled, this, &AudioPane::SaveSettings);
|
|
|
|
connect(m_dsp_interpreter, &QRadioButton::toggled, this, &AudioPane::SaveSettings);
|
2018-02-10 20:03:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2019-07-30 13:35:46 +00:00
|
|
|
connect(m_wasapi_device_combo, qOverload<int>(&QComboBox::currentIndexChanged), this,
|
2018-02-10 20:03:27 +00:00
|
|
|
&AudioPane::SaveSettings);
|
|
|
|
#endif
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::LoadSettings()
|
|
|
|
{
|
|
|
|
auto& settings = Settings::Instance();
|
|
|
|
|
|
|
|
// DSP
|
2021-10-14 00:29:04 +00:00
|
|
|
if (Config::Get(Config::MAIN_DSP_HLE))
|
2017-06-21 08:27:21 +00:00
|
|
|
{
|
|
|
|
m_dsp_hle->setChecked(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-10-14 00:29:04 +00:00
|
|
|
m_dsp_lle->setChecked(Config::Get(Config::MAIN_DSP_JIT));
|
|
|
|
m_dsp_interpreter->setChecked(!Config::Get(Config::MAIN_DSP_JIT));
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Backend
|
2021-10-14 00:29:04 +00:00
|
|
|
const auto current = Config::Get(Config::MAIN_AUDIO_BACKEND);
|
2019-10-06 18:40:31 +00:00
|
|
|
bool selection_set = false;
|
2017-06-21 08:27:21 +00:00
|
|
|
for (const auto& backend : AudioCommon::GetSoundBackends())
|
|
|
|
{
|
|
|
|
m_backend_combo->addItem(tr(backend.c_str()), QVariant(QString::fromStdString(backend)));
|
|
|
|
if (backend == current)
|
2019-10-06 18:40:31 +00:00
|
|
|
{
|
2017-06-21 08:27:21 +00:00
|
|
|
m_backend_combo->setCurrentIndex(m_backend_combo->count() - 1);
|
2019-10-06 18:40:31 +00:00
|
|
|
selection_set = true;
|
|
|
|
}
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
2019-10-06 18:40:31 +00:00
|
|
|
if (!selection_set)
|
|
|
|
m_backend_combo->setCurrentIndex(-1);
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
OnBackendChanged();
|
|
|
|
|
|
|
|
// Volume
|
|
|
|
OnVolumeChanged(settings.GetVolume());
|
|
|
|
|
|
|
|
// DPL2
|
2021-10-14 00:29:04 +00:00
|
|
|
m_dolby_pro_logic->setChecked(Config::Get(Config::MAIN_DPL2_DECODER));
|
2019-03-18 11:22:27 +00:00
|
|
|
m_dolby_quality_slider->setValue(int(Config::Get(Config::MAIN_DPL2_QUALITY)));
|
|
|
|
m_dolby_quality_latency_label->setText(
|
|
|
|
GetDPL2ApproximateLatencyLabel(Config::Get(Config::MAIN_DPL2_QUALITY)));
|
2020-04-01 20:40:45 +00:00
|
|
|
if (AudioCommon::SupportsDPL2Decoder(current) && !m_dsp_hle->isChecked())
|
2019-03-18 11:22:27 +00:00
|
|
|
{
|
|
|
|
EnableDolbyQualityWidgets(m_dolby_pro_logic->isChecked());
|
|
|
|
}
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
// Latency
|
2017-11-07 09:55:44 +00:00
|
|
|
if (m_latency_control_supported)
|
2021-10-14 00:29:04 +00:00
|
|
|
m_latency_spin->setValue(Config::Get(Config::MAIN_AUDIO_LATENCY));
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
// Stretch
|
2021-10-14 00:29:04 +00:00
|
|
|
m_stretching_enable->setChecked(Config::Get(Config::MAIN_AUDIO_STRETCH));
|
2023-02-18 02:51:41 +00:00
|
|
|
m_stretching_buffer_label->setEnabled(m_stretching_enable->isChecked());
|
2021-10-14 00:29:04 +00:00
|
|
|
m_stretching_buffer_slider->setValue(Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY));
|
2017-06-21 08:27:21 +00:00
|
|
|
m_stretching_buffer_slider->setEnabled(m_stretching_enable->isChecked());
|
2023-02-18 02:51:41 +00:00
|
|
|
m_stretching_buffer_indicator->setEnabled(m_stretching_enable->isChecked());
|
2017-06-21 08:27:21 +00:00
|
|
|
m_stretching_buffer_indicator->setText(tr("%1 ms").arg(m_stretching_buffer_slider->value()));
|
2018-02-10 20:03:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2021-10-14 00:29:04 +00:00
|
|
|
if (Config::Get(Config::MAIN_WASAPI_DEVICE) == "default")
|
2018-02-10 20:03:27 +00:00
|
|
|
{
|
|
|
|
m_wasapi_device_combo->setCurrentIndex(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_wasapi_device_combo->setCurrentText(
|
2021-10-14 00:29:04 +00:00
|
|
|
QString::fromStdString(Config::Get(Config::MAIN_WASAPI_DEVICE)));
|
2018-02-10 20:03:27 +00:00
|
|
|
}
|
|
|
|
#endif
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::SaveSettings()
|
|
|
|
{
|
|
|
|
auto& settings = Settings::Instance();
|
|
|
|
|
|
|
|
// DSP
|
2021-10-14 00:29:04 +00:00
|
|
|
if (Config::Get(Config::MAIN_DSP_HLE) != m_dsp_hle->isChecked() ||
|
|
|
|
Config::Get(Config::MAIN_DSP_JIT) != m_dsp_lle->isChecked())
|
2019-06-15 11:36:47 +00:00
|
|
|
{
|
|
|
|
OnDspChanged();
|
|
|
|
}
|
2018-07-19 22:10:37 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DSP_HLE, m_dsp_hle->isChecked());
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DSP_JIT, m_dsp_lle->isChecked());
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
// Backend
|
|
|
|
const auto selection =
|
|
|
|
m_backend_combo->itemData(m_backend_combo->currentIndex()).toString().toStdString();
|
2021-10-14 00:29:04 +00:00
|
|
|
std::string backend = Config::Get(Config::MAIN_AUDIO_BACKEND);
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
if (selection != backend)
|
|
|
|
{
|
|
|
|
backend = selection;
|
2021-10-14 00:29:04 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_BACKEND, selection);
|
2017-06-21 08:27:21 +00:00
|
|
|
OnBackendChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Volume
|
|
|
|
if (m_volume_slider->value() != settings.GetVolume())
|
|
|
|
{
|
|
|
|
settings.SetVolume(m_volume_slider->value());
|
|
|
|
OnVolumeChanged(settings.GetVolume());
|
|
|
|
}
|
|
|
|
|
|
|
|
// DPL2
|
2021-10-14 00:29:04 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_DPL2_DECODER, m_dolby_pro_logic->isChecked());
|
2019-03-18 11:22:27 +00:00
|
|
|
Config::SetBase(Config::MAIN_DPL2_QUALITY,
|
|
|
|
static_cast<AudioCommon::DPL2Quality>(m_dolby_quality_slider->value()));
|
|
|
|
m_dolby_quality_latency_label->setText(
|
|
|
|
GetDPL2ApproximateLatencyLabel(Config::Get(Config::MAIN_DPL2_QUALITY)));
|
2019-06-15 11:36:47 +00:00
|
|
|
if (AudioCommon::SupportsDPL2Decoder(backend) && !m_dsp_hle->isChecked())
|
2019-03-18 11:22:27 +00:00
|
|
|
{
|
|
|
|
EnableDolbyQualityWidgets(m_dolby_pro_logic->isChecked());
|
|
|
|
}
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
// Latency
|
2017-11-07 09:55:44 +00:00
|
|
|
if (m_latency_control_supported)
|
2021-10-14 00:29:04 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_LATENCY, m_latency_spin->value());
|
2017-06-21 08:27:21 +00:00
|
|
|
|
|
|
|
// Stretch
|
2021-10-14 00:29:04 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_STRETCH, m_stretching_enable->isChecked());
|
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_STRETCH_LATENCY, m_stretching_buffer_slider->value());
|
2017-06-21 08:27:21 +00:00
|
|
|
m_stretching_buffer_label->setEnabled(m_stretching_enable->isChecked());
|
|
|
|
m_stretching_buffer_slider->setEnabled(m_stretching_enable->isChecked());
|
|
|
|
m_stretching_buffer_indicator->setEnabled(m_stretching_enable->isChecked());
|
|
|
|
m_stretching_buffer_indicator->setText(
|
2021-10-14 00:29:04 +00:00
|
|
|
tr("%1 ms").arg(Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY)));
|
2017-06-21 08:27:21 +00:00
|
|
|
|
2018-02-10 20:03:27 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
std::string device = "default";
|
|
|
|
|
|
|
|
if (m_wasapi_device_combo->currentIndex() != 0)
|
|
|
|
device = m_wasapi_device_combo->currentText().toStdString();
|
|
|
|
|
2021-10-14 00:29:04 +00:00
|
|
|
Config::SetBaseOrCurrent(Config::MAIN_WASAPI_DEVICE, device);
|
2018-02-10 20:03:27 +00:00
|
|
|
#endif
|
|
|
|
|
2022-10-13 19:01:55 +00:00
|
|
|
AudioCommon::UpdateSoundStream(Core::System::GetInstance());
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
2019-06-15 11:36:47 +00:00
|
|
|
void AudioPane::OnDspChanged()
|
|
|
|
{
|
2021-10-14 00:29:04 +00:00
|
|
|
const auto backend = Config::Get(Config::MAIN_AUDIO_BACKEND);
|
2019-06-15 11:36:47 +00:00
|
|
|
|
|
|
|
m_dolby_pro_logic->setEnabled(AudioCommon::SupportsDPL2Decoder(backend) &&
|
|
|
|
!m_dsp_hle->isChecked());
|
2020-03-06 20:13:45 +00:00
|
|
|
EnableDolbyQualityWidgets(AudioCommon::SupportsDPL2Decoder(backend) && !m_dsp_hle->isChecked() &&
|
|
|
|
m_dolby_pro_logic->isChecked());
|
2019-06-15 11:36:47 +00:00
|
|
|
}
|
|
|
|
|
2017-06-21 08:27:21 +00:00
|
|
|
void AudioPane::OnBackendChanged()
|
|
|
|
{
|
2021-10-14 00:29:04 +00:00
|
|
|
const auto backend = Config::Get(Config::MAIN_AUDIO_BACKEND);
|
2017-06-21 08:27:21 +00:00
|
|
|
|
2019-06-15 11:36:47 +00:00
|
|
|
m_dolby_pro_logic->setEnabled(AudioCommon::SupportsDPL2Decoder(backend) &&
|
|
|
|
!m_dsp_hle->isChecked());
|
2020-03-06 20:13:45 +00:00
|
|
|
EnableDolbyQualityWidgets(AudioCommon::SupportsDPL2Decoder(backend) && !m_dsp_hle->isChecked() &&
|
|
|
|
m_dolby_pro_logic->isChecked());
|
2017-11-07 09:55:44 +00:00
|
|
|
if (m_latency_control_supported)
|
|
|
|
{
|
|
|
|
m_latency_label->setEnabled(AudioCommon::SupportsLatencyControl(backend));
|
|
|
|
m_latency_spin->setEnabled(AudioCommon::SupportsLatencyControl(backend));
|
|
|
|
}
|
2018-02-10 20:03:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
bool is_wasapi = backend == BACKEND_WASAPI;
|
|
|
|
m_wasapi_device_label->setHidden(!is_wasapi);
|
|
|
|
m_wasapi_device_combo->setHidden(!is_wasapi);
|
|
|
|
|
|
|
|
if (is_wasapi)
|
|
|
|
{
|
|
|
|
m_wasapi_device_combo->clear();
|
|
|
|
m_wasapi_device_combo->addItem(tr("Default Device"));
|
|
|
|
|
|
|
|
for (const auto device : WASAPIStream::GetAvailableDevices())
|
|
|
|
m_wasapi_device_combo->addItem(QString::fromStdString(device));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-06-21 08:27:21 +00:00
|
|
|
m_volume_slider->setEnabled(AudioCommon::SupportsVolumeChanges(backend));
|
|
|
|
m_volume_indicator->setEnabled(AudioCommon::SupportsVolumeChanges(backend));
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::OnEmulationStateChanged(bool running)
|
|
|
|
{
|
|
|
|
m_dsp_hle->setEnabled(!running);
|
|
|
|
m_dsp_lle->setEnabled(!running);
|
|
|
|
m_dsp_interpreter->setEnabled(!running);
|
|
|
|
m_backend_label->setEnabled(!running);
|
|
|
|
m_backend_combo->setEnabled(!running);
|
2021-10-14 00:29:04 +00:00
|
|
|
if (AudioCommon::SupportsDPL2Decoder(Config::Get(Config::MAIN_AUDIO_BACKEND)) &&
|
|
|
|
!m_dsp_hle->isChecked())
|
2019-03-18 11:22:27 +00:00
|
|
|
{
|
|
|
|
m_dolby_pro_logic->setEnabled(!running);
|
2020-03-06 20:13:45 +00:00
|
|
|
EnableDolbyQualityWidgets(!running && m_dolby_pro_logic->isChecked());
|
2019-03-18 11:22:27 +00:00
|
|
|
}
|
2020-12-29 01:05:45 +00:00
|
|
|
if (m_latency_control_supported &&
|
2021-10-14 00:29:04 +00:00
|
|
|
AudioCommon::SupportsLatencyControl(Config::Get(Config::MAIN_AUDIO_BACKEND)))
|
2017-11-07 09:55:44 +00:00
|
|
|
{
|
|
|
|
m_latency_label->setEnabled(!running);
|
|
|
|
m_latency_spin->setEnabled(!running);
|
|
|
|
}
|
2018-02-10 20:03:27 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
m_wasapi_device_combo->setEnabled(!running);
|
|
|
|
#endif
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::OnVolumeChanged(int volume)
|
|
|
|
{
|
|
|
|
m_volume_slider->setValue(volume);
|
2021-09-08 20:08:43 +00:00
|
|
|
m_volume_indicator->setText(tr("%1%").arg(volume));
|
2017-06-21 08:27:21 +00:00
|
|
|
}
|
2017-11-07 09:55:44 +00:00
|
|
|
|
|
|
|
void AudioPane::CheckNeedForLatencyControl()
|
|
|
|
{
|
|
|
|
std::vector<std::string> backends = AudioCommon::GetSoundBackends();
|
|
|
|
m_latency_control_supported =
|
|
|
|
std::any_of(backends.cbegin(), backends.cend(), AudioCommon::SupportsLatencyControl);
|
|
|
|
}
|
2019-03-18 11:22:27 +00:00
|
|
|
|
|
|
|
QString AudioPane::GetDPL2QualityLabel(AudioCommon::DPL2Quality value) const
|
|
|
|
{
|
|
|
|
switch (value)
|
|
|
|
{
|
2019-06-15 11:36:47 +00:00
|
|
|
case AudioCommon::DPL2Quality::Lowest:
|
|
|
|
return tr("Lowest");
|
2019-03-18 11:22:27 +00:00
|
|
|
case AudioCommon::DPL2Quality::Low:
|
|
|
|
return tr("Low");
|
|
|
|
case AudioCommon::DPL2Quality::Highest:
|
|
|
|
return tr("Highest");
|
|
|
|
default:
|
|
|
|
return tr("High");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
QString AudioPane::GetDPL2ApproximateLatencyLabel(AudioCommon::DPL2Quality value) const
|
|
|
|
{
|
|
|
|
switch (value)
|
|
|
|
{
|
2019-06-15 11:36:47 +00:00
|
|
|
case AudioCommon::DPL2Quality::Lowest:
|
2021-09-08 20:08:43 +00:00
|
|
|
return tr("Latency: ~10 ms");
|
2019-06-15 11:36:47 +00:00
|
|
|
case AudioCommon::DPL2Quality::Low:
|
2021-09-08 20:08:43 +00:00
|
|
|
return tr("Latency: ~20 ms");
|
2019-03-18 11:22:27 +00:00
|
|
|
case AudioCommon::DPL2Quality::Highest:
|
2021-09-08 20:08:43 +00:00
|
|
|
return tr("Latency: ~80 ms");
|
2019-03-18 11:22:27 +00:00
|
|
|
default:
|
2021-09-08 20:08:43 +00:00
|
|
|
return tr("Latency: ~40 ms");
|
2019-03-18 11:22:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AudioPane::EnableDolbyQualityWidgets(bool enabled) const
|
|
|
|
{
|
|
|
|
m_dolby_quality_label->setEnabled(enabled);
|
|
|
|
m_dolby_quality_slider->setEnabled(enabled);
|
|
|
|
m_dolby_quality_low_label->setEnabled(enabled);
|
|
|
|
m_dolby_quality_highest_label->setEnabled(enabled);
|
|
|
|
m_dolby_quality_latency_label->setEnabled(enabled);
|
|
|
|
}
|