Delay, Basic Ring Buffer

     Disclaimer...

23   desc:Ring Buffer [mono], v1.0.0
24  
25   slider1:50<1,500,1>Buffer Length [ms]
26  
27   @init
28   buf = 0; // buffer exists at offset 0
29   bufposR = 0;
30   delay = srate * 0.05; // 50 ms
31   bufposW = delay;
32   buflength = srate * 0.5; // 500 ms
33  
34   @slider
35   delay = srate * slider1 / 1000.0; // # of samples
36   bufposR = bufposW - delay;
37   bufposR < 0 ? bufposR = bufPosR + buflength;
38  
39   @sample
40   x = spl0;
41   spl0 = buf[bufposR];
42   buf[bufposW] = x;
43   bufposR = bufposR + 1 ;
44   bufposR > buflength ? bufposR = 0;
45   bufposW = bufposW + 1 ;
46   bufposW > buflength ? bufposW = 0;
47  
48   // only delays one channel - will not mix

One thought on “Delay, Basic Ring Buffer

Leave a Reply