Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/429.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/187.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Web音频API多脚本处理器节点_Javascript_Signal Processing_Web Audio Api_Scriptprocessor - Fatal编程技术网

Javascript Web音频API多脚本处理器节点

Javascript Web音频API多脚本处理器节点,javascript,signal-processing,web-audio-api,scriptprocessor,Javascript,Signal Processing,Web Audio Api,Scriptprocessor,我已经为这个问题寻找了将近两天的解决方案。 我有一个web音频api应用程序,可以捕捉麦克风输入。在一个脚本处理器中,我使用汉宁窗口对信号进行窗口处理,当音频链如下所示时,该窗口可以正常工作: source->WindowsScriptProcessorNode->audioContext.destination 然后我想向链中添加另一个脚本处理器,如下所示: source->WindowsScriptProcessorNode->otherScriptProcessorNode->audioC

我已经为这个问题寻找了将近两天的解决方案。 我有一个web音频api应用程序,可以捕捉麦克风输入。在一个脚本处理器中,我使用汉宁窗口对信号进行窗口处理,当音频链如下所示时,该窗口可以正常工作:

source->WindowsScriptProcessorNode->audioContext.destination

然后我想向链中添加另一个脚本处理器,如下所示:

source->WindowsScriptProcessorNode->otherScriptProcessorNode->audioContext.destination

但在otherScriptProcessorNode的inputBuffer中,只有零而不是WindowsScriptProcessorNode的信号。 下面是一些代码:

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

有没有可能发布一个带有简化测试用例的JSFIDLE?