[sdiy] help understanding circular buffers for delay line

dan snazelle subjectivity at hotmail.com
Fri Mar 2 16:03:00 CET 2012


thanks to everyones really great replys!

i will be studying them in more detail today, trying them out, etc.


this has been one of those concepts that just looking at random code on the internet has not really helped


however, it has been the first topic ive encountered in C which has really made me want to learn more about pointers

which is a good thing i think






On Mar 2, 2012, at 12:52 AM, Matthew Smith wrote:

> Quoth Andrew Simper at 02/03/12 14:37...
>> If you are using a power of 2 buffer length then just use an "&" of
>> the length - 1 for starters as this will be much easier to code, worry
>> about optimisation later:
>> 
>> buffer [index&  (length - 1)]
>> 
>> so for a fixed integer sample delay you would have:
>> 
>> inpos = (inpos + 1)&  (length - 1);
>> buffer [inpos] = input;
>> output = buffer [(inpos - delay)&  ( length - 1)];
>> 
>> and make sure delay is less than length - 1
> 
> Cool, thanks for that little optimisation.
> 
> Logical operation should mean that the process will take a more predictable time to execute, unlike using conditionals.
> 
> -- 
> Matthew Smith
> 
> Business: http://www.smiffytech.com
> Blog:     http://www.smiffysplace.com
> Linkedin: http://www.linkedin.com/in/smiffy
> Flickr:   http://www.flickr.com/photos/msmiffy
> Twitter:  http://twitter.com/smiffy
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
> 




More information about the Synth-diy mailing list