<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>
just to chime in here - i'm VERY new to programming. how do you create this kind of concurrency? if, say, you wanted to create two while loops, but wanted them to run "side-by-side", but looping at different speeds, how would you do it?<br><br>for example:<br><br>while (true){ do something; 100::ms =&gt; now;}<br><br>and<br><br>while (true) {do something else; 150::ms =&gt; now;}<br><br>cheers<br><br>&gt; Date: Fri, 3 Aug 2007 05:53:57 +0900<br>&gt; From: electriclightheads@gmail.com<br>&gt; To: chuck-users@lists.cs.princeton.edu<br>&gt; Subject: Re: [chuck-users] can there be many ::ms in while?<br>&gt; <br>&gt; oh<br>&gt; maybe in the second way<br>&gt; am just looping the 1st while only?<br>&gt; <br>&gt; maybe it was a bit too early for me to ask things on the list<br>&gt; (only i can do is modifying the tut)<br>&gt; i thought<br>&gt; 100::ms =&gt; now;<br>&gt; was something like "100msec later do ..." or "every 100msec do ..."<br>&gt; but i happened to find that in () expression of while<br>&gt; <br>&gt; mmm<br>&gt; i'll go through a bit more ahead in the manual<br>&gt; yes<br>&gt; then i'll find Blit-UGen waiting for me?<br>&gt; <br>&gt; On 8/2/07, Martin Ahnelöv &lt;operagasten@gmail.com&gt; wrote:<br>&gt; &gt; tor 2007-08-02 klockan 07:34 +0900 skrev 2g:<br>&gt; &gt; &gt; have just started coding on chuck<br>&gt; &gt; &gt; was looking for way to let s1 have 3 overtones<br>&gt; &gt; &gt; flying around him<br>&gt; &gt; &gt; i know it should be something other than rand2f to handle integers<br>&gt; &gt; &gt; but my q is about ::ms in while<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; i wonder which one of these are the right way to use them<br>&gt; &gt; &gt; i thought the latter might be safe but it seems to give one never<br>&gt; &gt; &gt; changing long note<br>&gt; &gt; &gt; and maybe only one another is floating around<br>&gt; &gt; &gt; but none of them give me an error<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; style one:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; SinOsc s1 =&gt; PRCRev g =&gt; dac;<br>&gt; &gt; &gt; SinOsc s2 =&gt; g;<br>&gt; &gt; &gt; SinOsc s3 =&gt; g;<br>&gt; &gt; &gt; SinOsc s4 =&gt; g;<br>&gt; &gt; &gt; .25 =&gt; g.gain =&gt; g.mix;<br>&gt; &gt; &gt; while( true ) {<br>&gt; &gt; &gt;         500::ms =&gt; now;<br>&gt; &gt; &gt;         Std.rand2f(30.0, 220.0) =&gt; s1.freq;<br>&gt; &gt; &gt;         170::ms =&gt; now;<br>&gt; &gt; &gt;         s1.freq() * Std.rand2f(8.0, 16.0) / 8.0 =&gt; s2.freq;<br>&gt; &gt; &gt;         75::ms =&gt; now;<br>&gt; &gt; &gt;         s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 =&gt; s3.freq;<br>&gt; &gt; &gt;         111::ms =&gt; now;<br>&gt; &gt; &gt;         s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 =&gt; s4.freq;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt;<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; style two:<br>&gt; &gt; &gt;<br>&gt; &gt; &gt; SinOsc s1 =&gt; PRCRev g =&gt; dac;<br>&gt; &gt; &gt; SinOsc s2 =&gt; g;<br>&gt; &gt; &gt; SinOsc s3 =&gt; g;<br>&gt; &gt; &gt; SinOsc s4 =&gt; g;<br>&gt; &gt; &gt; .25 =&gt; g.gain =&gt; g.mix;<br>&gt; &gt; &gt; while( true ) {<br>&gt; &gt; &gt;         200::ms =&gt; now;<br>&gt; &gt; &gt;         Std.rand2f(30.0, 220.0) =&gt; s1.freq;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt; while( true ) {<br>&gt; &gt; &gt;         170::ms =&gt; now;<br>&gt; &gt; &gt;         s1.freq() * Std.rand2f(8, 16) / 4.0 =&gt; s2.freq;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt; while( true ) {<br>&gt; &gt; &gt;         75::ms =&gt; now;<br>&gt; &gt; &gt;         s2.freq() * Std.rand2f(16, 32) / 8.0 =&gt; s3.freq;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt; while( true ) {<br>&gt; &gt; &gt;         111::ms =&gt; now;<br>&gt; &gt; &gt;         s2.freq() * Std.rand2f(16, 32) / 8.0 =&gt; s4.freq;<br>&gt; &gt; &gt; }<br>&gt; &gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Okey, I'm gonna teach you something about while-loops. A while loop will<br>&gt; &gt; do whatever is in the brackets behind the statements until the<br>&gt; &gt; expression inside the parenthesis is false. When it is false, it<br>&gt; &gt; continues to the next thing after the close bracket (in your case the<br>&gt; &gt; next while-loop).<br>&gt; &gt;<br>&gt; &gt; illustrated with chuck-code:<br>&gt; &gt;<br>&gt; &gt; 1 =&gt; int i;<br>&gt; &gt;<br>&gt; &gt; while (i &lt; 10) {<br>&gt; &gt;         &lt;&lt;&lt;i&gt;&gt;&gt;; //print i<br>&gt; &gt;         i + 1 =&gt; i;<br>&gt; &gt; }<br>&gt; &gt; &lt;&lt;&lt;"done"&gt;&gt;&gt;;<br>&gt; &gt;<br>&gt; &gt; Notice how it prints the numbers 1 to 9, and finally "done"?<br>&gt; &gt;<br>&gt; &gt; Now, look at your second example. Does the expression never return<br>&gt; &gt; false? No, because you have hard coded "true" inside it.<br>&gt; &gt;<br>&gt; &gt; So, your first one should work as you want it, and your second won't.<br>&gt; &gt; (Yes, you can advance time how many times as you want in whatever<br>&gt; &gt; code-context you want)<br>&gt; &gt;<br>&gt; &gt; By the way, have you checked out the Blit-UGen? I think that one might<br>&gt; &gt; satisfy your needs.<br>&gt; &gt;<br>&gt; &gt;<br>&gt; &gt; Hope that helps,<br>&gt; &gt; Gasten<br>&gt; &gt;<br>&gt; &gt; _______________________________________________<br>&gt; &gt; chuck-users mailing list<br>&gt; &gt; chuck-users@lists.cs.princeton.edu<br>&gt; &gt; https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br>&gt; &gt;<br>&gt; <br>&gt; <br>&gt; -- <br>&gt; 2g<br>&gt; http://micro.ispretty.com<br>&gt; _______________________________________________<br>&gt; chuck-users mailing list<br>&gt; chuck-users@lists.cs.princeton.edu<br>&gt; https://lists.cs.princeton.edu/mailman/listinfo/chuck-users<br><br /><hr />Are you the Quizmaster?  <a href='http://specials.uk.msn.com/brainbattle' target='_new'>Play BrainBattle with a friend now! </a></body>
</html>