CDROM: Add a setting and hotkey to mute CD audio

This commit is contained in:
Connor McLaughlin 2020-10-03 12:24:03 +10:00
parent f7de39f3d0
commit ca0bfc39a2
8 changed files with 36 additions and 5 deletions

View File

@ -2018,7 +2018,7 @@ void CDROM::ProcessXAADPCMSector(const u8* raw_sector, const CDImage::SubChannel
CDXA::DecodeADPCMSector(raw_sector, sample_buffer.data(), m_xa_last_samples.data()); CDXA::DecodeADPCMSector(raw_sector, sample_buffer.data(), m_xa_last_samples.data());
// Only send to SPU if we're not muted. // Only send to SPU if we're not muted.
if (m_muted || m_adpcm_muted) if (m_muted || m_adpcm_muted || g_settings.cdrom_mute_cd_audio)
return; return;
g_spu.GeneratePendingSamples(); g_spu.GeneratePendingSamples();
@ -2082,7 +2082,7 @@ void CDROM::ProcessCDDASector(const u8* raw_sector, const CDImage::SubChannelQ&
} }
// Apply volume when pushing sectors to SPU. // Apply volume when pushing sectors to SPU.
if (m_muted) if (m_muted || g_settings.cdrom_mute_cd_audio)
return; return;
g_spu.GeneratePendingSamples(); g_spu.GeneratePendingSamples();

View File

@ -456,6 +456,7 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetBoolValue("CDROM", "ReadThread", true); si.SetBoolValue("CDROM", "ReadThread", true);
si.SetBoolValue("CDROM", "RegionCheck", true); si.SetBoolValue("CDROM", "RegionCheck", true);
si.SetBoolValue("CDROM", "LoadImageToRAM", false); si.SetBoolValue("CDROM", "LoadImageToRAM", false);
si.SetBoolValue("CDROM", "MuteCDAudio", false);
si.SetStringValue("Audio", "Backend", Settings::GetAudioBackendName(Settings::DEFAULT_AUDIO_BACKEND)); si.SetStringValue("Audio", "Backend", Settings::GetAudioBackendName(Settings::DEFAULT_AUDIO_BACKEND));
si.SetIntValue("Audio", "OutputVolume", 100); si.SetIntValue("Audio", "OutputVolume", 100);

View File

@ -175,6 +175,7 @@ void Settings::Load(SettingsInterface& si)
cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true); cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true);
cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", true); cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", true);
cdrom_load_image_to_ram = si.GetBoolValue("CDROM", "LoadImageToRAM", false); cdrom_load_image_to_ram = si.GetBoolValue("CDROM", "LoadImageToRAM", false);
cdrom_mute_cd_audio = si.GetBoolValue("CDROM", "MuteCDAudio", false);
audio_backend = audio_backend =
ParseAudioBackend(si.GetStringValue("Audio", "Backend", GetAudioBackendName(DEFAULT_AUDIO_BACKEND)).c_str()) ParseAudioBackend(si.GetStringValue("Audio", "Backend", GetAudioBackendName(DEFAULT_AUDIO_BACKEND)).c_str())
@ -294,6 +295,7 @@ void Settings::Save(SettingsInterface& si) const
si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread); si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread);
si.SetBoolValue("CDROM", "RegionCheck", cdrom_region_check); si.SetBoolValue("CDROM", "RegionCheck", cdrom_region_check);
si.SetBoolValue("CDROM", "LoadImageToRAM", cdrom_load_image_to_ram); si.SetBoolValue("CDROM", "LoadImageToRAM", cdrom_load_image_to_ram);
si.SetBoolValue("CDROM", "MuteCDAudio", cdrom_mute_cd_audio);
si.SetStringValue("Audio", "Backend", GetAudioBackendName(audio_backend)); si.SetStringValue("Audio", "Backend", GetAudioBackendName(audio_backend));
si.SetIntValue("Audio", "OutputVolume", audio_output_volume); si.SetIntValue("Audio", "OutputVolume", audio_output_volume);

View File

@ -122,6 +122,7 @@ struct Settings
bool cdrom_read_thread = true; bool cdrom_read_thread = true;
bool cdrom_region_check = true; bool cdrom_region_check = true;
bool cdrom_load_image_to_ram = false; bool cdrom_load_image_to_ram = false;
bool cdrom_mute_cd_audio = false;
AudioBackend audio_backend = AudioBackend::Cubeb; AudioBackend audio_backend = AudioBackend::Cubeb;
s32 audio_output_volume = 100; s32 audio_output_volume = 100;

View File

