further adjusted short output to be closer to the float output

This commit is contained in:
FIX94 2017-05-31 22:20:46 +02:00
parent e1773a635a
commit 4cce3eac98
No known key found for this signature in database
GPG Key ID: CE39016A19D8EADA

35
apu.c
View File

@ -343,24 +343,27 @@ bool apuCycle()
lastLPOutRight = curLPOutRight; lastLPOutRight = curLPOutRight;
lastHPOutRight = curHPOutRight; lastHPOutRight = curHPOutRight;
#else #else
int32_t curIn, curOut;
//gen output Left //gen output Left
int32_t curInLeft = ((p1OutLeft + p2OutLeft + wavOutLeft + noiseOutLeft))*(apuMasterVolLeft+1)<<7; curIn = ((p1OutLeft + p2OutLeft + wavOutLeft + noiseOutLeft))*(apuMasterVolLeft+1)<<7;
int32_t curLPOutLeft = lastLPOutLeft+((lpVal*(curInLeft-lastLPOutLeft))>>15); curOut = lastLPOutLeft+((lpVal*(curIn-lastLPOutLeft))>>15); //Set Left Lowpass Output
int32_t curHPOutLeft = (hpVal*(lastHPOutLeft+lastLPOutLeft-curLPOutLeft))>>15; curIn = (lastHPOutLeft+lastLPOutLeft-curOut); //Set Left Highpass Input
curIn += (curIn>>31)&1; //Add Sign Bit for proper Downshift later
lastLPOutLeft = curOut; //Save Left Lowpass Output
curOut = (hpVal*curIn)>>15; //Set Left Highpass Output
lastHPOutLeft = curOut; //Save Left Highpass Output
//Save Clipped Left Highpass Output
apuOutBuf[curBufPos++] = ((soundEnabled)?((curOut > 32767)?(32767):((curOut < -32768)?(-32768):curOut)):0);
//gen output Right //gen output Right
int32_t curInRight = ((p1OutRight + p2OutRight + wavOutRight + noiseOutRight))*(apuMasterVolRight+1)<<7; curIn = ((p1OutRight + p2OutRight + wavOutRight + noiseOutRight))*(apuMasterVolRight+1)<<7;
int32_t curLPOutRight = lastLPOutRight+((lpVal*(curInRight-lastLPOutRight))>>15); curOut = lastLPOutRight+((lpVal*(curIn-lastLPOutRight))>>15); //Set Right Lowpass Output
int32_t curHPOutRight = (hpVal*(lastHPOutRight+lastLPOutRight-curLPOutRight))>>15; curIn = (lastHPOutRight+lastLPOutRight-curOut); //Set Right Highpass Input
//set output Left curIn += (curIn>>31)&1; //Add Sign Bit for proper Downshift later
apuOutBuf[curBufPos++] = ((soundEnabled)?((curHPOutLeft > 32767)?(32767):((curHPOutLeft < -32768)?(-32768):curHPOutLeft)):0); lastLPOutRight = curOut; //Save Right Lowpass Output
//set output Right curOut = (hpVal*curIn)>>15; //Set Right Highpass Output
apuOutBuf[curBufPos++] = ((soundEnabled)?((curHPOutRight > 32767)?(32767):((curHPOutRight < -32768)?(-32768):curHPOutRight)):0); lastHPOutRight = curOut; //Save Right Highpass Output
//save HP and LP Left //Save Clipped Right Highpass Output
lastLPOutLeft = curLPOutLeft; apuOutBuf[curBufPos++] = ((soundEnabled)?((curOut > 32767)?(32767):((curOut < -32768)?(-32768):curOut)):0);
lastHPOutLeft = curHPOutLeft;
//save HP and LP Right
lastLPOutRight = curLPOutRight;
lastHPOutRight = curHPOutRight;
#endif #endif
return true; return true;
} }