SPU2-X: Quality fix (?): take crest value to mean the electronics definition and clamp modulated pitch to [0,0x3fff] on the basis that the SPU2 probably is incapable of decoding two words of samples for each voice in each tick. Honestly this is still guessing, we only really know that it was wrong.

Test FFX tone when it's your turn to act, FFX underwater music?, xenosaga movie skipping sound effect, god knows what else.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4754 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
sudonim1@gmail.com 2011-06-22 02:27:39 +00:00
parent eba05e18c2
commit 629a6826d2
3 changed files with 9 additions and 13 deletions

View File

@ -341,7 +341,7 @@ static void __forceinline UpdatePitch( uint coreidx, uint voiceidx )
if( (vc.Modulated==0) || (voiceidx==0) ) if( (vc.Modulated==0) || (voiceidx==0) )
pitch = vc.Pitch; pitch = vc.Pitch;
else else
pitch = (vc.Pitch*(32768 + Cores[coreidx].Voices[voiceidx-1].OutX))>>15; pitch = GetClamped((vc.Pitch*(32768 + Cores[coreidx].Voices[voiceidx-1].OutX))>>15, 0, 0x3fff);
vc.SP+=pitch; vc.SP+=pitch;
} }
@ -584,17 +584,15 @@ static __forceinline StereoOut32 MixVoice( uint coreidx, uint voiceidx )
// Store Value for eventual modulation later // Store Value for eventual modulation later
// Pseudonym's Crest calculation idea. Actually calculates a crest, unlike the old code which was just peak. // Pseudonym's Crest calculation idea. Actually calculates a crest, unlike the old code which was just peak.
u32 Amplitude = std::abs(Value); if(vc.PV1 < vc.NextCrest)
if(Amplitude < vc.NextCrest)
{ {
vc.OutX = vc.NextCrest; vc.OutX = MulShr32(vc.NextCrest, vc.ADSR.Value);
vc.NextCrest = 0; vc.NextCrest = -0x8000;
} }
if(Amplitude > vc.PrevAmp) if(vc.PV1 > vc.PV2)
{ {
vc.NextCrest = Amplitude; vc.NextCrest = vc.PV1;
} }
vc.PrevAmp = Amplitude;
if( IsDevBuild ) if( IsDevBuild )
DebugCores[coreidx].Voices[voiceidx].displayPeak = std::max(DebugCores[coreidx].Voices[voiceidx].displayPeak,(s32)vc.OutX); DebugCores[coreidx].Voices[voiceidx].displayPeak = std::max(DebugCores[coreidx].Voices[voiceidx].displayPeak,(s32)vc.OutX);

View File

@ -180,9 +180,8 @@ struct V_Voice
s32 PV1; s32 PV1;
// Last outputted audio value, used for voice modulation. // Last outputted audio value, used for voice modulation.
u32 OutX; s32 OutX;
u32 NextCrest; // temp value for Crest calculation s32 NextCrest; // temp value for Crest calculation
u32 PrevAmp; // temp value for Crest calculation (abs of last value)
// SBuffer now points directly to an ADPCM cache entry. // SBuffer now points directly to an ADPCM cache entry.
s16 *SBuffer; s16 *SBuffer;

View File

@ -330,8 +330,7 @@ void V_Voice::Start()
PV1 = PV2 = 0; PV1 = PV2 = 0;
PV3 = PV4 = 0; PV3 = PV4 = 0;
PrevAmp = 0; NextCrest = -0x8000;
NextCrest = 0;
} }
else else
{ {