CMS: Do proper clipping of the sound data on generation.

This fixes some overflows/underflows which resulted in crackling.
This commit is contained in:
Johannes Schickel 2011-08-09 23:57:22 +02:00
parent 74560278b2
commit b95bbb2ace

View File

@ -244,8 +244,8 @@ void CMSEmulator::update(int chip, int16 *buffer, int length) {
}
}
/* write sound data to the buffer */
buffer[j*2] += output_l / 6;
buffer[j*2+1] += output_r / 6;
buffer[j*2+0] = CLIP<int>(buffer[j*2+0] + output_l / 6, -32768, 32767);
buffer[j*2+1] = CLIP<int>(buffer[j*2+1] + output_r / 6, -32768, 32767);
}
}