
On Thu, Sep 27, 2012 at 02:36:20PM +0200, Alberto Alassio wrote:
I was trying to open the otf examples you told me and I got a question about period. what does
T - (now % T) => now;
means?
The "%" operator means "modulo". X modulo Y means; the remainder of dividing X by Y. So; "9 % 4" will be 1. Check? What we are doing here is that we start counting in increments of T since time 0. This line of code makes us wait for the next beat, being a integer multiple of T. After all; (now % T) must be the time since the last "beat", so "T - (now % T)" refers to the amount of time to go until the next beat. The total expression will then advance time until the next beat, more or less like you will wait a bit until falling in on your guitar when entering a jam session. That is actually exactly what happens in these examples; each file will wait until the next beat, then start playing, so because they are all aware of T and know we start at 0 they do not need to communicate with each other about this. Make sense now? Kas.