[sdiy] help understanding circular buffers for delay line

dan snazelle subjectivity at hotmail.com
Sat Mar 3 05:36:33 CET 2012


thanks
On Mar 2, 2012, at 11:22 PM, Andrew Simper wrote:

> On 3 March 2012 11:07, dan snazelle <subjectivity at hotmail.com> wrote:
>> 
>> 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
>> 
>> Andy
>> 
>> Ok
>> 
>> i just got some time to really study this Andy and I have some questions
>> (surprise)
>> 
>> 
>> define length  8000
>> byte buffer [length]
>> 
>> 
>> what is the inpos? is that the same as using a for loop with an i as in
>> matthews example?
>> 
>> and what is delay...is that the J for loop as in matthews example? or is
>> that a delaytime pot?
>> 
>> thanks for your help
>> 
> 
> I'm not sure which number field you are on that 8000 is a power of 2,
> but back in regular flat number land you would need 8192 = 2^13, or
> any other power of 2, depending on how long you want the delay and
> your sample rate.
> 
> inpos is the input index position (write head)
> delay is the number of samples delay, which you subtract from the
> inpos (with wrap) as the read head
> 
> Per sample you need write one sample and read another for output.
> Don't modulate the delay at all and everything will work out really
> nice. If you want to modulate the delay head then things get way more
> complicated to get something that sounds good and is efficient to run.
> 
> Andy
> 




More information about the Synth-diy mailing list