Circular buffer wrap around with chorus effect 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 &gt; 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?
If I understood correctly what you are asking, then this is probably more of a programming question... But the solution would be to use modular arithmetic to compute the position of the delay. With a length equal to a power of 2, this could be accomplished with an AND instruction.

const int Mask = (1 &lt;&lt; 16) - 1;
Circular_Array[(Current_Position_in_Buffer - Delay) &amp; Mask];


In this example, the length of your buffer is $2^{16}$.

More generally you can use the modulo operator, but it will be slower.