Re: Creating ADSR Envelopes

I would point out there's a big difference, in this case, between dealing
with a trigger point to be handled "now/as soon as possible" in a JS event,
and "trigger this in n seconds precisely".  There's nothing to prevent me,
for example, from doing precisely what you say (have a fractional attack
phase, in order to keep a consistent slope) - I would just read the current
value, set it, calculate the proper timing for a linear ramp to keep the
appropriate slope, and schedule it.  (The synth examples I've done thus far
do not reuse/retrigger the same envelope.)  Retriggering an envelope in a
JS event handler is easy enough to do - retriggering inside the WA thread
is a bit harder, since you want to do programmatic things.  That might have
to wait for a future "audio shader" programmability feature.

The release portion, where this triggering could cause slope differences, I
already use setTargetAtTime() for, as (AIUI) releases are frequently
non-linear.


On Fri, Jan 11, 2013 at 12:41 PM, Ray Bellis <ray@bellis.me.uk> wrote:

> On 11/01/2013 17:29, Chris Wilson wrote:
>
>> Well, that could of course give you a value for a future time based on
>> what's currently known in the scheduler; if other calls are scheduled,
>> or the .value is set, that might not reflect reality, though.  I think
>> it would be easier (and actually clarify the normal case, too) to have
>> something that schedules taking the current result of scheduling and
>> setting it as the currently scheduled value (at that point in time), and
>> cancels any currently pending or in-progress scheduling events.
>>
>
> Isn't there a further problem in that to correctly emulate an ADSR
> generator that hasn't started from 0 you must both shorten the attack phase
> and reschedule the decay and sustain phases accordingly.
>
> AIUI, on analogue synths the A and D values typically affected the _slope_
> of the attack and delay, which then only indirectly affects the _timing_ of
> those phases.  This would have been done by tuning the 1/RC
> time constant of a charging capacitor, where the R component was the knob
> on the panel.
>
> If the EG is at 0.5 when triggered, you need to have roughly half as long
> an attack phase, not one of the same duration with half the slope.
>
> The decay (and sustain) have to start sooner, because the decay phase is
> triggered by the EG reaching its peak value.  Again, timing is a
> consequence of the slope, not the other way around.
>
> If you follow the WebAudio mantra of dynamically creating nodes as they're
> needed there's less of a problem, because a dynamically created EG node
> would always start at zero.  However, doing so would make it difficult to
> emulate the ADSR effects you get when an EG is repeatedly retriggered
> without ever reaching its zero point.
>
> Ray
>
>

Received on Friday, 11 January 2013 21:06:02 UTC