UNCONFIRMED Bug 97290
Loud sounds turning up when using Web Audio API where no sound expected
https://bugs.webkit.org/show_bug.cgi?id=97290
Summary Loud sounds turning up when using Web Audio API where no sound expected
Srikumar K. Subramanian
Reported 2012-09-20 21:43:37 PDT
OS: iOS6 Device Type: iPhone4 Steps to reproduce: The following code is not expected to produce any sound since the volume set is 0, but once in a while you get a loud "ping" if you keep reloading the page in Mobile Safari on iOS6. Less than 10 attempts are needed to produce this effect. {{{ <script> var ac = new webkitAudioContext(); var attack = 0.01; var decay = 0.5; function note(t, f, v) { var osc = ac.createOscillator(); osc.frequency.value = f; var gain = ac.createGainNode(); gain.gain.setValueAtTime(0, t); gain.gain.linearRampToValueAtTime(v, t + attack); gain.gain.setTargetValueAtTime(0, t + attack, decay); osc.connect(gain); gain.connect(ac.destination); osc.noteOn(t); osc.noteOff(t + 12 * decay); } note(ac.currentTime, 880, 0); </script> }}} I've occasionally heard such loud sounds in Chrome 21.0.1180.89 and Safari 6 on MacOS 10.8.1 and so I believe it might be present in the WebKit implementation across the board. Some other observations - 1. Changing the line "gain.gain.setValueAtTime(0, t);" to "gain.gain.value = 0;" seems to result in the code doing the right thing - i.e. I never got the loud ping on several attempts. 2. Changing the line "note(ac.currentTime, 880, 0);" to "note(ac.currentTime + 0.01, 880, 0);" also seems to resolve this issue.
Attachments
Srikumar K. Subramanian
Comment 1 2012-09-20 22:05:09 PDT
Btw with either of the changes (1) and (2), if I give a non-zero gain value, the note is played at that level correctly upon page load.
Note You need to log in before you can comment on or make changes to this bug.