02-26-2011, 04:57 AM
Starting with r1979, I noticed that sound effects in Persona 3 Portable became a bit distorted and noisy. I think I have found a way to restore the sound quality back to the way it was previously. In class jpcsp.sound.SampleSourceWithPitch starting on line 75, I changed the getSampleIndex() method to:
The original one calculates the sampleIndex from the sampleSourceIndex but I'm not sure that's necessary since there's already a sampleIndex field available. The calculation probably introduces rounding errors which cause the distortion/noise? Changing the above seems to have restored sound effects quality in P3P (and probably other games too) back to the way it was before r1979.
Also, I noticed that SampleSourceWithPitch isn't needed if pitch is already at base pitch, and some sound effects in P3P (and I assume in other games too) are at base pitch. So, perhaps the following optimization in class jpcsp.sound.SoftwareSynthesizer in method getSampleSource() replacing lines 35-36 can help a bit:
I haven't done any benchmarks at all, and the above optimization may even be useless or even slow things down a bit if very few sounds are at base pitch in most games. Oh well, it's just a suggestion.
Code:
@Override
public int getSampleIndex() {
return sampleIndex;
}
The original one calculates the sampleIndex from the sampleSourceIndex but I'm not sure that's necessary since there's already a sampleIndex field available. The calculation probably introduces rounding errors which cause the distortion/noise? Changing the above seems to have restored sound effects quality in P3P (and probably other games too) back to the way it was before r1979.
Also, I noticed that SampleSourceWithPitch isn't needed if pitch is already at base pitch, and some sound effects in P3P (and I assume in other games too) are at base pitch. So, perhaps the following optimization in class jpcsp.sound.SoftwareSynthesizer in method getSampleSource() replacing lines 35-36 can help a bit:
Code:
ISampleSource sampleSourceTemp = new SampleSourceVAG(voice.getVAGAddress(), voice.getVAGSize(), voice.getLoopMode() != sceSasCore.PSP_SAS_LOOP_MODE_OFF);
int pitch = voice.getPitch();
if (pitch == sceSasCore.PSP_SAS_PITCH_BASE)
sampleSource = sampleSourceTemp;
else
sampleSource = new SampleSourceWithPitch(sampleSourceTemp, pitch);
I haven't done any benchmarks at all, and the above optimization may even be useless or even slow things down a bit if very few sounds are at base pitch in most games. Oh well, it's just a suggestion.