Delay Line using Lagrange Interpolation


VST plug-in and C++ codes:

delay_line.cpp
delay_line.hpp
delay_lineMain.cpp

delay_line.dll


Matlab code for the delay part, can be added to the input signal:


%% write sample to delay buffer
wp = rem(wp+1, delaybuffersize); %% write pointer
delaybuffer(wp+1) = insignal(i);

%% read samples from delay buffer
di = fix(deltai) - 1;
rp = rem(wp - (di+[0:3]) + delaybuffersize, delaybuffersize); %%read pointers
listate = delaybuffer(rp+1);

%% apply Lagrange interpolator
t0 = deltai - di;
t1 = t0 - 1;
t2 = t0 - 2;
t3 = t0 - 3;
b0 = -t1*t2*t3/6;
b1 =  t0*t2*t3/2;
b2 = -t0*t1*t3/2;
b3 =  t0*t1*t2/6;
outsignal(i) = b0*listate(1) + b1*listate(2) + b2*listate(3) + b3*listate(4);