Fix buzzsaw noises in reverb by preventing integer wraparound in a couple of places

This commit is contained in:
Henrik Rydgard 2015-10-28 21:36:00 +01:00
parent 22f71f1e9a
commit 40246e894c
2 changed files with 6 additions and 4 deletions

View file

@ -647,8 +647,8 @@ void SasInstance::SetWaveformEffectType(int type) {
void SasInstance::ApplyWaveformEffect() {
// First, downsample the send buffer to 22khz. We do this naively for now.
for (int i = 0; i < grainSize / 2; i++) {
sendBufferDownsampled[i * 2] = sendBuffer[i * 4];
sendBufferDownsampled[i * 2 + 1] = sendBuffer[i * 4 + 1];
sendBufferDownsampled[i * 2] = clamp_s16(sendBuffer[i * 4]);
sendBufferDownsampled[i * 2 + 1] = clamp_s16(sendBuffer[i * 4 + 1]);
}
// Volume max is 0x1000, while our factor is up to 0x8000. Shifting right by 3 fixes that.