Fix for distorted synthesizer sound (maybe) - Printable Version +- EmuNewz Network (https://www.emunewz.net/forum) +-- Forum: PSP Emulation (https://www.emunewz.net/forum/forumdisplay.php?fid=191) +--- Forum: JPCSP Official Forum (https://www.emunewz.net/forum/forumdisplay.php?fid=51) +---- Forum: svn trunk discussion (https://www.emunewz.net/forum/forumdisplay.php?fid=56) +---- Thread: Fix for distorted synthesizer sound (maybe) (/showthread.php?tid=3768) |
Fix for distorted synthesizer sound (maybe) - Itaru - 02-26-2011 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 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); 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. RE: Fix for distorted synthesizer sound (maybe) - Hykem - 02-26-2011 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! RE: Fix for distorted synthesizer sound (maybe) - gid15 - 02-27-2011 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. RE: Fix for distorted synthesizer sound (maybe) - Itaru - 02-28-2011 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. |