Skip to content

Commit ad3a214

Browse files
committed
lagrange interpolation optimization
1 parent 3924429 commit ad3a214

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/juce_dsp/processors/juce_DelayLine.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,16 @@ class DelayLine
253253
auto value3 = samples[index3];
254254
auto value4 = samples[index4];
255255

256+
auto d0 = delayFrac;
256257
auto d1 = delayFrac - 1.f;
257258
auto d2 = delayFrac - 2.f;
258259
auto d3 = delayFrac - 3.f;
259260

260-
auto c1 = -d1 * d2 * d3 / 6.f;
261-
auto c2 = d2 * d3 * 0.5f;
262-
auto c3 = -d1 * d3 * 0.5f;
263-
auto c4 = d1 * d2 / 6.f;
261+
auto a = d1 * d2 / 6.f;
262+
auto b = d3 * d0 * 0.5f;
264263

265-
return value1 * c1 + delayFrac * (value2 * c2 + value3 * c3 + value4 * c4);
264+
return a * (d0 * value4 - d3 * value1)
265+
+ b * (d2 * value2 - d1 * value3);
266266
}
267267
else if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::Thiran>)
268268
{

0 commit comments

Comments
 (0)