Skip to content
Forum Archive

Cyclic Array

7 posts

Synth-C#

Cyclic Array

A little experiment with a cyclic array.
TomyLobo#
you could optimize the whole thing a lot by using a cyclic buffer. that is, if you had 5 buffer entries you now do this

copy 3 to 4
copy 2 to 3
copy 1 to 2
copy 0 to 1
put new data into 0
use 0, 1, 2, 3, 4


using a cyclic buffer means you do the following:
bufnum=5

bufbase=(bufbase+1)%bufnum
use (bufbase+0)%bufnum, (bufbase+1)%bufnum, (bufbase+2)%bufnum, (bufbase+3)%bufnum, (bufbase+4)%bufnum

understood? 🙂
you save the copying time and shift the base index by +1 (the % is the modulo operation, which does a division and returns the rest
Synth-C#
you could optimize the whole thing a lot by using a cyclic buffer. that is, if you had 5 buffer entries you now do this
Uhm, i used a cyclic buffer...

Just look at the (simplified) code;

per frame:
ww=80; points per ring
hh=100; amount of rings
fc=(fc+1)%hh; offset, your bufbase
loop(ww,exec2(assign( gmegabuf(cc+ww*fc),
(getosc((cc/ww),.1,0))) ,assign(cc,cc+1))); assign
getosc data for each point on the ring.

per point:
z1=gmegabuf((pc+fc*ww+ww)%n); retreive array data and
counter the offset.
pc=pc+1; pointcounter