Re: Having some problems with envelopes

Peter van der Noord writes:

> I'm currently having some issues regarding envelopes, which seems to be
> exacty what is described here:
>
> http://lists.w3.org/Archives/Public/public-audio/2013JanMar/0053.html
>
> I'm playing sequences that i schedule ahead in time, but i don't see any
> way to get the envelopes right. Some questions:
>
> - what happens exactly when i cancel scheduled param-changes? it's totally
> unclear for me from the specs what happens to the value when i schedule a
> cancel on a moment when it will be in the middle of a change (a linear ramp
> for example)

I'm guessing the intention was that
cancelScheduledValues(startTime) would remove the scheduled events
from the equation.  Those events would no longer have any effect,
even for times < startTime.  If an event, such as a linear ramp,
has already begun taking effect, then I'm not clear what the
expected behavior is.

> - is it currently impossible to implement a correctly working envelope when
> scheduling ahead in time?

I think it is possible but may be inelegantly awkward if values for
setValueAtTime() need to be calculated by the client.

Consider this function from [1]:

function triggerAttack (time) {
  param.setValueAtTime(*SOME VALUE?*, time);
  param.linearRampToValue(1, time+attackTime);
  param.linearRampToValue(sustainValue, time+attackTime+decayTime);
}

We want a way to say where the linear ramp for the attack should
start.  i.e. we want to schedule an event that has no effect
except to mark the start for the effect of subsequent events or an
end to the effects of previous events.  (IIUC this is a little
simpler than what is proposed in [2].)

setTargetAtTime() already does pretty much what is wanted here
because it does not change that value at startTime.

Unfortunately, though, the spec isn't clear which equation should
be used between a setTargetAtTime event and a
linearRampToValueAtTime event.  This was raised in [3], but I
don't find where it has been addressed.  I would have expected the
linear ramp equation to apply, because otherwise the linear ramp
will become a step function at its endTime, but Gecko is applying
the exponential from setTargetAtTime.

> - is there any way to access the queued/scheduled param-changes on an
> audioparam?

Not currently, at least.

[1] http://lists.w3.org/Archives/Public/public-audio/2013JanMar/0055.html
[2] http://lists.w3.org/Archives/Public/public-audio/2013JanMar/0075.html
[3] https://github.com/WebAudio/web-audio-api/issues/216

Received on Thursday, 3 July 2014 23:38:41 UTC