[web-audio-api] Asynchronous write (#165)

> Originally reported on W3C Bugzilla [ISSUE-18334](https://www.w3.org/Bugs/Public/show_bug.cgi?id=18334) Thu, 19 Jul 2012 16:18:42 GMT
> Reported by Jussi Kalliokoski
> Assigned to 

I may be wrong, but it seems to me that currently the JavaScriptNode has no way of filling the buffers asynchronously. I suggest we adopt the way that Robert's proposal did the callbacks, having a write method on the event. Allowing asynchronous writes makes sense in an environment like JS where most of the external operations are asynchronous. Also, for example if we define a DSP library that supports things such as convolution, it would be ideal for it to provide asynchronous versions of the calls as well, to make it more natural to the async flow of JS programs, not to mention that you could do concurrent overlap-add things. So for example (very simplified):

var l = 2048

customNode.onaudioprocess = function (e) {
  var buffer = new Float32Array(l)

  oscillator.fillBufferAsync(buffer, function () {
    e.writeAudio(buffer)
  })
}

This would also allow one to write data ahead of time.

---
Reply to this email directly or view it on GitHub:
https://github.com/WebAudio/web-audio-api/issues/165

Received on Wednesday, 11 September 2013 14:29:08 UTC