Commit 44207900 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Deal with saturation correctly for S16N volume

parent f0ee4072
......@@ -78,18 +78,32 @@ static void FilterFI32 (audio_mixer_t *mixer, block_t *block, float volume)
static void FilterS16N (audio_mixer_t *mixer, block_t *block, float volume)
{
const int32_t mult = volume * 0x10000;
int32_t mult = volume * 0x1.p16;
if (mult == 0x10000)
return;
int16_t *p = (int16_t *)block->p_buffer;
if (mult < 0x10000)
{
for (size_t n = block->i_buffer / sizeof (*p); n > 0; n--)
{
*p = (*p * mult) >> 16;
p++;
}
}
else
{
mult >>= 4;
for (size_t n = block->i_buffer / sizeof (*p); n > 0; n--)
{
int32_t v = (*p * mult) >> 12;
if (abs (v) > 0x7fff)
v = 0x8000;
*(p++) = v;
}
}
(void) mixer;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment