multiple script processors not working in a row

Hello everyone,

I've been searching a solution for nearly two days now about this problem.
I have a web audio api app that catches the microphone input. In one 
script processor i'm windowing the signal with a hanning window, which 
works fine this way:

     source -> windowScriptProcessorNode -> audioContext.destination

Then i wanted to add another script processor like this:

     source -> windowScriptProcessorNode -> otherScriptProcessorNode -> 
audioContext.destination

but at the inputBuffer of the otherScriptProcessorNode there are just 
zeros instead of the signal of windowScriptProcessorNode.
Here is some code:


         var audioContext = new AudioContext();

         //get microphone input via getUserMedia
         navigator.getUserMedia({audio: true}, function(stream) {

             //set up source
             var audioSource = audioContext.createMediaStreamSource(stream);
             audioSource.buffer = stream;

             //set up hanning window script processor node
             var windowScriptProcessorNode = 
audioContext.createScriptProcessor(BLOCKLENGTH,1,1);
             windowScriptProcessorNode.onaudioprocess = function(e){
                 var windowNodeInput = e.inputBuffer.getChannelData(0);
                 var windowNodeOutput = e.outputBuffer.getChannelData(0);
                 if (windowfunction==true) {
                     windowNodeOutput = 
applyDspWindowFunction(windowNodeInput.subarray());
                 }else{
                     windowNodeOutput = windowNodeInput.subarray();
                 }
             }

             //some other script processor node, just passing through 
the signal
             var otherScriptProcessorNode = 
audioContext.createScriptProcessor(BLOCKLENGTH,1,1);
             otherScriptProcessorNode.onaudioprocess = function(e){
                 var otherNodeInput = e.inputBuffer.getChannelData(0);
                 var otherNodeInput = e.outputBuffer.getChannelData(0);
                 otherNodeInput = otherNodeInput.subarray();

             }


             // this connnection works fine
             audioSource.connect(windowScriptProcessorNode);
windowScriptProcessorNode.connect(audioContext.destination);

             /* // this connnection does NOT work
             audioSource.connect(windowScriptProcessorNode);
windowScriptProcessorNode.connect(otherScriptProcessorNode);
otherScriptProcessorNode.connect(audioContext.destination);
             */
         }

Did anyone ever connected two scriptProcessorNodes in a row? is there 
anything special, one has to account for??
Note that I use mono input and output for each node, i tested it with 
regular stereo, but that didn't made any difference to me.
Would be great if some could help me out!

Best regards,
Erik

Received on Friday, 20 September 2013 16:20:15 UTC