@ -445,7 +445,7 @@ void LibretroHostInterface::OnSystemDestroyed()
m_using_hardware_renderer = false; m_using_hardware_renderer = false;
} }
static std::array<retro_core_option_definition, 34> s_option_definitions = {{ static std::array<retro_core_option_definition, 35> s_option_definitions = {{
{"duckstation_Console.Region", {"duckstation_Console.Region",
"Console Region", "Console Region",
"Determines which region/hardware to emulate. Auto-Detect will use the region of the disc inserted.", "Determines which region/hardware to emulate. Auto-Detect will use the region of the disc inserted.",
@ -476,6 +476,11 @@ static std::array<retro_core_option_definition, 34> s_option_definitions = {{
"lock up while the image is preloaded.", "lock up while the image is preloaded.",
{{"true", "Enabled"}, {"false", "Disabled"}}, {{"true", "Enabled"}, {"false", "Disabled"}},
"false"}, "false"},
{"duckstation_CDROM.MuteCDAudio",
"Mute CD Audio",
"Forcibly mutes both CD-DA and XA audio from the CD-ROM. Can be used to disable background music in some games.",
{{"true", "Enabled"}, {"false", "Disabled"}},
"false"},
{"duckstation_CPU.ExecutionMode", {"duckstation_CPU.ExecutionMode",
"CPU Execution Mode", "CPU Execution Mode",
"Which mode to use for CPU emulation. Recompiler provides the best performance.", "Which mode to use for CPU emulation. Recompiler provides the best performance.",

View File

@ -22,6 +22,7 @@ AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidge
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToOutput, "Audio", "Sync"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.syncToOutput, "Audio", "Sync");
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.bufferSize, "Audio", "BufferSize"); SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.bufferSize, "Audio", "BufferSize");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startDumpingOnBoot, "Audio", "DumpOnBoot"); SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.startDumpingOnBoot, "Audio", "DumpOnBoot");
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.muteCDAudio, "CDROM", "MuteCDAudio");
m_ui.volume->setValue(m_host_interface->GetIntSettingValue("Audio", "OutputVolume")); m_ui.volume->setValue(m_host_interface->GetIntSettingValue("Audio", "OutputVolume"));
m_ui.muted->setChecked(m_host_interface->GetBoolSettingValue("Audio", "OutputMuted")); m_ui.muted->setChecked(m_host_interface->GetBoolSettingValue("Audio", "OutputMuted"));
@ -53,8 +54,11 @@ AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidge
tr("Start dumping audio to file as soon as the emulator is started. Mainly useful as a debug option.")); tr("Start dumping audio to file as soon as the emulator is started. Mainly useful as a debug option."));
dialog->registerWidgetHelp(m_ui.volume, tr("Volume"), "100", dialog->registerWidgetHelp(m_ui.volume, tr("Volume"), "100",
tr("Controls the volume of the audio played on the host. Values are in percentage.")); tr("Controls the volume of the audio played on the host. Values are in percentage."));
dialog->registerWidgetHelp(m_ui.muted, tr("Mute"), tr("Unchecked"), dialog->registerWidgetHelp(m_ui.muted, tr("Mute All Sound"), tr("Unchecked"),
tr("Prevents the emulator from producing any audible sound.")); tr("Prevents the emulator from producing any audible sound."));
dialog->registerWidgetHelp(m_ui.muteCDAudio, tr("Mute CD Audio"), tr("Unchecked"),
tr("Forcibly mutes both CD-DA and XA audio from the CD-ROM. Can be used to disable "
"background music in some games."));
} }
AudioSettingsWidget::~AudioSettingsWidget() = default; AudioSettingsWidget::~AudioSettingsWidget() = default;

View File

@ -149,7 +149,14 @@
<item row="2" column="0" colspan="2"> <item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="muted"> <widget class="QCheckBox" name="muted">
<property name="text"> <property name="text">
<string>Mute</string> <string>Mute All Sound</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="muteCDAudio">
<property name="text">
<string>Mute CD Audio</string>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -1549,6 +1549,17 @@ void CommonHostInterface::RegisterAudioHotkeys()
AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), g_settings.audio_output_volume); AddFormattedOSDMessage(2.0f, TranslateString("OSDMessage", "Volume: %d%%"), g_settings.audio_output_volume);
} }
}); });
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioCDAudioMute"),
StaticString(TRANSLATABLE("Hotkeys", "Toggle CD Audio Mute")), [this](bool pressed) {
if (System::IsValid() && !pressed)
{
g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio;
AddOSDMessage(g_settings.cdrom_mute_cd_audio ?
TranslateStdString("OSDMessage", "CD Audio Muted.") :
TranslateStdString("OSDMessage", "CD Audio Unmuted."),
2.0f);
}
});
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeUp"), RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Audio")), StaticString("AudioVolumeUp"),
StaticString(TRANSLATABLE("Hotkeys", "Volume Up")), [this](bool pressed) { StaticString(TRANSLATABLE("Hotkeys", "Volume Up")), [this](bool pressed) {
if (System::IsValid() && pressed) if (System::IsValid() && pressed)