[chuck-users] a couple of questions

Robert Poor rdpoor at gmail.com
Mon Jun 22 19:34:07 EDT 2009

Hi Dimitris:

I'm not the most qualified to answer your questions, but I'll take a  
shot (besides my brain needs a break from the research I've been  
doing).  If  anyone wants to correct me, please jump in.

Passing default values: As Far As I Know, ChucK does not support  
default values in formal arguments.

Of "now" and timestamps: You are well on your way to discovering a  
fundamental truth about ChucK: "now" is the current time in the  
virtual machine.  In effect, it advances only when sound is being  
synthesized, not when your code is being run.  From the point of view  
of your code, now advances only when you execute some form of:
	x => now;
where x is a duration, a time, or an event.  So the following code  
will advance "now" by 1000 units (where one unit turns out to be one  
	<<< now >>>;
	1000::samp => now;
	<<< now >>>;
On the other hand, the following code will not advance now at all:
	<<< now >>>;
	for (0 => int i; i<REALLY_HUGE_NUMBER; i++) {
		Math.sqrt(2.0) => float y;
	<<< now >>>;
... since the code doesn't have any calls to "x => now".

Moral of the story: ChucKs 'now' facility is for precise timing of  
synthesized audio.  It's not the same as a Unix time function.

Does that answer your question?


- Rob

On 22 Jun 2009, at 16:15, Bozelos Dimitris wrote:

> Hello everyone!
> 1) can default values be passed to a function? I've tried all of
>     fun void test( int i = 0)
>     fun void test( 0 => int i)
>     fun void test( int i => 0)
> but nothing works and in the manual nothing is stated. Anybody  
> knows? I would be surprised if you cannot pass default values to a  
> function. Why if so?
> 2) by printing <<< now >>>; I get the timestamp from the virtual  
> machine, but if I do
> <<<now>>>;
> /// do some stuff
> <<<now>>>;
> the two outputs are exactly the same even if the stuff in between  
> last for some seconds. Why? How can I know the duration of something?
> Cheers,
> Dimitris
> Χρησιμοποιείτε Yahoo!
> Βαρεθήκατε τα ενοχλητικά μηνύ ματα  
> (spam); Το Yahoo! Mail διαθέτει την καλύτερη  
> δυνατή προστασία κατά των  
> ενοχλητικών μηνυμάτων
> http://login.yahoo.com/config/mail?.intl=gr  
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090622/4020f2a4/attachment.html>

More information about the chuck-users mailing list