<br><br><div class="gmail_quote">2008/6/19 kevin <<a href="mailto:vacillates@gmail.com">vacillates@gmail.com</a>>:<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'll chime in my support for this functionality, as it makes sense, though it does seem like it'd be harder to implement.<br><font color="#888888"><br></font></blockquote><div>Not by much, I think. This is the "essence" of Envelope, it comes from Ugen_stk.cpp, starts at line 6972;<br>
=============================-<br>MY_FLOAT Envelope :: tick(void)<br>{<br> if (state) {<br> if (target > value) {<br> value += rate;<br> if (value >= target) {<br> value = target;<br> state = 0;<br>
}<br> }<br> else {<br> value -= rate;<br> if (value <= target) {<br> value = target;<br> state = 0;<br> }<br> }<br> }<br> 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>
if (state) {<br>
if (target > value) {<br>
value += rate;<br>
if (value >= target) {<br>
value = target;<br>
state = 0;<br> <span style="color: rgb(255, 0, 0);"> rate = 0;</span><br>
}<br>
}<br>
else {<br>
value -= rate;<br>
if (value <= target) {<br>
value = target;<br>
state = 0; <span style="color: rgb(255, 0, 0);">//not sure we actually need this line?</span><br> <span style="color: rgb(255, 0, 0);"> rate = 0;</span><br>
}<br>
}<br>
}<br>
return value;<br>
}<br>
=============<br>I think that would fly. <br><br>I am, BTW, not sure why there are separate "rate" and "state" variables... and I can'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'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>