Skip to content

Commit 3134919

Browse files
committed
diff by zero
1 parent 23035e2 commit 3134919

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rvoice/fluid_iir_filter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ extern "C" void fluid_iir_filter_init_table(fluid_real_t sample_rate)
6060
template<typename R>
6161
static R interp_lin(R y0, R y1, R x0, R x1, R x)
6262
{
63-
return (y0 * (x1 - x) + y1 * (x - x0)) / (x1 - x0);
63+
return std::fabs(x1 - x0 <= 1 /* do not interpolate, if difference is less than a single cent */) ? y0 : (y0 * (x1 - x) + y1 * (x - x0)) / (x1 - x0);
6464
}
6565

6666
template<typename R>
@@ -112,7 +112,7 @@ static inline void fluid_iir_filter_calculate_coefficients(R fres,
112112
R omega = (R)(2.0 * M_PI) * (fres_hz / output_rate);
113113
coeff_accurate.sin = std::sin(omega);
114114
coeff_accurate.cos = std::cos(omega);
115-
115+
116116
std::cerr << "fres: " << std::fixed << std::setprecision(2) << fres_hz << " Hz | "
117117
<< "fres: " << std::fixed << std::setprecision(2) << fres << " Cents | "
118118
<< "sin: " << std::fixed << std::setprecision(6) << coeff.sin << " | "

0 commit comments

Comments
 (0)