Re: AudioParam.exponentialRampToValueAtTime() does not work as intended

Hi Hongchan,

The spec forbids 0.0 as a end value for the exponential ramp.
This is because the exp ramp linearly interpolates the log
of the gain value.

You can use any non-zero small value instead - like 0.001 -
and you'll indeed see a fadeout. Another way to approach a
fadeout is to use "setTargetAtTime" and specify an appropriate
half life.

Meta note: The "public-audio-dev@w3.org" list was recently
created for these kinds of questions. This list is now concerned
with spec related discussions.

Best,
-Kumar

On 24 May, 2013, at 5:46 AM, Hongchan Choi <choihongchan@gmail.com> wrote:

> Hello All,
> 
> I have been fiddling with AudioParam and found a weird thing:
> 
> var c = new AudioContext();
> var o = c.createOscillator();
> var g = c.createGainNode();
> 
> o.connect(g);
> g.connect(c.destination);
> o.noteOn(0); // for Safari
> 
> g.gain.setValueAtTime(0.0, 0);
> g.gain.linearRampToValueAtTime(1.0, 0.01);
> g.gain.exponentialRampToValueAtTime(0.0, 2.0); // ???
> 
> With the last line above, I am expecting to have a nice smooth fade out for 1.99 seconds, but it is not happening on Chrome (stable, 27.0.1453.93)  and Safari (stable, 6.0.4 (7536.29.13)). The sine wave falls into 0 gain immediately at 2.0 second. The jsfiddle link follows:
> 
> http://jsfiddle.net/hoch/3sXRq/2/
> 
> Am I missing something here?
> 
> Thank you in advance,
> Hongchan
> 
> 
> -- 
> Hongchan Choi
> 
> Teaching Assistant / PhD Candidate
> Center for Computer Research in Music and Acoustics (CCRMA)
> Stanford University
> 
> http://ccrma.stanford.edu/~hongchan

Received on Friday, 24 May 2013 01:46:48 UTC