This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Fix for distorted synthesizer sound (maybe)
#1
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:
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. Smile
Reply
#2
Very well spotted!
In fact, the PSP itself skips the pitch conversion if the sound is already sampled at the base pitch, so you're fix is completely accurate. Even though there aren't many games using only the base pitch, it's necessary to enable this check.
Thanks, Itaru! Big Grin
Reply
#3
Hi Itaru!

thank you for your code review! Is the problem fixed by r1995? The fix was a little bit more complicated to handle looping sounds.
I've also posted your improvement in r1996.
Reply
#4
You're very welcome, Hykem and gid15. And thank you very much for the proper fix, gid15! I kinda figured the fix wouldn't be that simple so that's why the "(maybe)" in the title, hehe. It's working perfectly now with your fix. Smile
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)