网络音频:右声道无声音

Web Audio: No sound in right channel

本文关键字:无声 声音 声道 音频 网络      更新时间:2023-09-26

我正在尝试使用Web Audio API创建一个自定义平移控件,但我无法使用频道拆分器和合并节点从正确的频道中获得任何声音:

var context = new webkitAudioContext(),
    destination = context.destination,
    osc = context.createOscillator(),
    gainL = context.createGainNode(),
    gainR = context.createGainNode(),
    splitter = context.createChannelSplitter(2),
    merger = context.createChannelMerger(2);
osc.frequency.value = 500;
osc.connect(splitter);
splitter.connect(gainL, 0);
splitter.connect(gainR, 1);
gainL.connect(merger, 0, 0);
gainR.connect(merger, 0, 1);
osc.noteOn(0);
gainL.gain.value = 0.1;
gainR.gain.value = 0.5;
osc.noteOff(2);
merger.connect(destination);

我是不是遗漏了一些显而易见的东西?这里有上面代码的JSBin预览:http://jsbin.com/ayijoy/1/

我运行的是Chrome v24.00.13125.57,以防有任何用处。

我的最佳猜测是发生这种情况是因为振荡器输出单声道信号。试着使用立体声源,你可能会有更多的运气。

编辑:以下是如何平移"单声道"信号(绕过分离器,因为没有立体声信号可以分离,并将振荡器直接连接到两个增益。然后在调整每个通道的增益后,将两个单声道信号连接到合并器)http://jsbin.com/ayijoy/16/