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 <= length(x_t) output(i) = x_t(i) + (b_n * buffer(reader)); elseif i > length(x_t) output(i) = b_n * buffer(reader); end % Circular Buffer writer = writer + 1; if writer > length(buffer) writer = 1; end reader = reader + 1; if reader > 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.