[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] Loosing attack when re-triggering custom envelopes



On Dec 28, 2012 7:42 PM, <nunja@xxxxxxx> wrote:
>
> Hello Sc Users,
>
> In a trial to build a simple drum synth, I am optimizing by re-triggering enveloppes instead of creating new Synth instances each time I got an event (MIDI / OSC) for a drum.

This means you have UGens running without making sound. That's the opposite of an optimization.

It is very fast and cheap to make new synths. You gain nothing by this technique.

> Here is an example of a Kick drum.
> I have a strange issue that I encountered by using Env.new instead of Env.perc.
> Re-triggering an EnvGen which has been created using Env.new instead Env.perc has only once the attack power at synth creation and loose it after while re-triggering.
>
> SynthDef(\nun_kick_b,{
>         arg out=0, amp=0.6, pan=0, t_trig = 1;
>         var env0, env1, env1m, son;
>
>         env0 =  EnvGen.ar(Env.new([0.5, 1, 0.5, 0], [0.005, 0.06, 0.26], [-4, -2, -4]), t_trig);
>         env1 = EnvGen.ar(Env.new([110, 59, 29], [0.005, 0.29], [-4, -5]), t_trig);

This is something that confuses everyone about SC envelopes.

The first value is used once and only once: at the beginning of EnvGen. After you move toward the second value, there is no way to go back to the first value by re-triggering. The second trigger goes from the EnvGen's current value (which may be in between breakpoints) to the target of the envelope's first segment. That target is the SECOND item in the "levels" array.

In Env.perc, the peak value is the second item. In your Env.new, the peak value is first.

hjh