<br><br><div><span class="gmail_quote">On 8/27/07, <b class="gmail_sendername">2g</b> &lt;<a href="mailto:electriclightheads@gmail.com">electriclightheads@gmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
mmm...i seem to be writing same things too much<br>can&#39;t any of these done in list[] oriented ways?</blockquote><div><br><br>Sure!<br><br>I&#39;ll just take this ChunK (a ChunK is a unit of ChucK code, at least it should be) as a example and then you can see how far you get with that, ok?
<br>
&nbsp;</div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><a href="http://sa.ck">sa.ck</a>:<br><br>SinOsc sun1 =&gt; Pan2 ps1 =&gt; dac;<br>
SinOsc sun2 =&gt; Pan2 ps2 =&gt; dac;<br>SinOsc sun3 =&gt; Pan2 ps3 =&gt; dac;<br>SinOsc sun4 =&gt; Pan2 ps4 =&gt; dac;<br>SinOsc sun5 =&gt; Pan2 ps5 =&gt; dac;<br>SinOsc moon1 =&gt; Pan2 pm1 =&gt; dac;<br>SinOsc moon2 =&gt; Pan2 pm2 =&gt; dac;
<br>SinOsc moon3 =&gt; Pan2 pm3 =&gt; dac;<br>SinOsc moon4 =&gt; Pan2 pm4 =&gt; dac;<br>SinOsc moon5 =&gt; Pan2 pm5 =&gt; dac;<br>.1 =&gt; ps1.gain;<br>.1 =&gt; ps2.gain;<br>.1 =&gt; ps3.gain;<br>.1 =&gt; ps4.gain;<br>.1 =&gt; 
ps5.gain;<br>.1 =&gt; pm1.gain;<br>.1 =&gt; pm2.gain;<br>.1 =&gt; pm3.gain;<br>.1 =&gt; pm4.gain;<br>.1 =&gt; pm5.gain;</blockquote><div><br><br>========================<br>10 =&gt; int foo;<br>//some oscilators<br>SinOsc suns_moons[foo];
<br><br>//as many pans<br>Pan2 pans[foo];<br><br>//now we automate and from here on we save lots of lines<br>for( 0=&gt; int n; n&lt; foo; n++)<br>{<br>//make connections<br>suns_moons[n] =&gt; pans[n] =&gt; dac;<br>//set gain
<br>1 =&gt; pans[n].gain;<br>}<br></div>===================<br><br><br>From there on you could make the suns even and the moons odd numbers, that might work nicely, you can sort odd from even using &quot;if(n%2)&quot; because modulus n will always resolve to either 0 or 1 for a positive n. Arrays of Ugens are a great way of structuring your code if you do a lot of monotonous stuff. Another aproach might be making a class that conists of a sun-moon pair and making a array of those.
<br><br>As for the functions; you could pass those a reference to the arrays used or hardcode their name in (less versatile). Because of the way the namespace works it would be possible and a good idea to use &quot;foo&quot; again in the functions or use the .cap() method that arrays have, this would make it easier to create whole solar systems by increasing one number.
<br><br><br>ChucK on!<br>Kas.<br></div>