Commit b58469d5 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Optimize limiter performance by interpolating scale factor directly.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 83aab16e
......@@ -3,4 +3,3 @@ possible improvements:
limiter:
- flush
- interpolate scale factor directly
......@@ -61,12 +61,12 @@ Limiter::process_block (const float *in, float *out)
block_max = max (block_max, fabs (in[x]));
block_max2 = max (block_max2, fabs (in[x + block_size * n_channels]));
}
float left_max = max (last_block_max, block_max);
float right_max = max (block_max, block_max2);
const float scale_start = ceiling / max (last_block_max, block_max);
const float scale_end = ceiling / max (block_max, block_max2);
for (size_t i = 0; i < block_size; i++)
{
const float alpha = float (i) / block_size;
const float scale = ceiling / (left_max * (1 - alpha) + right_max * alpha);
const float scale = scale_start * (1 - alpha) + scale_end * alpha;
// debug_scale (scale);
for (uint c = 0; c < n_channels; c++)
......
......@@ -50,7 +50,7 @@ int
impulses()
{
Limiter limiter (2, 44100);
limiter.set_block_size_ms (5);
limiter.set_block_size_ms (3);
limiter.set_ceiling (0.9);
vector<float> in_all, out_all;
......
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