From acf94a35f8ffaf067fa1285b7978c245514ab546 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sat, 6 Jul 2013 22:21:29 +0200 Subject: [PATCH] Minor audio optimization --- Core/HLE/sceAtrac.cpp | 6 ++++-- Core/HW/SasAudio.cpp | 8 +++++--- UI/MenuScreens.cpp | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceAtrac.cpp b/Core/HLE/sceAtrac.cpp index 19622012d5..b2de674213 100644 --- a/Core/HLE/sceAtrac.cpp +++ b/Core/HLE/sceAtrac.cpp @@ -629,11 +629,13 @@ u32 _AtracDecodeData(int atracID, u8* outbuf, u32 *SamplesNum, u32* finish, int int gotsize = atrac->sampleQueue.pop_front(buf, ATRAC3PLUS_MAX_SAMPLES * sizeof(s16) * atrac->atracChannels); numSamples = gotsize / sizeof(s16) / atrac->atracChannels; s16* in = (s16*)buf; + int volumeShift = (MAX_CONFIG_VOLUME - g_Config.iBGMVolume); + if (volumeShift < 0) volumeShift = 0; for (u32 i = 0; i < numSamples; i++) { - s16 sampleL = *in++ >> (MAX_CONFIG_VOLUME - g_Config.iBGMVolume); // Max = 4 and Min = 0(no shift) + s16 sampleL = *in++ >> volumeShift; // Max = 4 and Min = 0(no shift) s16 sampleR = sampleL; if (atrac->atracChannels == 2) - sampleR = *in++ >> (MAX_CONFIG_VOLUME - g_Config.iBGMVolume); // Max = 4 and Min = 0(no shift) + sampleR = *in++ >> volumeShift; // Max = 4 and Min = 0(no shift) *out++ = sampleL; if (atrac->atracOutputChannels == 2) *out++ = sampleR; diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 4fd3197e21..d776d63348 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -413,7 +413,9 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) { // Resample to the correct pitch, writing exactly "grainSize" samples. u32 sampleFrac = voice.sampleFrac; - const int MAX_CONFIG_VOLUME = 17; + const int MAX_CONFIG_VOLUME = 17; // 12 + 5 + int volumeShift = (MAX_CONFIG_VOLUME - g_Config.iSEVolume); + if (volumeShift < 0) volumeShift = 0; for (int i = 0; i < grainSize; i++) { // For now: nearest neighbour, not even using the resample history at all. int sample = resampleBuffer[sampleFrac / PSP_SAS_PITCH_BASE + 2]; @@ -431,8 +433,8 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) { // We mix into this 32-bit temp buffer and clip in a second loop // Ideally, the shift right should be there too but for now I'm concerned about // not overflowing. - mixBuffer[i * 2] += (sample * voice.volumeLeft ) >> (MAX_CONFIG_VOLUME - g_Config.iSEVolume); // Max = 16 and Min = 12(default) - mixBuffer[i * 2 + 1] += (sample * voice.volumeRight) >> (MAX_CONFIG_VOLUME - g_Config.iSEVolume); // Max = 16 and Min = 12(default) + mixBuffer[i * 2] += (sample * voice.volumeLeft ) >> volumeShift; // Max = 16 and Min = 12(default) + mixBuffer[i * 2 + 1] += (sample * voice.volumeRight) >> volumeShift; // Max = 16 and Min = 12(default) sendBuffer[i * 2] += sample * voice.volumeLeftSend >> 12; sendBuffer[i * 2 + 1] += sample * voice.volumeRightSend >> 12; voice.envelope.Step(); diff --git a/UI/MenuScreens.cpp b/UI/MenuScreens.cpp index be0786e124..2a6e40d6a9 100644 --- a/UI/MenuScreens.cpp +++ b/UI/MenuScreens.cpp @@ -820,6 +820,7 @@ void AudioScreen::render() { if (UIButton(GEN_ID, hlinear2, 50, 0, a->T("+1"), ALIGN_LEFT)) if (g_Config.iSEVolume < 5) g_Config.iSEVolume += 1; + y+=10; } else