Delay, Ring Buffer [Stereo]

Download

     Disclaimer...

23   desc:Ring Buffer [2ch], 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   buf2 = buflength; // buffer2 exists at offset 22050
34  
35   @slider
36   delay = srate * slider1 / 1000.0; // # of samples
37   bufposR = bufposW - delay;
38   bufposR < 0 ? bufposR = bufPosR + buflength;
39  
40   @sample
41   x = spl0;
42   spl0 = buf[bufposR];
43   buf[bufposW] = x;
44  
45   // delays both channels by same amount, no mix
46   x = spl1;
47   spl1 = buf2[bufposR];
48   buf2[bufposW] = x;
49  
50   bufposR = bufposR + 1 ;
51   bufposR > buflength ? bufposR = 0;
52   bufposW = bufposW + 1 ;

Download