Audio: Add option to AudioPane to temporarily mute audio when emulation speed limit is disabled.

This commit is contained in:
TryTwo 2024-10-09 17:39:18 -07:00
parent de67c4c93b
commit a56a27a219
5 changed files with 41 additions and 1 deletions

View File

@ -280,6 +280,8 @@ const Info<std::string> MAIN_AUDIO_BACKEND{{System::Main, "DSP", "Backend"},
AudioCommon::GetDefaultSoundBackend()}; AudioCommon::GetDefaultSoundBackend()};
const Info<int> MAIN_AUDIO_VOLUME{{System::Main, "DSP", "Volume"}, 100}; const Info<int> MAIN_AUDIO_VOLUME{{System::Main, "DSP", "Volume"}, 100};
const Info<bool> MAIN_AUDIO_MUTED{{System::Main, "DSP", "Muted"}, false}; const Info<bool> MAIN_AUDIO_MUTED{{System::Main, "DSP", "Muted"}, false};
const Info<bool> MAIN_AUDIO_MUTE_ON_DISABLED_SPEED_LIMIT{
{System::Main, "DSP", "MuteOnDisabledSpeedLimit"}, false};
#ifdef _WIN32 #ifdef _WIN32
const Info<std::string> MAIN_WASAPI_DEVICE{{System::Main, "DSP", "WASAPIDevice"}, "Default"}; const Info<std::string> MAIN_WASAPI_DEVICE{{System::Main, "DSP", "WASAPIDevice"}, "Default"};
#endif #endif

View File

@ -167,6 +167,7 @@ extern const Info<bool> MAIN_DUMP_UCODE;
extern const Info<std::string> MAIN_AUDIO_BACKEND; extern const Info<std::string> MAIN_AUDIO_BACKEND;
extern const Info<int> MAIN_AUDIO_VOLUME; extern const Info<int> MAIN_AUDIO_VOLUME;
extern const Info<bool> MAIN_AUDIO_MUTED; extern const Info<bool> MAIN_AUDIO_MUTED;
extern const Info<bool> MAIN_AUDIO_MUTE_ON_DISABLED_SPEED_LIMIT;
#ifdef _WIN32 #ifdef _WIN32
extern const Info<std::string> MAIN_WASAPI_DEVICE; extern const Info<std::string> MAIN_WASAPI_DEVICE;
#endif #endif

View File

