<br><br><div class="gmail_quote">2008/6/19 kevin &lt;<a href="mailto:vacillates@gmail.com">vacillates@gmail.com</a>&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I suppose I&#39;ll chime in my support for this functionality, as it makes sense, though it does seem like it&#39;d be harder to implement.<br><font color="#888888"><br></font></blockquote><div>Not by much, I think. This is the &quot;essence&quot; of Envelope, it comes from Ugen_stk.cpp, starts at line 6972;<br>
=============================-<br>MY_FLOAT Envelope :: tick(void)<br>{<br>&nbsp; if (state) {<br>&nbsp;&nbsp;&nbsp; if (target &gt; value) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value += rate;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (value &gt;= target) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = target;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state = 0;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; else {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value -= rate;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (value &lt;= target) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = target;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; }<br>&nbsp; return value;<br>}<br>============ <br></div></div>
<br>So; that has clauses for having reached the end already anyway, so what we simply could do would be;<br>=================<br>MY_FLOAT Envelope :: tick(void)<br>
{<span style="color: rgb(255, 0, 0);"></span><br>
&nbsp; if (state) {<br>
&nbsp;&nbsp;&nbsp; if (target &gt; value) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value += rate;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (value &gt;= target) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = target;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state = 0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);"> rate = 0;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; else {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value -= rate;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (value &lt;= target) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; value = target;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; state = 0; <span style="color: rgb(255, 0, 0);">//not sure we actually need this line?</span><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: rgb(255, 0, 0);">&nbsp; rate = 0;</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp; }<br>
&nbsp; return value;<br>
}<br>
=============<br>I think that would fly. <br><br>I am, BTW, not sure why there are separate &quot;rate&quot; and &quot;state&quot; variables... and I can&#39;t seem to find the getRate() one. Also; in ChucK .rate() will always be a non-negative value. Maybe it would be best to have .rate() (in ChucK) report a rate with the appropriate sign as we don&#39;t have access to .state() from ChucK.... of course in that case we could also add a little check and if rate == 0 immediately proceed to returning value, in the interest of saving CPU.<br>
<br>Yours,<br>Kas.<br>