[chuck-users] Begin the beguine

Hans Aberg haberg-1 at telia.com
Sun Sep 30 17:16:38 EDT 2012


On 30 Sep 2012, at 21:41, Alberto Alassio wrote:

> Me again.

I add some comments, in addition to Kassen's.

> Looking at the examples, now I'm messing with Chirp.
> I cannot understand what Tinc and Inc are.

As ChucK is case sensitive, one normally keep the case.

> I think that tinc is something like the time of every step from a freq to another one, is it right?

Probably short for "time increment" - typed as duration by "dur". Just a function argument variable.

This file illustrates function name (or Koenig) overloading: there are two different functions named 'chirp' with differently typed arguments.

> And Inc is how much freq increases according to tinc's time, is it correct?

The LHS of the line
  duration / tinc => float steps;
divides the two durations, the RHS declares a float variable 'steps', and '=>' assigns LHS to this variable. So this divides the time interval of length 'duration' into 'steps' steps of length 'tinc'.

Then the line
  ( target - src ) / steps => float inc;
divides the frequency interval from 'src' to 'target' into 'steps' steps of length 'tinc'.

> But what is -count-? A counter of what? And  what " while ( count < steps ) " and " 1+ => count " mean?

This is just a loop counter. The line
  float count;
declares it and initializes it to 0. Then "while (count < steps) {...}" loops over "{...}" as long '1 +=> count' does not increment up to 'steps' or beyond - which could happen, due to round-off errors, as they are floats. So the proper way would be to ensure 'steps' is an 'int'.

Here, 'x +=> y' is the same as the 'y += x' of C/C++: instead of assigning x to y, it does x + y => y, thus adding x to y.

Hans





More information about the chuck-users mailing list