NEW 89017
JavaScriptAudioNode does not fire onaudioprocess with 0 input channels
https://bugs.webkit.org/show_bug.cgi?id=89017
Summary JavaScriptAudioNode does not fire onaudioprocess with 0 input channels
Chris Rogers
Reported 2012-06-13 10:26:39 PDT
JavaScriptAudioNode (part of the Web Audio API) does not fire the onaudioprocess event as it should if it is configured to have 0 input channels. Changing it to 1 or 2 makes it work. Steps to Reproduce: Here is a simple sine wave demo: <script> var context = new webkitAudioContext(); var node = context.createJavaScriptNode(1024, 0, 1); var freq = context.sampleRate / (440 * 2 * Math.PI); var x = 0; node.onaudioprocess = function(e) { var data = e.outputBuffer.getChannelData(0); for (var i = 0; i < data.length; ++i) { data[i] = Math.sin(x++ / freq); } } </script> <button onclick="node.connect(context.destination)">Play</button> <button onclick="node.disconnect()">Pause</button> 1 - Clicking play makes no sound and in fact onaudioprocess is never fired. 2 - Change the JavaScriptAudioNode to take 1 input channel, eg. context.createJavaScriptNode(1024, 1, 1); 3 - Notice that it works now.
Attachments
Xingnan Wang
Comment 1 2012-06-14 02:03:07 PDT
(In reply to comment #0) > JavaScriptAudioNode (part of the Web Audio API) does not fire the onaudioprocess event as it should if it is configured to have 0 input channels. Changing it to 1 or 2 makes it work. > > Steps to Reproduce: > Here is a simple sine wave demo: > <script> > var context = new webkitAudioContext(); > var node = context.createJavaScriptNode(1024, 0, 1); > var freq = context.sampleRate / (440 * 2 * Math.PI); > var x = 0; > > node.onaudioprocess = function(e) { > var data = e.outputBuffer.getChannelData(0); > for (var i = 0; i < data.length; ++i) { > data[i] = Math.sin(x++ / freq); > } > } > </script> > <button onclick="node.connect(context.destination)">Play</button> > <button onclick="node.disconnect()">Pause</button> > > 1 - Clicking play makes no sound and in fact onaudioprocess is never fired. > 2 - Change the JavaScriptAudioNode to take 1 input channel, eg. context.createJavaScriptNode(1024, 1, 1); > 3 - Notice that it works now. Hi Chris, I cannot reproduce the bug (with zero input). I`ve tested on both the latest chromium and chrome in my ubuntu and mac, the onaudioprocess events could be caught and the sound was played well.
Chris Rogers
Comment 2 2012-06-14 15:25:05 PDT
Jer, just wanted to note that there have been some recent-ish changes to JavaScriptAudioNode channel handling...
Note You need to log in before you can comment on or make changes to this bug.