7

Is there an (easy) way to take a mono input and play it only in the left or right channel? I'm thinking I can do it through the ScriptProcessing node, but if there is a node meant to handle this situation I'd really like to know. The API has a section on mixing, but I don't see any code on how to manipulate channels yourself in this fashion.

Note, I have tried the panner node, but it doesn't seem to really cut off the left the from the right channel, I don't want any sound bleeding from one channel to the other.

3 Answers 3

3

You do want to use the ChannelSplitter, although there is a bug when a channel is simply not connected. See this issue: Play an Oscillation In a Single Channel.

Sign up to request clarification or add additional context in comments.

Comments

2

Take a look at the splitter node: https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#ChannelSplitterNode-section

One application for ChannelSplitterNode is for doing "matrix mixing" where individual gain control of each channel is desired.

(I haven't yet tried it, let me know : )

Comments

2

You can try to use the CreatePanner() and then setPosition() to the desired channel. Don't forget to connect your previous node to the panner node and the panner to the context.destination.

For example:

//Lets create a simple oscilator just to have some audio in our context
var oscillator = context.createOscillator();

//Now lets create the panner node
var pannerNode = context.createPanner();

//Connecting the nodes
oscillator.connect(pannerNode); //Connecting the oscillator output to the panner input
pannerNode.connect(context.destination); //Connecting the panner output to our sound output

//Setting the position of the sound
pannerNode.setPosition(-1, 0, 0);//If you want it to play on the left channel
pannerNode.setPosition(1, 0, 0);//If you want it to play on the right channel

//Playing the sound
oscillator.noteOn(0);

Is that what you need?

1 Comment

Someone has suggested and edit. Can you review, it looks to have missed a typo at least.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.