@ -360,7 +360,7 @@ void HotkeyScheduler::Run()
if (IsHotkey(HK_VOLUME_TOGGLE_MUTE)) if (IsHotkey(HK_VOLUME_TOGGLE_MUTE))
{ {
AudioCommon::ToggleMuteVolume(Core::System::GetInstance()); AudioCommon::ToggleMuteVolume(system);
ShowVolume(); ShowVolume();
} }
@ -483,6 +483,20 @@ void HotkeyScheduler::Run()
Core::SetIsThrottlerTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true)); Core::SetIsThrottlerTempDisabled(IsHotkey(HK_TOGGLE_THROTTLE, true));
if (IsHotkey(HK_TOGGLE_THROTTLE, true) && !Config::Get(Config::MAIN_AUDIO_MUTED) &&
Config::Get(Config::MAIN_AUDIO_MUTE_ON_DISABLED_SPEED_LIMIT))
{
Config::SetCurrent(Config::MAIN_AUDIO_MUTED, true);
AudioCommon::UpdateSoundStream(system);
}
else if (!IsHotkey(HK_TOGGLE_THROTTLE, true) && Config::Get(Config::MAIN_AUDIO_MUTED) &&
Config::GetActiveLayerForConfig(Config::MAIN_AUDIO_MUTED) ==
Config::LayerType::CurrentRun)
{
Config::DeleteKey(Config::LayerType::CurrentRun, Config::MAIN_AUDIO_MUTED);
AudioCommon::UpdateSoundStream(system);
}
auto ShowEmulationSpeed = []() { auto ShowEmulationSpeed = []() {
const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED); const float emulation_speed = Config::Get(Config::MAIN_EMULATION_SPEED);
if (!AchievementManager::GetInstance().IsHardcoreModeActive() || if (!AchievementManager::GetInstance().IsHardcoreModeActive() ||

View File

@ -160,10 +160,22 @@ void AudioPane::CreateWidgets()
dsp_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); dsp_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
auto* misc_box = new QGroupBox(tr("Miscellaneous Settings"));
auto* misc_layout = new QGridLayout;
misc_box->setLayout(misc_layout);
m_speed_up_mute_enable = new QCheckBox(tr("Mute When Disabling Speed Limit."));
m_speed_up_mute_enable->setToolTip(
tr("Mutes the audio when overriding the emulation speed limit (default hotkey: Tab)."));
misc_layout->addWidget(m_speed_up_mute_enable, 0, 0, 1, 1);
auto* const main_vbox_layout = new QVBoxLayout; auto* const main_vbox_layout = new QVBoxLayout;
main_vbox_layout->addWidget(dsp_box); main_vbox_layout->addWidget(dsp_box);
main_vbox_layout->addWidget(backend_box); main_vbox_layout->addWidget(backend_box);
main_vbox_layout->addWidget(stretching_box); main_vbox_layout->addWidget(stretching_box);
main_vbox_layout->addWidget(misc_box);
m_main_layout = new QHBoxLayout; m_main_layout = new QHBoxLayout;
m_main_layout->addLayout(main_vbox_layout); m_main_layout->addLayout(main_vbox_layout);
@ -188,6 +200,7 @@ void AudioPane::ConnectWidgets()
connect(m_dsp_hle, &QRadioButton::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_lle, &QRadioButton::toggled, this, &AudioPane::SaveSettings);
connect(m_dsp_interpreter, &QRadioButton::toggled, this, &AudioPane::SaveSettings); connect(m_dsp_interpreter, &QRadioButton::toggled, this, &AudioPane::SaveSettings);
connect(m_speed_up_mute_enable, &QCheckBox::toggled, this, &AudioPane::SaveSettings);
#ifdef _WIN32 #ifdef _WIN32
connect(m_wasapi_device_combo, &QComboBox::currentIndexChanged, this, &AudioPane::SaveSettings); connect(m_wasapi_device_combo, &QComboBox::currentIndexChanged, this, &AudioPane::SaveSettings);
@ -251,6 +264,9 @@ void AudioPane::LoadSettings()
m_stretching_buffer_indicator->setEnabled(m_stretching_enable->isChecked()); m_stretching_buffer_indicator->setEnabled(m_stretching_enable->isChecked());
m_stretching_buffer_indicator->setText(tr("%1 ms").arg(m_stretching_buffer_slider->value())); m_stretching_buffer_indicator->setText(tr("%1 ms").arg(m_stretching_buffer_slider->value()));
// Misc
m_speed_up_mute_enable->setChecked(Config::Get(Config::MAIN_AUDIO_MUTE_ON_DISABLED_SPEED_LIMIT));
#ifdef _WIN32 #ifdef _WIN32
if (Config::Get(Config::MAIN_WASAPI_DEVICE) == "default") if (Config::Get(Config::MAIN_WASAPI_DEVICE) == "default")
{ {
@ -320,6 +336,10 @@ void AudioPane::SaveSettings()
m_stretching_buffer_indicator->setText( m_stretching_buffer_indicator->setText(
tr("%1 ms").arg(Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY))); tr("%1 ms").arg(Config::Get(Config::MAIN_AUDIO_STRETCH_LATENCY)));
// Misc
Config::SetBaseOrCurrent(Config::MAIN_AUDIO_MUTE_ON_DISABLED_SPEED_LIMIT,
m_speed_up_mute_enable->isChecked());
#ifdef _WIN32 #ifdef _WIN32
std::string device = "default"; std::string device = "default";

View File

@ -76,4 +76,7 @@ private:
QLabel* m_stretching_buffer_label; QLabel* m_stretching_buffer_label;
QSlider* m_stretching_buffer_slider; QSlider* m_stretching_buffer_slider;
QLabel* m_stretching_buffer_indicator; QLabel* m_stretching_buffer_indicator;
// Misc Settings
QCheckBox* m_speed_up_mute_enable;
}; };