Forgot to scale a multiplication. Slightly better but quickly devolves into harsh noise.

This commit is contained in:
Henrik Rydgard 2015-10-27 15:56:11 +01:00
parent 9bb8aff715
commit 06fec54dba
2 changed files with 4 additions and 5 deletions

View File

@ -546,14 +546,12 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {
int voicesPlayingCount = 0;
int sendVolumeSum = 0; // Figure out if we actually need to run the effect. This can cut off echo trails though so TODO: Let's remove after debugging.
for (int v = 0; v < PSP_SAS_VOICES_MAX; v++) {
SasVoice &voice = voices[v];
if (!voice.playing || voice.paused)
continue;
voicesPlayingCount++;
MixVoice(voice);
sendVolumeSum += voice.effectLeft + voice.effectRight;
}
// Then mix the send buffer in with the rest.
@ -564,7 +562,7 @@ void SasInstance::Mix(u32 outAddr, u32 inAddr, int leftVol, int rightVol) {
if (outputMode == PSP_SAS_OUTPUTMODE_MIXED) {
// Okay, apply effects processing to the Send buffer.
// TODO: Is this only done in PSP_SAS_OUTPUTMODE_MIXED?
if (sendVolumeSum && waveformEffect.type != PSP_SAS_EFFECT_TYPE_OFF) {
if (waveformEffect.type != PSP_SAS_EFFECT_TYPE_OFF) {
ApplyWaveformEffect();
// TODO: Mix send when it has proper values, probably based on dry/wet?
if (inp) {

View File

@ -226,6 +226,7 @@ void SasReverb::ProcessReverb(int16_t *output, const int16_t *input, size_t inpu
// This runs at 22khz.
// Very unoptimized, straight from the description. Can probably be reformulated into something way more efficient.
// For example, we could just do the whole thing in floating point. Should actually be faster.
for (int i = 0; i < inputSize; i++) {
int16_t LeftInput = input[i * 2];
int16_t RightInput = input[i * 2 + 1];
@ -246,9 +247,9 @@ void SasReverb::ProcessReverb(int16_t *output, const int16_t *input, size_t inpu
b[d.mRAPF1] = clamp_s16(Rout - (d.vAPF1*b[(d.mRAPF1 - d.dAPF1) * 4] >> 15));
Rout = b[(d.mRAPF1 - d.dAPF1)*4] + (b[d.mRAPF1*4] * d.vAPF1 >> 15);
// ___Late Reverb APF2(All Pass Filter 2, with input from APF1)________________
b[d.mLAPF2] = clamp_s16(Lout - d.vAPF2*b[(d.mLAPF2 - d.dAPF2)*4]);
b[d.mLAPF2] = clamp_s16(Lout - (d.vAPF2*b[(d.mLAPF2 - d.dAPF2)*4] >> 15));
Lout = b[(d.mLAPF2 - d.dAPF2)*4] + (b[d.mLAPF2*4] * d.vAPF2 >> 15);
b[d.mRAPF2] = clamp_s16(Rout - d.vAPF2*b[(d.mRAPF2 - d.dAPF2)*4]);
b[d.mRAPF2] = clamp_s16(Rout - (d.vAPF2*b[(d.mRAPF2 - d.dAPF2)*4] >> 15));
Rout = b[(d.mRAPF2 - d.dAPF2)*4] + (b[d.mRAPF2*4] * d.vAPF2 >> 15);
// ___Output to Mixer(Output volume multiplied with input from APF2)___________
output[i*2] = clamp_s16(Lout*volLeft >> 15);