tis 2008-01-08 klockan 21:50 -0500 skrev Rich Caloggero:
OK, I'm not a math wiz or even a audio/dsp wiz, and certainly not a ChucK wiz. What exactly does this mean: now - (now % T) => now;
I've seen it before and am guessing it has something to do with periodicity, but not really sure how this statement works.
It's used to keep a bunch of shreds operating in sync so you can throw
new ones in, and remove old ones. like the otf_*.ck-files in the example
directory.
% means modulo, which means that chuck will compute the remainder of a
division.
7/3 = 2,333333333
or this:
7/3 = 6, r = 1.
It's like the division you (at least I did) learnt when you were a very
little kid and wasn't supposed to know about floats.
So, in our case:
now % beat => dur samples_from_last_beats
now - samples_from_last_beats => now; <--- go to next beat
Hope that helps,
Gasten
Ps. modulo can be used in many clever ways. for example, if you want to
count from 0 to 9 and imedietly start with 0 again, you could do
something like this (I'm not sure this is right - i'm not so good with
head-calculation, but you get the point):
0 => int x;
while (true) {
<<