Merge pull request #1487 from oioitff/audio-patch

Implement _sceSasCoreWithMix correctly.
This commit is contained in:
Henrik Rydgård committed 2013-04-23 08:32:02 -07:00
commit 15ac87bf59
3 files changed
+12 -8

No files matched your search

+5 -6
View File
@@ -95,20 +95,19 @@ u32 _sceSasCore(u32 core, u32 outAddr) {
return ERROR_SAS_INVALID_PARAMETER;
}
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;
}
+6 -1
View File
@@ -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);
}
}
+1 -1
View File
@@ -237,7 +237,7 @@ public:
FILE *audioDump;
void Mix(u32 outAddr);
void Mix(u32 outAddr, u32 inAddr = 0);
void DoState(PointerWrap &p);