Coding a Variable Delay with LFO (MATLAB/C) I am trying to code a Variable Delay (chorus/flanger) effect in MATLAB using a paradigm that would be friendly for porting to a lower level language like C.  What I currently have is a working echo/delay that uses read/write indices to write into a buffer.  I'm now trying to use an LFO (low freq sine wave) to modulate the delay time but can't seem to figure it out.  Sometimes my errors sound "cool" but they aren't correct or what I was trying to do.

% Create LFO
lfo = abs(sin(2*pi*lfo_rate*[0:length(output)]/fs));

    % Perform the Echo Loop
    for i=1:length(x_t)

    % Write Sample Into Delay Buffer
    buffer(writer) = x_t(i);

    % Get All Delay Into Output
    if i &lt;= length(x_t)
        output(i) = x_t(i) + (b_n * buffer(reader));
    elseif i &gt; length(x_t)
        output(i) = b_n * buffer(reader);
    end

    % Circular Buffer
    writer = writer + 1;
        if writer &gt; length(buffer)
            writer = 1;
        end
    reader = reader + 1;
        if reader &gt; length(buffer)
            reader = 1;
        end
    end


I've been trying to use the LFO Vector to modulate the readers position, but I'm pretty much stuck and the stuff I can find online about this sort of thing isn't too helpful either.
I answer this way because i don't have permission for comments.
I don't have a complete solution. What happens with an chorus flanger is this.

Signal xt goes in split in two(or maybe more) signal paths and mixed together at the end.
The difference is the length of the delay (Flanger &lt;10ms and chorus 20 - 60ms).
First your Lfo discription isn't right.
It should me something like :lfo = A *sin(2*pi*lfo_rate*[0:length(output)]/fs) + Offset; Where A is half the time (Positive and negative) and offset the center time where the LFO is turning around.
And `A =&lt; offset' otherwise the time gets negative

The difficulty is i think a variable buffersize. let say a chorus center time is 50 ms with ±10 ms delay. no Lfo you have 44100 * 20/1000 = 2205 samples. the max buffer = 2646 samples and the min buffer = 1764 Samples.

Hope you can do something with the info