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