0
votes

To do so I would need to make use of WebAudio API and its ChannelSplitter feature in order to access the individual channels. I would then need to have functions that could set the gain for Left and Right channels so that I only use one at a time and merge the channels back to their original destination (the audio file). However I have been trying for countless hours and can't get any implementation to work so am reaching out to any of you experts available on here!

The codepen below outlines what I am trying to achieve

<a>https://codepen.io/grahamfalconer/pen/eYdgeBe</a>
1

1 Answers

0
votes
<body>
  <audio id="my-audio" src="audio/Squirrel Nut Zippers - Trou Macacq.mp3"></audio>
</body>
<script>
  const context = new AudioContext(),
    audioSource = context.createMediaElementSource(document.getElementById("my-audio")),
    splitter = context.createChannelSplitter(2)
audioSource.connect(splitter);
splitter.connect(context.destination);
merger = context.createChannelMerger(2);

var gainNode = context.createGain();
gainNode.gain.setValueAtTime(0.5, context.currentTime);
splitter.connect(gainNode, 0);

gainNode.connect(merger, 0, 1);
splitter.connect(merger, 1, 0);

var dest = context.createMediaStreamDestination();

merger.connect(dest);

myAudio = document.getElementById("my-audio")
myAudio.play()

</script>