Reproduction of oscillations in one channel

I tried to make the oscillator sound play in only one channel, and I could not get it to work.

I tried using the panner node to set the position of the sound, but it still plays in both channels, but not so loud in the more distant channel.

My last attempt tried using channel merging, but it still plays in both channels:

 var audioContext = new webkitAudioContext(); var merger = audioContext.createChannelMerger(); merger.connect(audioContext.destination); var osc = audioContext.createOscillator(); osc.frequency.value = 500; osc.connect( merger, 0, 1 ); osc.start( audioContext.currentTime ); osc.stop( audioContext.currentTime + 2 ); 

How to create a generator that plays in only one channel?

+4
source share
1 answer

Hmm, weird - it seems like a mistake when the Merge input is not connected. To get around, just connect the nulled gain of the node to another input, for example:

 var audioContext = new webkitAudioContext(); var merger = audioContext.createChannelMerger(2); merger.connect(audioContext.destination); var osc = audioContext.createOscillator(); osc.frequency.value = 500; osc.connect( merger, 0, 0 ); // workaround here: var gain= audioContext.createGainNode(); gain.gain.value = 0.0; osc.connect( gain ); gain.connect( merger, 0, 1 ); // end workaround osc.start( audioContext.currentTime ); osc.stop( audioContext.currentTime + 2 ); 
+2
source

All Articles