I am using the ScriptProcessorNode onaudioprocess callback to handle microphone input. By connecting MediaStreamSourceNode to ScriptProcessorNode, I can get the original audio data in the onaudioprocess callback function. However, after about 30 seconds (this varies from 10 to 35 seconds), the browser stops ringing onaudiprorocess. In the following code, the output of console.log ('→') always stops after about 30 seconds.
var ctx = new AudioContext(); var BUFFER_LENGTH = 4096; console.log('Buffer length is + ' + BUFFER_LENGTH); navigator.webkitGetUserMedia({audio: true}, function (stream) { var mediaStreamSource = ctx.createMediaStreamSource(stream); var scriptProcessor = ctx.createScriptProcessor(BUFFER_LENGTH, 1, 1); scriptProcessor.onaudioprocess = function (e) { console.log('>>'); }; scriptProcessor.connect(ctx.destination); }, function(e) { console.error('Unable to get audio input source.'); });
I tried all possible BUFFER_LENGTH (256, 512, 1024, 2048, 4096, 8192, 16384), but the situation has not changed (the log stops after 30 seconds). I noticed this problem in the latest version of Chrome (version 35.0.1916.153) and Canary (canary version 37.0.2060.3). Does anyone know any workarounds?
google-chrome getusermedia web-audio
kuu
source share