[sdiy] help understanding circular buffers for delay line

Andrew Simper andy at cytomic.com
Fri Mar 2 09:57:54 CET 2012


On 2 March 2012 16:33, Matthew Smith <matt at smiffytech.com> wrote:
> Quoth Andrew Simper at 02/03/12 17:12...
> ...
>
>> Before any statements can be made about one thing being quicker than
>> another you really need to run tests on the target architecture and
>> measure cpu usage. Using '&' is just easier to code to get up and
>> running if you have a power of 2 buffer that you want to wrap around.
>
>
> It's not speed that's of concern to me, it's predictability.
>
> If I do a logical operation on a number, the same number of CPU cycles
> should occur each time. When a conditional situation arises (my original if
> statements,) depending on the outcome of the comparison, operations of
> differing numbers of CPU cycles will occur.  The more predictable the
> behaviour, the better - at least in my mind.
>
>
> --
> Matthew Smith

Compilers could possibly find it quite hard to optimise array access
via a bitwise and, since they can't easily predict where the memory
access will be. Depending on the platform and compiler and length of
the block of processing you may be better off manually splitting any
boundary conditions with 'if' statements to make the memory access of
the algorithm easier to predict inside each of the conditions when
looping over buffers. If you need single sample 'tick' functions then
the '&' could be better, but you are always best off testing such
things rather than guessing.

Andrew Simper



More information about the Synth-diy mailing list