Reputation: 31
I have a direct input box with 2 input channels. Using getUserMedia, how can I specify to stream from the first or second input from the device? I've seen how to get the device specifically by feeding in the deviceId, but it gets both inputs mixed together.
Upvotes: 1
Views: 315
Reputation: 163602
It sounds like you have a 2-channel audio interface. The MediaStream you get from getUserMedia()
will contain both channels, as that's what's coming from the source. Therefore, you can't select just one of the streams initially.
However, you can easily split out the audio you want with the ChannelSplitterNode
:
const splitter = audioContext.createChannelSplitter(2); // 2 channels
mediaStreamSourceNode.connect(splitter);
splitter.connect(targetForFirstChannel, 0);
splitter.connect(targetForSecondChannel, 1);
The second parameter of splitter.connect()
sets the index of the output you want to use.
Upvotes: 1