2008/6/19 kevin
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.
Not by much, I think. This is the "essence" of Envelope, it comes from Ugen_stk.cpp, starts at line 6972; =============================- MY_FLOAT Envelope :: tick(void) { if (state) { if (target > value) { value += rate; if (value >= target) { value = target; state = 0; } } else { value -= rate; if (value <= target) { value = target; state = 0; } } } return value; } ============
So; that has clauses for having reached the end already anyway, so what we simply could do would be; ================= MY_FLOAT Envelope :: tick(void) { if (state) { if (target > value) { value += rate; if (value >= target) { value = target; state = 0; rate = 0; } } else { value -= rate; if (value <= target) { value = target; state = 0; //not sure we actually need this line? rate = 0; } } } return value; } ============= I think that would fly. 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. Yours, Kas.