Re: multiple script processors not working in a row

Hello Joseph,

thanks for your advice. I will use the set() method in my future code.
Unfortunately this was not the reason for the problem I had. Also with 
the set() method, no audio data
arrives in the otherNodeInput. Hope you or somebody else can me give any 
further hints.

         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.set(calc.applyDspWindowFunction(windowNodeInput));
                 }else{
                     windowNodeOutput.set(windowNodeInput);
                 }
             }

             //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 otherNodeOutput = e.outputBuffer.getChannelData(0);
                 otherNodeOutput.set(otherNodeInput);

             }


             // 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);
             */
         }



Best regards,
Erik


Am 20.09.2013 19:12, schrieb Joseph Berkovitz:
> Looks like you have a couple of mistakes in the code:
>
>
>>             //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();
>
> 1. You probably meant to have two variables here: otherNodeInput and 
> otherNodeOutput. Otherwise you'll be copying the output array back to 
> itself.
>
> 2. Even after you have two variables, assigning an array to the local 
> variable otherNodeOutput will not copy the data, it will just change 
> what array that local variable points to. You'll need to do this instead:
>
> otherNodeOutput.set(otherNodeInput);
>
>
> Best,
>
> .          .   .    .  . ...Joe
>
> *Joe Berkovitz*
> President
>
> *Noteflight LLC*
> Boston, Mass.
> phone: +1 978 314 6271
> www.noteflight.com <http://www.noteflight.com>
> "Your music, everywhere"
>

Received on Sunday, 22 September 2013 11:05:28 UTC