- From: Raymond Toy <rtoy@google.com>
- Date: Tue, 17 Sep 2013 13:48:57 -0700
- To: "public-audio@w3.org" <public-audio@w3.org>
- Message-ID: <CAE3TgXHEE3YYbDw6i02Dm0LsbVgrCFO_BRBn_3OdY7OxCUW+Zg@mail.gmail.com>
Let's say you create a ScriptProcessorNode and set the onaudioprocess to
generate, say, a sine wave. Something like the script below.
In this case, all Javascript references to the ScriptProcessorNode and the
corresponding onaudioprocess function are dropped.
What should happen now? Should you still hear the sine wave?
--
Ray
Sample code:
var MyClass = function () {
var mAudioContext;
var mPhase = 0;
var generateTimeSlice = function (leftBuf, rightBuf) {
var bufLen = leftBuf.length;
for (var k = 0; k < bufLen; k++) {
leftBuf[k] = Math.sin(mPhase);
rightBuf[k] = Math.sin(mPhase * 1.01);
mPhase += 0.02;
}
};
this.init = function () {
mAudioContext = new AudioContext();
var scriptNode = mAudioContext.createScriptProcessor(4096, 0, 2);
scriptNode.onaudioprocess = function (event) {
var leftBuf = event.outputBuffer.getChannelData(0);
var rightBuf = event.outputBuffer.getChannelData(1);
generateTimeSlice(leftBuf, rightBuf);
};
scriptNode.connect(mAudioContext.destination);
};
};
var gMyClass = new MyClass();
gMyClass.init();
Received on Tuesday, 17 September 2013 20:49:25 UTC