Re: Fading sound in and out

On 26 Aug 2014, at 23:50, Chris Wilson <cwilso@google.com> wrote:
> I still think the easiest assistive thing to do here is to make cancelScheduledValues() insert a schedule point of the current value, as well as set .value to the current value.

Yes, I guess that would be a good idea.

Also, it would not hurt to secretly insert such a point each time the slope is zero at the schedule point of a "xxxRampToValueAtTime" or, said otherwise, to ignore the time of the param having a constant value in the calculation of the ramp. This would avoid discontinuities that are not well represented by the given scheduling calls. If somebody wants these discontinuities, he or she should call "setValueATime" with the adequate time which perfectly expresses this desire.
_____________________
N o r b e r t   S c h n e l l
{ Sound Music Movement } Interaction
IRCAM – Centre Pompidou


> Ray, I don't see a way to avoid saying you need to do the math yourself unless we completely flip to a slopes-and-trigger-voltages model  (keep in mind we cannot rely on callbacks here - JS would not give us an answer quickly enough to, say "call a callback when I hit 1").  In the new AudioWorker world, it would be easy enough to create an envelope node that worked that way;  but changing audioparam's model I'm somewhat opposed to.
> 
> 
> On Tue, Aug 26, 2014 at 1:14 PM, Norbert Schnell <Norbert.Schnell@ircam.fr> wrote:
> 
> On 26 Aug 2014, at 21:45, "Ray Bellis" <ray@bellis.me.uk> wrote:
> >> What I would expect is that calling the function "linearRampToValueAtTime"
> >> would use the current value at current time as a start point and ramp from
> >> there to the given value at the given time. In that case the fade times
> >> are always respected (even though the slopes wouldn't).
> >> I could not think of any scenario in which this behaviour would not be
> >> desired, do you?
> >
> > See endless threads passim where it has been noted that for an ADSR EG it
> > is the slope that's most important.
> 
> Well, I don't think that the slope is worth a lot in a env if you generate a click right before it.
> … and if you want to control the slope you always can use "setValueAtTime" and even "cancelScheduledValues".
> 
> (I find it just a pity that one needs to call functions that "cancel" and "set" to generate continuous envelopes while "ramp" may generate discontinuities.)
> 
> > Consequently to maintain that slope you must somehow both determine the
> > current value of the EG (if non-zero) and the amount of time you expect
> > the EG to take to go from that value to the new value.
> 
> Can that be something like this?
> 
>   var now = audioContext.currentTime;
>   var currentValue = myParam.value;
> 
>   myParam.cancelScheduledValues(now);
>   myParam.setValueAtTime(currentValue, now);
> 
>   var duration = targetValue / slope;
>   // or: var targetValue = duration * slope;
> 
>   myParam.linearRampToValueAtTime(targetValue, now + duration);
> 
> N.
> 
> 
> 

Received on Thursday, 28 August 2014 15:10:27 UTC