diff --git a/Core/Config.cpp b/Core/Config.cpp index d019ae7bfb..a378ceada6 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -904,7 +904,8 @@ static ConfigSetting soundSettings[] = { ConfigSetting("Enable", &g_Config.bEnableSound, true, true, true), ConfigSetting("AudioBackend", &g_Config.iAudioBackend, 0, true, true), ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, true, false), - ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_MAX, true, true), + ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_FULL, true, true), + ConfigSetting("ReverbVolume", &g_Config.iReverbVolume, VOLUME_FULL, true, true), ConfigSetting("AltSpeedVolume", &g_Config.iAltSpeedVolume, -1, true, true), ConfigSetting("AudioDevice", &g_Config.sAudioDevice, "", true, false), ConfigSetting("AutoAudioDevice", &g_Config.bAutoAudioDevice, true, true, false), diff --git a/Core/Config.h b/Core/Config.h index 4ddde8b525..cf0711b139 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -238,6 +238,7 @@ public: bool bEnableSound; int iAudioBackend; int iGlobalVolume; + int iReverbVolume; int iAltSpeedVolume; bool bExtraAudioBuffering; // For bluetooth std::string sAudioDevice; diff --git a/Core/ConfigValues.h b/Core/ConfigValues.h index d55af77964..cbdee70a0b 100644 --- a/Core/ConfigValues.h +++ b/Core/ConfigValues.h @@ -28,7 +28,7 @@ const int PSP_MODEL_FAT = 0; const int PSP_MODEL_SLIM = 1; const int PSP_DEFAULT_FIRMWARE = 660; static const int8_t VOLUME_OFF = 0; -static const int8_t VOLUME_MAX = 10; +static const int8_t VOLUME_FULL = 10; enum class CPUCore { INTERPRETER = 0, diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 31de118345..2df95195a6 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -680,7 +680,7 @@ void SasInstance::ApplyWaveformEffect() { sendBufferDownsampled[i * 2 + 1] = clamp_s16(sendBuffer[i * 4 + 1]); } - // Volume max is 0x1000, while our factor is up to 0x8000. Shifting right by 3 fixes that. + // Volume max is 0x1000, while our factor is up to 0x8000. Shifting left by 3 fixes that. reverb_.ProcessReverb(sendBufferProcessed, sendBufferDownsampled, grainSize / 2, waveformEffect.leftVol << 3, waveformEffect.rightVol << 3); } diff --git a/Core/HW/SasReverb.cpp b/Core/HW/SasReverb.cpp index 14dbc06248..c67de0abdd 100644 --- a/Core/HW/SasReverb.cpp +++ b/Core/HW/SasReverb.cpp @@ -18,6 +18,8 @@ #include #include +#include "Common/Math/math_util.h" +#include "Core/Config.h" #include "Core/HW/SasReverb.h" #include "Core/Util/AudioFormat.h" @@ -219,6 +221,15 @@ void SasReverb::ProcessReverb(int16_t *output, const int16_t *input, size_t inpu return; } + const uint8_t reverbVolume = Clamp(g_Config.iReverbVolume, 0, 25); + // Standard volume is 10, which pairs with a normal shift of 15. + const uint8_t finalShift = 25 - reverbVolume; + if (reverbVolume == 0) { + // Force to zero output, which is not the same as "Off." + memset(output, 0, inputSize * 4); + return; + } + const SasReverbData &d = presets[preset_]; // We put this on the stack instead of in the object to let the compiler optimize better (avoid mem r/w). @@ -255,8 +266,8 @@ void SasReverb::ProcessReverb(int16_t *output, const int16_t *input, size_t inpu b[d.mRAPF2] = clamp_s16(Rout - (d.vAPF2*b[(d.mRAPF2 - d.dAPF2)] >> 15)); Rout = b[(d.mRAPF2 - d.dAPF2)] + (b[d.mRAPF2] * d.vAPF2 >> 15); // ___Output to Mixer(Output volume multiplied with input from APF2)___________ - output[i * 4 + 0] = clamp_s16(Lout * volLeft >> 15); - output[i * 4 + 1] = clamp_s16(Rout * volRight >> 15); + output[i * 4 + 0] = clamp_s16((Lout * volLeft) >> finalShift); + output[i * 4 + 1] = clamp_s16((Rout * volRight) >> finalShift); output[i * 4 + 2] = 0; output[i * 4 + 3] = 0; diff --git a/Core/HW/StereoResampler.cpp b/Core/HW/StereoResampler.cpp index 6f40d310f3..5445984546 100644 --- a/Core/HW/StereoResampler.cpp +++ b/Core/HW/StereoResampler.cpp @@ -149,12 +149,12 @@ inline void ClampBufferToS16WithVolume(s16 *out, const s32 *in, size_t size) { } } - if (volume >= VOLUME_MAX) { + if (volume >= VOLUME_FULL) { ClampBufferToS16(out, in, size, 0); } else if (volume <= VOLUME_OFF) { memset(out, 0, size * sizeof(s16)); } else { - ClampBufferToS16(out, in, size, VOLUME_MAX - (s8)volume); + ClampBufferToS16(out, in, size, VOLUME_FULL - (s8)volume); } } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 5f35d37b78..441e57ae63 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -609,15 +609,19 @@ void GameSettingsScreen::CreateViews() { audioSettings->Add(new CheckBox(&g_Config.bEnableSound, a->T("Enable Sound"))); - PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGlobalVolume, VOLUME_OFF, VOLUME_MAX, a->T("Global volume"), screenManager())); + PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGlobalVolume, VOLUME_OFF, VOLUME_FULL, a->T("Global volume"), screenManager())); volume->SetEnabledPtr(&g_Config.bEnableSound); volume->SetZeroLabel(a->T("Mute")); - PopupSliderChoice *altVolume = audioSettings->Add(new PopupSliderChoice(&g_Config.iAltSpeedVolume, VOLUME_OFF, VOLUME_MAX, a->T("Alternate speed volume"), screenManager())); + PopupSliderChoice *altVolume = audioSettings->Add(new PopupSliderChoice(&g_Config.iAltSpeedVolume, VOLUME_OFF, VOLUME_FULL, a->T("Alternate speed volume"), screenManager())); altVolume->SetEnabledPtr(&g_Config.bEnableSound); altVolume->SetZeroLabel(a->T("Mute")); altVolume->SetNegativeDisable(a->T("Use global volume")); + PopupSliderChoice *reverbVolume = audioSettings->Add(new PopupSliderChoice(&g_Config.iReverbVolume, VOLUME_OFF, 2 * VOLUME_FULL, a->T("Reverb volume"), screenManager())); + reverbVolume->SetEnabledPtr(&g_Config.bEnableSound); + reverbVolume->SetZeroLabel(a->T("Disabled")); + // Hide the backend selector in UWP builds (we only support XAudio2 there). #if PPSSPP_PLATFORM(WINDOWS) && !PPSSPP_PLATFORM(UWP) if (IsVistaOrHigher()) { diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 0f3fc8f276..fa433dae54 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -405,6 +405,8 @@ int main(int argc, const char* argv[]) g_Config.sMACAddress = "12:34:56:78:9A:BC"; g_Config.iFirmwareVersion = PSP_DEFAULT_FIRMWARE; g_Config.iPSPModel = PSP_MODEL_SLIM; + g_Config.iGlobalVolume = VOLUME_FULL; + g_Config.iReverbVolume = VOLUME_FULL; #ifdef _WIN32 g_Config.internalDataDirectory.clear(); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 1e5fcc61e5..66c080d2c0 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -420,7 +420,8 @@ void retro_init(void) // libretro does its own timing, so this should stay CONTINUOUS. g_Config.iUnthrottleMode = (int)UnthrottleMode::CONTINUOUS; g_Config.bMemStickInserted = true; - g_Config.iGlobalVolume = VOLUME_MAX - 1; + g_Config.iGlobalVolume = VOLUME_FULL - 1; + g_Config.iReverbVolume = VOLUME_FULL; g_Config.iAltSpeedVolume = -1; g_Config.bEnableSound = true; g_Config.iCwCheatRefreshRate = 60;