Dimitris,
I do this all the time now:
//
// CurveTable Envelope
//
class CurveEnvelope
{
// members and default params
Phasor drive => CurveTable curvetable => Gain multiplier;
3 => multiplier.op; // this is what makes the CurveTable an envelope!
0. => multiplier.gain; // we use this to gait the output, so start at 0.
UGen source, out;
0 => drive.op; // stop the driver for now
dac @=> out;
1. => float gain;
1::second => dur length;
[0., 0., 0., 1., 1., 0., 2., 0.] => curvetable.coefs; // triangle window
// methods
fun void setEnvelopeCoefs( float _coefs[] )
{
_coefs => curvetable.coefs;
}
fun void connectSource( UGen src )
{
src @=> source;
}
fun void connectOutput( UGen destination )
{
destination @=> out;
}
fun void trigger()
{
source => multiplier => out; // connect things
gain => multiplier.gain; // open gait
1 => drive.op;
0. => drive.phase; // reset driver to beginning of envelope curve
1. / (length / second) => drive.freq; // calculate speed of driver in Hz
length => now; // let it happen...
0. => multiplier.gain; // close gait
0 => drive.op;
source =< multiplier =< out; // disconnect things
}
}
// demo
CurveEnvelope ce;
SinOsc s;
ce.connectSource( s );
ce.connectOutput( dac );
ce.trigger();
TriOsc t;
ce.connectSource( t );
ce.connectOutput( dac );
ce.trigger();
<<< "done" >>>;
---
It's fast. I use it for grain envelopes. The GenX UGens are similarly helpful.
-Mike
On Wed, Aug 12, 2009 at 3:38 AM, Hans Aberg
On 12 Aug 2009, at 04:17, Kassen wrote:
has anybody implemented in ChucK or elsewhere else envelopes with the use of bezier or other spline curves?
Doesn't one of the Gen[n] UGens cover those? If not we might put that on the wish list.
It might be nice to have it some general functions. - I was thinking of using it for implementing scale stretch.
Hans
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users