Flanging Effect

Basically it's the same as echo, delay time usually sweep sinusoidally from 0.5ms to 2ms.
Basic algorithm in C++:
while (--sampleFrames >= 0)

    {
        n = n++; // initialized with n = 0
        deltai = delayMin + (delayMax-delayMin)/2 *(1+ sin(2 * pi * freq * 1/44100 * n)); // sweep 0.5 – 2 ms

        // Delay line using Lagrange interpolator
        di = floorf(deltai) - 1;
        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;

        //Lelf channel only here
        if (inPointL == delayBufferSize)
           inPointL = 0;
        delay_bufferL[inPointL++] = gain*(*in1) +  room * feedbackL;
        for (i=0;i<4;i++){
            outPointL[i] = (inPointL - di + i);
            if (outPointL[i] < 0)
            outPointL[i] += delayBufferSize;
            listateL[i] = delay_bufferL[outPointL[i]];
        }
        feedbackL = (b0*listateL[0] + b1*listateL[1] + b2*listateL[2] + b3*listateL[3]);
        feedbackLOut = lowShelf(feedbackL); // used lowsheld filter within the loop 
}


Algorithm diagram by Dr. Abel



VST plug-in
flanging.cpp
flanging.hpp
flangingMain.cpp
flanging.dll

STK codes in C++ [Flanging.tar.gz]

Matlab codes to study the relationship with delay sample vs the frequency of the first peak of the comb filter:
flanging_temp.m
taoVsw.m

Reference:
[1] flanging history and a simple flanging algorithm from Professor Julius Smith's
website
[2] Phase Shift and Time Delay from Universal Audio(c) website