Isolate output of right channel or left channel of audio blob using a panner (Javascript)

380 views Asked by At

I am using wavesurfer.js to display and play an audio blob and am looking for a way to isolate the audio output of the right channel and left channel. I tried adding a StereoPannerNode but it seems like both channels play out of whichever side I pan to and doesn't effectively isolate the right channel at +1 or left channel at -1. Any help with this issue would be much appreciated!

1

There are 1 answers

0
chrisguttandin On

To isolate a channel of a signal with the Web Audio API you could use the ChannelSplitterNode which allows you to connect the individual channels of a signal separately.

A simple example to isolate the left channel (channel at index 0) from a stereo signal might look like this:

const channelSplitterNode = new ChannelSplitterNode(
    audioContext,
    { numberOfOutputs: 2 }
);

input
    .connect(channelSplitterNode)
    .connect(output, 0);

Jordan Eldredge once wrote a nice article which explains the difference between the StereoPannerNode and what he calls a StereoBalanceNode. Implementing a Robust Web Audio API Balance Node