diff --git a/Core/HLE/sceSas.cpp b/Core/HLE/sceSas.cpp index 5be29cc8dc..1fe71421a5 100644 --- a/Core/HLE/sceSas.cpp +++ b/Core/HLE/sceSas.cpp @@ -95,20 +95,20 @@ u32 _sceSasCore(u32 core, u32 outAddr) { return ERROR_SAS_INVALID_PARAMETER; } - Memory::Memset(outAddr, 0, sas->GetGrainSize() * 2 * 2); + //Memory::Memset(outAddr, 0, sas->GetGrainSize() * 2 * 2); sas->Mix(outAddr); return 0; } -// Another way of running the mixer, what was the difference again? -u32 _sceSasCoreWithMix(u32 core, u32 outAddr, int leftVolume, int rightVolume) { - DEBUG_LOG(HLE,"sceSasCoreWithMix(%08x, %08x, %i, %i)", core , outAddr, leftVolume, rightVolume); +// Another way of running the mixer, the inoutAddr should be both input and output +u32 _sceSasCoreWithMix(u32 core, u32 inoutAddr, int leftVolume, int rightVolume) { + DEBUG_LOG(HLE,"sceSasCoreWithMix(%08x, %08x, %i, %i)", core , inoutAddr, leftVolume, rightVolume); - if (!Memory::IsValidAddress(outAddr)) { + if (!Memory::IsValidAddress(inoutAddr)) { return ERROR_SAS_INVALID_PARAMETER; } - sas->Mix(outAddr); + sas->Mix(inoutAddr, inoutAddr); return 0; } diff --git a/Core/HW/SasAudio.cpp b/Core/HW/SasAudio.cpp index b4faf3c93b..98479fe534 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) { +void SasInstance::Mix(u32 outAddr, u32 inAddr) { int voicesPlayingCount = 0; for (int v = 0; v < PSP_SAS_VOICES_MAX; v++) { SasVoice &voice = voices[v]; @@ -373,12 +373,17 @@ void SasInstance::Mix(u32 outAddr) { // Alright, all voices mixed. Let's convert and clip, and at the same time, wipe mixBuffer for next time. Could also dither. s16 *outp = (s16 *)Memory::GetPointer(outAddr); + s16 *inp = inAddr ? (s16*)Memory::GetPointer(inAddr) : 0; for (int i = 0; i < grainSize * 2; i += 2) { int sampleL = mixBuffer[i] + sendBuffer[i]; + if (inp) + sampleL += *inp++; *outp++ = clamp_s16(sampleL); if (outputMode == 0) { // stereo int sampleR = mixBuffer[i + 1] + sendBuffer[i + 1]; + if (inp) + sampleR += *inp++; *outp++ = clamp_s16(sampleR); } } diff --git a/Core/HW/SasAudio.h b/Core/HW/SasAudio.h index 1a50a97da5..c367f5f5ec 100644 --- a/Core/HW/SasAudio.h +++ b/Core/HW/SasAudio.h @@ -237,7 +237,7 @@ public: FILE *audioDump; - void Mix(u32 outAddr); + void Mix(u32 outAddr, u32 inAddr = 0); void DoState(PointerWrap &p);