I am developing an embedded DSP audio processor and am trying to implement a chorus effect. To my understanding, the chorus effect is multiple delayed versions of the original signal, where the delay itself is random. In my program I have set the delays to be randomly defined upon initialization and then remain static during the program execution.
The challenge I'm faced with is that in using a circular buffer to store my past signal, I cannot simply wrap delayed signals back around the circular buffer as there is multiple delays present.
With a single delay I can simply check if the delay required exceeds the current position in the circular buffer, if so, I can jump to the end of the circular buffer subtract the delay and add my current position in the circular buffer.
if (Delay > Current_Position_in_Buffer)
{
Circular_Array[Length_of_Array + Current_Position_in_Buffer - Delay];
}
else
{
Circular_Array[Current_Position_in_Buffer - Delay];
}
Is there an efficient way to check and adjust the position in my circular array of each delayed signal, without separately checking each delay with an if statement?