<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>thanks everyone for the replies. Gen[n] and CurveTable are useful I will give them a try. If i'm not mistaken the curves generated this way pass through the intermediate points, so I was thinking of bezier curves because they pass in between the intermediate points and meet only the edges and they are smoother.<br><br>Thanks for the code Mike! I looked at your technique and I have a couple of observations/questions. I guess you disconnect the envelope to save cpu when not needed. But you have the phasor in ( .op() == 0 ) - probably for the same reason - which I haven't verified it but according to the manual should still be active but giving output of 0 - so it wastes cpu, no? And shouldn't be needed to block the input since you use the multiplier's gain for it, no? I usually use the passthru status ( .op() == -1 ) which shouldn't use any cpu.
I post part of my envelope class in case anybody would be interested in this way. Maybe too much for just an envelope but in long complicated code I find it really time saving to use this kind of 'secure' code:<br><br>public class XEnvelope<br>{<br> Envelope envelope;<br><br> UGen @ inputRef;<br> UGen @ outputRef;<br><br> // default status: passthru<br> -1 => envelope.op;<br><br> int isChucked; // 1 if connected both ways (left-right)<br> int isOn; // 1 if envelope.op() == 1<br> int isRunning; // 1 while envelope is running<br><br> 5 => int isBlocked; // if( isBlocked == 5 ) it is not blocked<br> // otherwise
it indicates the op status before blocked<br><br> // connect input<br> // if already connected, disconnect and connect the new one<br> fun void leftChuck( UGen input )<br> {<br> if( inputRef != NULL )<br> {<br> leftUnchuck();<br> }<br><br> input => envelope;<br> input @=> inputRef;<br><br> if( outputRef != NULL )<br> {<br> 1 => isChucked;<br> }<br> }<br><br> // connect to output<br> // if already connected,
disconnect and connect the new one<br> fun void rightChuck( UGen output )<br> {<br> if( outputRef != NULL )<br> {<br> rightUnchuck();<br> }<br><br> envelope => output;<br> output @=> outputRef;<br><br> if( inputRef != NULL )<br> {<br> 1 => isChucked;<br> }<br> }<br><br> // disconnect input<br> fun void leftUnchuck()<br> {<br> if( inputRef != NULL )<br>
{<br> inputRef =< envelope;<br> NULL @=> inputRef;<br><br> 0 => isChucked;<br> }<br> }<br><br> // disconnect output<br> fun void rightUnchuck()<br> {<br> if( outputRef != NULL )<br> {<br> envelope =< outputRef;<br> NULL @=> outputRef;<br><br> 0 => isChucked;<br> }<br> }<br><br>
// when blocking the envelope be careful not to change envelope.op<br> // elsewhere. security will be enhanced in the future<br> fun void block()<br> {<br> if( isBlocked == 5 )<br> {<br> envelope.op() => isBlocked;<br> 0 => envelope.op;<br> }<br> }<br><br> fun void unblock()<br> {<br> if( isBlocked != 5 )<br> {<br> isBlocked => envelope.op;<br>
5 => isBlocked;<br> }<br> }<br><br> // being OFF, turn on, run and hold<br> // needs to be turned off in the end with 'off'<br> fun void on( float start, float target, int milliseconds )<br> {<br> if( isChucked && !isOn )<br> {<br> 1 => isRunning => isOn => envelope.op;<br><br> milliseconds::ms => envelope.duration;<br> start => envelope.value;<br>
target => envelope.target;<br><br> milliseconds::ms => now;<br><br> 0 => isRunning;<br> }<br> else if( !isChucked )<br> {<br> <<< "ERROR: can't turn the envelope on - not connected" >>>;<br> }<br> else if( isOn )<br> {<br> <<< "ERROR: can't turn the envelope on - already on" >>>;<br> }<br> }<br><br> // being OFF, turn on, run and
hold<br> // needs to be turned off in the end with 'off'<br> fun void on( float start, float target, int milliseconds )<br> {<br> if( isChucked && !isOn )<br> {<br> 1 => isRunning => isOn => envelope.op;<br><br> milliseconds::ms => envelope.duration;<br> start => envelope.value;<br> target => envelope.target;<br><br> milliseconds::ms => now;<br><br>
0 => isRunning;<br> }<br> else if( !isChucked )<br> {<br> <<< "ERROR: can't turn the envelope on - not connected" >>>;<br> }<br> else if( isOn )<br> {<br> <<< "ERROR: can't turn the envelope on - already on" >>>;<br> }<br> }<br><br> // being ON, run to target and turn off<br> fun void off( float target, int milliseconds )<br> {<br> if( isOn && !isRunning )<br>
{<br> 1 => isRunning;<br><br> milliseconds::ms => envelope.duration;<br> target => envelope.target;<br><br> milliseconds::ms => now;<br><br> 0 => isRunning;<br> -1 => envelope.op;<br> 0 => isOn;<br> }<br> else if( !isOn )<br> {<br> <<< "ERROR: can't turn the envelope off - already off"
>>>;<br> }<br> else if( isRunning )<br> {<br> <<< "ERROR: can't turn the envelope off - running" >>>;<br> }<br> }<br><br> // being ON, move to next target<br> fun void to( float target, int milliseconds )<br> {<br> if( isOn && !isRunning )<br> {<br> 1 => isRunning;<br><br> milliseconds::ms => envelope.duration;<br> target =>
envelope.target;<br><br> milliseconds::ms => now;<br><br> 0 => isRunning;<br> }<br> else if( !isOn )<br> {<br> <<< "ERROR: can't move the envelope - envelope off" >>>;<br> }<br> else if( isRunning )<br> {<br> <<< "ERROR: can't move the envelope - running" >>>;<br> }<br> }<br><br> // being OFF, turn on, run and turn off<br> fun void onOff( float start, float target, int milliseconds
)<br> {<br> if( isChucked && !isOn )<br> {<br> 1 => isRunning => isOn => envelope.op;<br><br> milliseconds::ms => envelope.duration;<br> start => envelope.value;<br> target => envelope.target;<br><br> milliseconds::ms => now;<br><br> -1 => envelope.op;<br> 0 => isOn;<br>
0 => isRunning;<br> }<br> else if( !isChucked )<br> {<br> <<< "ERROR: can't turn the envelope on/off - not connected" >>>;<br> }<br> else if( isOn )<br> {<br> <<< "ERROR: can't turn the envelope on/off - already on" >>>;<br> }<br> }<br>}<br></td></tr></table><br>
<hr size=1><font size=-1 face=Arial>
Χρησιμοποιείτε Yahoo!<br>
Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων <br>
<a href="http://login.yahoo.com/config/mail?.intl=gr">http://login.yahoo.com/config/mail?.intl=gr</a> </font>