The behavior I'm going to describe happens in Chrome 44, but it doesn't happen in Firefox 40.
If you create an oscillator, set it to 220 Hz, and then change the frequency to 440 Hz a second later, you can hear a great portamento effect: instead of instantly changing from 220 to 440, the generator slides from the original frequency to the new one.
The code below illustrates this phenomenon:
var ac = new AudioContext(); var osc = ac.createOscillator(); osc.connect( ac.destination ); osc.type = 'sawtooth'; osc.frequency.value = 220; osc.start( 0 ); window.setTimeout( function() { osc.frequency.value = 440; }, 1000 ); window.setTimeout( function() { osc.stop( 0 ); }, 2000 );
I studied the documents for the OscillatorNode object and did not mention this.
I also searched Google, and (surprisingly) I cannot find any other references to this phenomenon.
What's happening? This is not like correct behavior. If I wanted the frequency to slip, I would use the linearRampToValueAtTime () method. Setting the frequency directly to a specific value should simply ... do it.
Is this just a mistake? I know that this API is still on the move, but it seems rather egregious to be a mistake - it wonβt miss the most superficial testing. But I also canβt imagine that Google will implement it in such a way intentionally.
Most important: is there a workaround?
source share