I am trying to implement a ScriptProcessorNode with two input and one output channels.
var source = new Array(2);
source[0] = context.createBufferSource();
source[0].buffer = buffer[0];
source[1] = context.createBufferSource();
source[1].buffer = buffer[1];
var test = context.createScriptProcessor(4096, 2, 1);
source[0].connect(test, 0, 0);
source[1].connect(test, 0, 1);
test.connect(context.destination);
source[0].start();
source[1].start();
When I run this code in Google Chrome as well as in Mozilla Firefox I get the following error thrown. It tells me my test
node has only one input channel.
Uncaught IndexSizeError: Failed to execute 'connect' on 'AudioNode': input index (1) exceeds number of inputs (1).
When I console print the number of input channels of the ScriptProcessorNode test
I get two input channels.
test.onaudioprocess = function(evt){
console.log("number of input channels: " + evt.inputBuffer.numberOfChannels);
}
Nevertheless connecting two nodes to the input of the test
node does not work the way I do it. I want to program a vocoder inside the ScriptProcessorNode. How can I create a ScriptProcessorNode with two input and one output channels and connect two source nodes as input channel and the context.destination
as output channel?
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers. The AudioWorklet interface of the Web Audio API is used to supply custom audio processing scripts that execute in a separate thread to provide very low latency audio processing.
Load and install the audio processor module. Create an AudioWorkletNode , specifying the audio processor module to use by its name. Connect inputs to the AudioWorkletNode and its outputs to appropriate destinations (either other nodes or to the AudioContext object's destination property.
The ScriptProcessor handles Amazon SageMaker Processing tasks for jobs using a machine learning framework, which allows for providing a script to be run as part of the Processing Job. Parameters. role (str) – An AWS IAM role name or ARN.
The second parameter of createScriptProcessor
is the number of input channels to the single input of the node, not the number of inputs to the node.
So the way to do this is to use a ChannelMergerNode
with two inputs. Connect your two sources to each of the inputs of the merger node. The output of the merger should be connected to your script processor node. The onaudioprocess
callback will be given an AudioBuffer
that has two channels in it. You can then process these two channels however you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With