Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio: Add volume for alternate speed #12124

Merged
merged 1 commit into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ static ConfigSetting soundSettings[] = {
ConfigSetting("ExtraAudioBuffering", &g_Config.bExtraAudioBuffering, false, true, false),
ConfigSetting("AudioResampler", &g_Config.bAudioResampler, true, true, true),
ConfigSetting("GlobalVolume", &g_Config.iGlobalVolume, VOLUME_MAX, true, true),
ConfigSetting("AltSpeedVolume", &g_Config.iAltSpeedVolume, -1, true, true),

ConfigSetting(false),
};
Expand Down
1 change: 1 addition & 0 deletions Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ struct Config {
int iAudioLatency; // 0 = low , 1 = medium(default) , 2 = high
int iAudioBackend;
int iGlobalVolume;
int iAltSpeedVolume;
bool bExtraAudioBuffering; // For bluetooth

// UI
Expand Down
13 changes: 10 additions & 3 deletions Core/HW/StereoResampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,19 @@ inline void ClampBufferToS16(s16 *out, const s32 *in, size_t size, s8 volShift)
}

inline void ClampBufferToS16WithVolume(s16 *out, const s32 *in, size_t size) {
if (g_Config.iGlobalVolume >= VOLUME_MAX) {
int volume = g_Config.iGlobalVolume;
if (PSP_CoreParameter().fpsLimit != FPSLimit::NORMAL || PSP_CoreParameter().unthrottle) {
if (g_Config.iAltSpeedVolume != -1) {
volume = g_Config.iAltSpeedVolume;
}
}

if (volume >= VOLUME_MAX) {
ClampBufferToS16<false>(out, in, size, 0);
} else if (g_Config.iGlobalVolume <= VOLUME_OFF) {
} else if (volume <= VOLUME_OFF) {
memset(out, 0, size * sizeof(s16));
} else {
ClampBufferToS16<true>(out, in, size, VOLUME_MAX - (s8)g_Config.iGlobalVolume);
ClampBufferToS16<true>(out, in, size, VOLUME_MAX - (s8)volume);
}
}

Expand Down
6 changes: 6 additions & 0 deletions UI/GameSettingsScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,12 @@ void GameSettingsScreen::CreateViews() {

PopupSliderChoice *volume = audioSettings->Add(new PopupSliderChoice(&g_Config.iGlobalVolume, VOLUME_OFF, VOLUME_MAX, 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()));
altVolume->SetEnabledPtr(&g_Config.bEnableSound);
altVolume->SetZeroLabel(a->T("Mute"));
altVolume->SetNegativeDisable(a->T("Use global volume"));

#ifdef _WIN32
if (IsVistaOrHigher()) {
Expand Down