diff --git a/src/rvoice/fluid_iir_filter.c b/src/rvoice/fluid_iir_filter.c index 20c652deb..7529dae8c 100644 --- a/src/rvoice/fluid_iir_filter.c +++ b/src/rvoice/fluid_iir_filter.c @@ -391,7 +391,12 @@ void fluid_iir_filter_calc(fluid_iir_filter_t *iir_filter, } else if(FLUID_FABS(fres_diff) > 0.01f) { - static const int fres_incr_count = FLUID_BUFSIZE; + int fres_incr_count = FLUID_BUFSIZE; + fluid_real_t num_buffers = iir_filter->last_q; + fluid_clip(num_buffers, 1, 8); + // For high values of Q, the phase gets really steep. To prevent clicks when quickly modulating fres in this case, we need to smooth out "slower". + // This is done by simply using Q times FLUID_BUFSIZE samples for the interpolation to complete, capped at 8. + fres_incr_count *= num_buffers; iir_filter->fres_incr = fres_diff / (fres_incr_count); iir_filter->fres_incr_count = fres_incr_count; iir_filter->target_fres = fres;