From 8d10724b64d3a27151a380ea3a97e775c8499728 Mon Sep 17 00:00:00 2001 From: oioitff Date: Sat, 11 May 2013 04:30:02 +0800 Subject: [PATCH] Implement volume control for _sceSasCoreWithMix. Tested with Fate Unlimited Code. --- Core/HLE/sceSas.cpp | 2 +- Core/HW/SasAudio.cpp | 6 +++--- Core/HW/SasAudio.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index 5947dcae5..5618105d3 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -107,7 +107,7 @@ u32 _sceSasCoreWithMix(u32 core, u32 inoutAddr, int leftVolume, int rightVolume) return ERROR_SAS_INVALID_PARAMETER; } - sas->Mix(inoutAddr, inoutAddr); + sas->Mix(inoutAddr, inoutAddr, leftVolume, rightVolume); return 0; } diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index 98479fe53..5cf90ba17 100644 --- a/Core/HW/SasAudio.cpp +++ b/Core/HW/SasAudio.cpp @@ -265,7 +265,7 @@ static inline s16 clamp_s16(int i) { return i; } -void SasInstance::Mix(u32 outAddr, u32 inAddr) { +void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) { int voicesPlayingCount = 0; for (int v = 0; v < PSP_SAS_VOICES_MAX; v++) { SasVoice &voice = voices[v]; @@ -377,13 +377,13 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr) { for (int i = 0; i < grainSize * 2; i += 2) { int sampleL = mixBuffer[i] + sendBuffer[i]; if (inp) - sampleL += *inp++; + sampleL += (*inp++) * leftVol >> 12; *outp++ = clamp_s16(sampleL); if (outputMode == 0) { // stereo int sampleR = mixBuffer[i + 1] + sendBuffer[i + 1]; if (inp) - sampleR += *inp++; + sampleR += (*inp++) * rightVol >> 12; *outp++ = clamp_s16(sampleR); } } diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index c367f5f5e..ef0c704aa 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -237,7 +237,7 @@ public: FILE *audioDump; - void Mix(u32 outAddr, u32 inAddr = 0); + void Mix(u32 outAddr, u32 inAddr = 0, int leftVol = 0, int rightVol = 0); void DoState(PointerWrap &p);