What does the signed_saturate_rshift(val, 16, 0); ] in the mixer class do?
I assume the val variable cannot overflow so it is an overflow preventer... but what does the other 2 parameters (..,16,0) specify ?
More complete code:
The above is from @paul s mixer class https://github.com/PaulStoffregen/Audio/blob/master/mixer.cpp
I assume the val variable cannot overflow so it is an overflow preventer... but what does the other 2 parameters (..,16,0) specify ?
More complete code:
Code:
static void applyGain(int16_t *data, int32_t mult)
{
const int16_t *end = data + AUDIO_BLOCK_SAMPLES;
do {
int32_t val = *data * mult;
*data++ = signed_saturate_rshift(val, 16, 0);
} while (data < end);
}
The above is from @paul s mixer class https://github.com/PaulStoffregen/Audio/blob/master/mixer.cpp