Bug 89017
| Summary: | JavaScriptAudioNode does not fire onaudioprocess with 0 input channels | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Chris Rogers <crogers> |
| Component: | Web Audio | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | crogers, eric.carlson, jer.noble, xingnan.wang |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
Chris Rogers
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Xingnan Wang
(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
Jer, just wanted to note that there have been some recent-ish changes to JavaScriptAudioNode channel handling...