- From: Norbert Schnell <Norbert.Schnell@ircam.fr>
- Date: Tue, 26 Aug 2014 12:04:38 +0200
- To: public-audio@w3.org
The current behaviour of the "xxxToValueAtTime" and the code that it requires is really not that great. In Chinmay's example it causes clicks as he describes and in Chris' example causes clicks when clicking "play" during the fadeout or "stop" during the fadein. 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? Norbert _____________________ N o r b e r t S c h n e l l { Sound Music Movement } Interaction IRCAM – Centre Pompidou > Actually, your problem is you're not setting the start point for the linear > ramp appropriately; you setValueAtTime(0) when the context is created, But > you need to additionally set it when the play or stop button is pressed (to > give it a start value and (more importantly) time for the ramp. See > > http://jsfiddle.net/9La05fg5/11/ > . > > What's happening now is whenever the click methods are called, the start > time and value for the ramp is whatever the last schedule event was - e.g., > if you loaded the page and waited three seconds, then clicked play, the > linear ramp will have its start point (value 0) set on creation - 3 seconds > in the past - and the end point is three seconds in the future (value 1) - > so it will immediately jump to 0.5, and ramp from 0.5 to 1 over the next 3 > seconds, which is why it's not smooth enough. > > I really need to write an explanatory article about how to use the > scheduler. > > On Wed, Aug 20, 2014 at 9:43 AM, Chinmay Pendharkar <notthetup@gmail.com> wrote: >> Hello, >> >> You can look at using the exponentialRampToValueAtTime or setTargetAtTime methods >> instead. >> >> Human perception of loudness is logarithmic in nature, so exponential >> decays of loudness feel 'smoother' to us than linear decays. >> >> -Chinmay >> >> >> On Wed, Aug 20, 2014 at 10:29 PM, Yehonathan Sharvit <viebel@gmail.com> wrote: >> >>> Hi, >>> >>> What is the best way to fade sound in and out? >>> >>> I tried to achieve that by calling linearRampToValueAtTime (see a demo: >>> >>> http://jsfiddle.net/viebel/9La05fg5/7/ >>> ) on a gain node but the effect >>> was not smooth enough? >>> >>> How could I make it smoother? >>> >>> Thanks, >>> Yehonathan.
Received on Tuesday, 26 August 2014 10:05:12 UTC