git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@203 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
ramapcsx2 2008-10-16 14:10:31 +00:00 committed by Gregory Hainaut
parent 6c2d95f27d
commit a6eba17dfa
2 changed files with 22 additions and 28 deletions

View File

@ -363,8 +363,7 @@ void GetVoiceValues(s32& Value) {
vc.SP+=pitch;
while(vc.SP>=4096)
{
//this isn't needed. it's garaunteed to be assigned a valid value.
//DT=0;
DT=0;
if(vc.Noise)
GetNoiseValues(DT);
@ -380,6 +379,7 @@ void GetVoiceValues(s32& Value) {
}
CalculateADSR();
// CalculateADSR();
if(vc.ADSR.Phase==0)
{
@ -388,18 +388,12 @@ void GetVoiceValues(s32& Value) {
}
else
{
// if SP is zero then we landed perfectly on a sample source, no
// interpolation necessary (this is important too, since the
// interpolator will pick the wrong sample to mix).
if(Interpolation==0 || vc.SP == 0) {
if(Interpolation==0) {
Data = vc.PV1;
}
else if(Interpolation==1) //linear
{
// [Air]: Inverted the interpolation delta. The old way was generating
// inverted waveforms.
s64 t0 = vc.PV2 - vc.PV1;
s64 t0 = vc.PV1 - vc.PV2;
s64 t1 = vc.PV1;
Data = (((t0*vc.SP)>>12) + t1);
}
@ -409,11 +403,11 @@ void GetVoiceValues(s32& Value) {
s64 a1 = vc.PV4 - vc.PV3 - a0;
s64 a2 = vc.PV1 - vc.PV4;
s64 a3 = vc.PV2;
s64 mu = 4096-vc.SP;
s64 mu = vc.SP;
s64 t0 = ((a0 )*mu)>>18; //all 3 were >>12, was causing ugly, loud overflow sound
s64 t1 = ((t0+a1)*mu)>>18;
s64 t2 = ((t1+a2)*mu)>>18;
s64 t0 = ((a0 )*mu)>>12;
s64 t1 = ((t0+a1)*mu)>>12;
s64 t2 = ((t1+a2)*mu)>>12;
s64 t3 = ((t2+a3));
Data = t3;
@ -423,7 +417,7 @@ void GetVoiceValues(s32& Value) {
vc.OutX=abs(Value);
}
//if(vc.PeakX<vc.OutX) vc.PeakX=vc.OutX;
if(vc.PeakX<vc.OutX) vc.PeakX=vc.OutX;
}
/////////////////////////////////////////////////////////////////////////////////////////
@ -1159,4 +1153,4 @@ buffer[MIX_DEST_B0] = (FB_ALPHA * ACC0) - FB_A0 * (FB_ALPHA^0x8000) - FB_B0 * FB
buffer[MIX_DEST_B1] = (FB_ALPHA * ACC1) - FB_A1 * (FB_ALPHA^0x8000) - FB_B1 * FB_X;
-----------------------------------------------------------------------------
*/
*/

View File

@ -282,7 +282,7 @@ float valAccum1 = 1.0f;
float valAccum2 = 1.0f;
u32 numAccum = 1;
const u32 numUpdates = 96;
const u32 numUpdates = 112;
float lastTempo=1;
float cTempo=1;
@ -312,21 +312,21 @@ void UpdateTempoChange()
s32 bufferSize = sndBuffer->GetBufferSize();
//Emergency stretch to compensate for FPS fluctuations and keep the buffers happy
bool a=(bufferUsage < CurBufferSize * 4);
bool b=(bufferUsage >= (bufferSize - CurBufferSize * 4));
bool a=(bufferUsage < CurBufferSize * 2.5);
bool b=(bufferUsage >= (bufferSize - CurBufferSize * 2.5));
if(a!=b)
{
if (bufferUsage < CurBufferSize * 1.5) { cTempo*=0.70f; }
else if(bufferUsage < CurBufferSize * 2) { cTempo*=0.90f; }
else if(bufferUsage < CurBufferSize * 3.9) { cTempo*=0.95f; }
if (bufferUsage < CurBufferSize) { cTempo*=0.7f; }
else if(bufferUsage < CurBufferSize * 2) { cTempo*=0.90f; }
else if(bufferUsage < CurBufferSize * 2.5) { cTempo*=0.95f; }
if (bufferUsage > (bufferSize - CurBufferSize * 1.5)) { cTempo*=1.30f; }
else if(bufferUsage > (bufferSize - CurBufferSize * 2)) { cTempo*=1.10f; }
else if(bufferUsage > (bufferSize - CurBufferSize * 3.9)) { cTempo*=1.05f; }
if (bufferUsage > (bufferSize - CurBufferSize)) { cTempo*=1.3f; }
else if(bufferUsage > (bufferSize - CurBufferSize * 2)) { cTempo*=1.10f; }
else if(bufferUsage > (bufferSize - CurBufferSize * 2.5)) { cTempo*=1.05f; }
if (cTempo != lastTempo) {
//printf("%f %d\n",cTempo,bufferUsage);
printf("%f %d\n",cTempo,bufferUsage);
pSoundTouch->setTempo(cTempo);
}
}
@ -354,12 +354,12 @@ void UpdateTempoChange()
if((valAccum < 1.05f) && (valAccum > 0.95f) /*&& (valAccum != 1)*/)
{
//printf("Timestretch Debug > Playbackpeed: %f (difference disregarded, using 1.0).\n",valAccum);
printf("Timestretch Debug > Playbackpeed: %f (difference disregarded, using 1.0).\n",valAccum);
valAccum = 1.0f;
}
else
{
// printf("Timestretch Debug > Playbackpeed: %f\n",valAccum);
printf("Timestretch Debug > Playbackpeed: %f\n",valAccum);
}
if (valAccum != lastTempo) //only update soundtouch object when needed