I am attempting to implement a fractional delay line in Matlab which operates in real time, uses an object-oriented approach, and whose length can be modulated each time a sample is processed. I have already successfully implemented a fractional delay line, but I am having some trouble with the modulation step.
Below are some graphs of my current output:
As you can see, discontinuities occur when the current position approaches a part of the buffer which has not been encountered yet, due to the changing length of the buffer. I am wondering if anyone may know of a way to smooth these discontinuities out. My delay line uses linear interpolation at the moment, and I was thinking of using the first-order all pass filter interpolation method instead, but I am not sure if that would help at all, so I wanted to seek some advice first.
The end goal is to have this be a flanger effect for audio, so if anyone has expertise on this particular topic it would be greatly appreciated.
Some specifics for graph interpretation:
LFO period: 2 seconds
LFO shape: triangle
Base delay time: 8 ms
Max delay time: 18 ms
Process function for delay line:
function xDelayed = process(obj, x, L) % Current position index i = obj.currentPos; % Modulate delay time L_int = floor(L); obj.bufferLen = L_int+1; obj.delta = L-L_int; obj.delayLen = L; % Output delayed sample if i < obj.bufferLen xDelayed = obj.delta*obj.buffer(i)+(1-obj.delta)*obj.buffer(i+1); else xDelayed = obj.delta*obj.buffer(i)+(1-obj.delta)*obj.buffer(1); end % Save current sample to buffer obj.buffer(i) = x; % Increment delay line or go back to beginning if currently at % last position if i >= obj.bufferLen obj.currentPos = 1; else obj.currentPos = i+1; end end
Any advice on how to handle these discontinuities or improve my implementation would be greatly appreciated. Thank you, and please let me know if you need any additional information. I apologize if what I posted here is not sufficient.