Andrew,<br><br>Some notes here in addition to what Tom already covered because I think some of the topics here can stand some clarification;<br><br>&nbsp;&nbsp;&nbsp; Generally it&#39;s not such a good idea to define things (like variables or UGens) inside of a loop. This is because defining&nbsp; -and so instantiating- things will take memory and right now we don&#39;t have garbage collection so the memory that gets used for these things will never be freed. Aside from that; when you define things inside of a loop it will become impossible to later address those (for example to change their parameters). Unless you are very sure of what you are doing defining UGens within a loop is probably a bad idea.<br>
<br>Let me give a example;<br>-----------------8&lt;--------------------------<br>repeat(3)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; SinOsc s =&gt; dac;<br>&nbsp;&nbsp;&nbsp; Std.rand2f(200, 2000) =&gt; s.freq;<br>&nbsp;&nbsp;&nbsp; .33 =&gt; s.gain;<br>&nbsp;&nbsp;&nbsp; second =&gt; now;<br>
&nbsp;&nbsp;&nbsp; }<br><br>5::second =&gt; now;<br>-----------------8&lt;-------------------------<br><br>This wil create a sort of &quot;chord&quot; (probably a very bad one). Let&#39;s suppose that after these 8 seconds we&#39;d like to change the &quot;chord&quot;. How would we distinguish between the 3 copies of &quot;s&quot;? The sad truth is tthat we can&#39;t. This is a bit tricky; in a way we can say that every iteration of such a loop is it&#39;s own namespace like a function has it&#39;s own namespace. Obviously this namespace is a superset of the namespace the loop itself is in, or loops wouldn&#39;t be good for much. To re-phrase; from within a loop you can address anything defined within that loop and anything in the scope the loop itself is in. You can&#39;t address things defined within a loop from outside of that loop.<br>
<br>&nbsp;&nbsp;&nbsp; About Envelope; Envelope.last() will give you the last value calculated by the UGen. This is the same as the value it sends to the UGen it&#39;s connected to at the last &quot;tick&quot; of the sample rate. This value is based on Envelope&#39;s input multiplied by the current value of the Envelope. When nothing is connected to the input of the Envelope this value will always be 0 though the value of .value() may be any number (because anything multiplied by 0 will be 0). <br>
<br>At times it&#39;s handy to feed a Envelope with a Step UGen to scale it&#39;s output. Let me demonstrate;<br><br>Envelope e =&gt; dac; //notice a connection to the dac or blackhole is needed for any results to be calculated at all<br>
-------------------8&lt;-------------------------------<br>3::second =&gt; e.duration;<br><br>1 =&gt; e.target;<br>&lt;&lt;&lt;e.value(), e.last()&gt;&gt;&gt;;<br><br>repeat(3)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; second =&gt; now;<br>&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;e.value(), e.last()&gt;&gt;&gt;;<br>
&nbsp;&nbsp;&nbsp; }<br><br>//second case, notice the difference<br><br>Step s =&gt; e;<br>10 =&gt; s.next;<br>0 =&gt; e.value;<br>samp =&gt; now; //allow parameter changes to have effect<br>&lt;&lt;&lt;e.value(), e.last()&gt;&gt;&gt;;<br>
<br>1=&gt; e.target;<br><br>repeat(3)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; second =&gt; now;<br>&nbsp;&nbsp;&nbsp; &lt;&lt;&lt;e.value(), e.last()&gt;&gt;&gt;;<br>&nbsp;&nbsp;&nbsp; }<br>--------------------8&lt;---------------------------------<br><br>Quite different, I&#39;d say.<br>
<br>I hope that clarifies. Some of this is slightly tricky but most of it directly translates to more power to you. Shout if this was unclear.<br><br>Yours,<br>Kas.<br>