- Lookahead limiter (fixed latency)
- A lookahead limiter - similar to the original Lookahead Limiter, but
-with a constant latency of around 150ms and a reduced maximum lookahead
-time.
-
-
-
-
-
- b ? a : b;
-/* XXX
- sig = fabs(in_1[pos]) > fabs(in_2[pos]) ? fabs(in_1[pos]) :
- fabs(in_2[pos]);
-*/
-
- if (sig > max) {
- const float rel = lin2db(sig) - limit;
-
- if (rel / delay > peak / (float)peak_dist) {
- peak_dist = delay;
- peak = rel;
- }
- }
-
- /* Incremenatlly approach the correct attenuation for the next peak */
- atten -= (atten - peak) / (float)(peak_dist + 1);
-
- if (peak_dist-- == 0) {
- peak_dist = f_round(delay);
- peak = 0.0f;
- }
-
- /* Cacluate the apropriate gain reduction and write it back into the
- * buffer */
- gain = amp_buffer[(buffer_pos - f_round(delay)) & (buffer_len - 1)];
- amp_buffer[(buffer_pos - f_round(delay)) & (buffer_len - 1)] =
- 1.0f / db2lin(atten);
-
-gain=1.0f / db2lin(atten);
-
- buffer_write(out_1[pos], buffer[(2 * (buffer_pos + 1)) &
- buffer_mask] * gain);
- buffer_write(out_2[pos], buffer[(2 * (buffer_pos + 1)+1) &
- buffer_mask] * gain);
-
- /* Ensure that the signal really can't be over the limit */
-
-#if 0
-XXX FIXME XXX
- if (out_1[pos] < -max) {
- buffer_write(out_1[pos], -max);
- } else if (out_1[pos] > max) {
- buffer_write(out_1[pos], max);
- }
- if (out_2[pos] < -max) {
- buffer_write(out_2[pos], -max);
- } else if (out_2[pos] > max) {
- buffer_write(out_2[pos], max);
- }
-#endif
-
- buffer_pos++;
- }
-
- plugin_data->buffer_pos = buffer_pos;
- plugin_data->peak = peak;
- plugin_data->peak_dist = peak_dist;
- plugin_data->atten = atten;
- plugin_data->last_delay = delay;
-
- *(plugin_data->attenuation) = atten;
- *(plugin_data->latency) = buffer_len - 1;
- ]]>
-
- buffer);
- free(plugin_data->amp_buffer);
- ]]>
-
-
- Limit (dB)
- The maximum output amplitude. Peaks over this level will be attenuated as smoothly as possible to bring them as close as possible to this level.
-
-
-
-
- Lookahead time (s)
- The delay time used by the lookahead predictor. The longer the time the smoother the limiting will be, but will tend to make the changes in dynamic range more obvious.
-
-
-
-
- Attenuation (dB)
- The current limiting attenuation of the signal coming out of the delay
-buffer.
-
-
-
-
- Input 1
-
-
-
- Input 2
-
-
-
- Output 1
-
-
-
- Output 2
-
-
-
- latency
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-