have just started coding on chuck was looking for way to let s1 have 3 overtones flying around him i know it should be something other than rand2f to handle integers but my q is about ::ms in while i wonder which one of these are the right way to use them i thought the latter might be safe but it seems to give one never changing long note and maybe only one another is floating around but none of them give me an error style one: SinOsc s1 => PRCRev g => dac; SinOsc s2 => g; SinOsc s3 => g; SinOsc s4 => g; .25 => g.gain => g.mix; while( true ) { 500::ms => now; Std.rand2f(30.0, 220.0) => s1.freq; 170::ms => now; s1.freq() * Std.rand2f(8.0, 16.0) / 8.0 => s2.freq; 75::ms => now; s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 => s3.freq; 111::ms => now; s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 => s4.freq; } style two: SinOsc s1 => PRCRev g => dac; SinOsc s2 => g; SinOsc s3 => g; SinOsc s4 => g; .25 => g.gain => g.mix; while( true ) { 200::ms => now; Std.rand2f(30.0, 220.0) => s1.freq; } while( true ) { 170::ms => now; s1.freq() * Std.rand2f(8, 16) / 4.0 => s2.freq; } while( true ) { 75::ms => now; s2.freq() * Std.rand2f(16, 32) / 8.0 => s3.freq; } while( true ) { 111::ms => now; s2.freq() * Std.rand2f(16, 32) / 8.0 => s4.freq; } -- 2g http://micro.ispretty.com
tor 2007-08-02 klockan 07:34 +0900 skrev 2g:
have just started coding on chuck was looking for way to let s1 have 3 overtones flying around him i know it should be something other than rand2f to handle integers but my q is about ::ms in while
i wonder which one of these are the right way to use them i thought the latter might be safe but it seems to give one never changing long note and maybe only one another is floating around but none of them give me an error
style one:
SinOsc s1 => PRCRev g => dac; SinOsc s2 => g; SinOsc s3 => g; SinOsc s4 => g; .25 => g.gain => g.mix; while( true ) { 500::ms => now; Std.rand2f(30.0, 220.0) => s1.freq; 170::ms => now; s1.freq() * Std.rand2f(8.0, 16.0) / 8.0 => s2.freq; 75::ms => now; s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 => s3.freq; 111::ms => now; s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 => s4.freq; }
style two:
SinOsc s1 => PRCRev g => dac; SinOsc s2 => g; SinOsc s3 => g; SinOsc s4 => g; .25 => g.gain => g.mix; while( true ) { 200::ms => now; Std.rand2f(30.0, 220.0) => s1.freq; } while( true ) { 170::ms => now; s1.freq() * Std.rand2f(8, 16) / 4.0 => s2.freq; } while( true ) { 75::ms => now; s2.freq() * Std.rand2f(16, 32) / 8.0 => s3.freq; } while( true ) { 111::ms => now; s2.freq() * Std.rand2f(16, 32) / 8.0 => s4.freq; }
Okey, I'm gonna teach you something about while-loops. A while loop will do whatever is in the brackets behind the statements until the expression inside the parenthesis is false. When it is false, it continues to the next thing after the close bracket (in your case the next while-loop). illustrated with chuck-code: 1 => int i; while (i < 10) { <<<i>>>; //print i i + 1 => i; } <<<"done">>>; Notice how it prints the numbers 1 to 9, and finally "done"? Now, look at your second example. Does the expression never return false? No, because you have hard coded "true" inside it. So, your first one should work as you want it, and your second won't. (Yes, you can advance time how many times as you want in whatever code-context you want) By the way, have you checked out the Blit-UGen? I think that one might satisfy your needs. Hope that helps, Gasten
oh
maybe in the second way
am just looping the 1st while only?
maybe it was a bit too early for me to ask things on the list
(only i can do is modifying the tut)
i thought
100::ms => now;
was something like "100msec later do ..." or "every 100msec do ..."
but i happened to find that in () expression of while
mmm
i'll go through a bit more ahead in the manual
yes
then i'll find Blit-UGen waiting for me?
On 8/2/07, Martin Ahnelöv
tor 2007-08-02 klockan 07:34 +0900 skrev 2g:
have just started coding on chuck was looking for way to let s1 have 3 overtones flying around him i know it should be something other than rand2f to handle integers but my q is about ::ms in while
i wonder which one of these are the right way to use them i thought the latter might be safe but it seems to give one never changing long note and maybe only one another is floating around but none of them give me an error
style one:
SinOsc s1 => PRCRev g => dac; SinOsc s2 => g; SinOsc s3 => g; SinOsc s4 => g; .25 => g.gain => g.mix; while( true ) { 500::ms => now; Std.rand2f(30.0, 220.0) => s1.freq; 170::ms => now; s1.freq() * Std.rand2f(8.0, 16.0) / 8.0 => s2.freq; 75::ms => now; s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 => s3.freq; 111::ms => now; s2.freq() * Std.rand2f(16.0, 32.0) / 16.0 => s4.freq; }
style two:
SinOsc s1 => PRCRev g => dac; SinOsc s2 => g; SinOsc s3 => g; SinOsc s4 => g; .25 => g.gain => g.mix; while( true ) { 200::ms => now; Std.rand2f(30.0, 220.0) => s1.freq; } while( true ) { 170::ms => now; s1.freq() * Std.rand2f(8, 16) / 4.0 => s2.freq; } while( true ) { 75::ms => now; s2.freq() * Std.rand2f(16, 32) / 8.0 => s3.freq; } while( true ) { 111::ms => now; s2.freq() * Std.rand2f(16, 32) / 8.0 => s4.freq; }
Okey, I'm gonna teach you something about while-loops. A while loop will do whatever is in the brackets behind the statements until the expression inside the parenthesis is false. When it is false, it continues to the next thing after the close bracket (in your case the next while-loop).
illustrated with chuck-code:
1 => int i;
while (i < 10) { <<<i>>>; //print i i + 1 => i; } <<<"done">>>;
Notice how it prints the numbers 1 to 9, and finally "done"?
Now, look at your second example. Does the expression never return false? No, because you have hard coded "true" inside it.
So, your first one should work as you want it, and your second won't. (Yes, you can advance time how many times as you want in whatever code-context you want)
By the way, have you checked out the Blit-UGen? I think that one might satisfy your needs.
Hope that helps, Gasten
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
fre 2007-08-03 klockan 05:53 +0900 skrev 2g:
oh maybe in the second way am just looping the 1st while only?
maybe it was a bit too early for me to ask things on the list (only i can do is modifying the tut)
Keep modifying! That's a very very good way to learn. And ask away, too.
i thought 100::ms => now; was something like "100msec later do ..." or "every 100msec do ..." but i happened to find that in () expression of while
About the code-chunks which have while ( 100::ms => now ) { /* code */ } in them... Well, they are using a bit more advanced syntax. it's short for: while(true) { 100::ms => now; //something } And about the time... "100::ms => now;" means that chuck will pause in the code for 100 ms and compute the audio. That's the only way to get any sound. And, yes, it means both "100msec later do ..." and "every 100msec do ...". When chuck gets to a "100::ms => now;" it will pause there (and make noise) until it continues 100 ms later. But if you got code that looks like this: SinOsc s => dac; 440.0 => s.freq; while(true) { 100::ms => now; Std.rand2f(110.0, 990.0) => s.freq; } you can say that "every 100msec do ...", because that's exactly what it's doing.
mmm i'll go through a bit more ahead in the manual yes then i'll find Blit-UGen waiting for me?
Well, actually.. I don't really know how far you've gotten in the manual, but I would recommend that you play with ugens at the same time as you go through it. When you think you know the most importnat, and can write a basic patch without looking in the manual, you can start to let go of it. By the way, the ugens isn't even IN the manual. They are collected on the ugen-reference page on the website. http://chuck.cs.princeton.edu/doc/program/ugen.html Hope that helps, Gasten
participants (2)
-
2g
-
Martin Ahnelöv