【发布时间】:2014-11-28 18:24:40
【问题描述】:
我正在尝试通过channelsplitter 将立体声音频路由到具有增益控制的 6 个通道,然后返回到channelMerger,以控制 5.1 组的所有 6 个通道。设备通过 HDMI 连接,windows 正确输出到所有 6 个通道(一个可以让所有 6 个扬声器分别播放声音的屏幕)。
我能找到的唯一例子有这段代码:
if (context.destination.maxChannelCount >= 6) {
context.destination.channelCount = 6;
}
else {
context.destination.channelCount = 2;
}
初始化audiocontext时,我的channelCount默认为2,maxChannelCount为6。
我使用以下代码来创建拆分器、合并器和增益:
if (context.destination.maxChannelCount >= 6) {
context.destination.channelCount = 6;
}
else {
context.destination.channelCount = 2;
}
context.destination.channelCountMode = "explicit";
context.destination.channelInterpretation = "discrete";
var ammount = context.destination.channelCount;
console.log('Ammount of channels:',ammount); //this outputs 6
window.channelSplitter = context.createChannelSplitter(ammount);
window.channelMerger = context.createChannelMerger(ammount);
postGain.connect(channelSplitter); //postGain is the last node of the audio system
channelMerger.connect(context.destination);
window.channelGains = [];
for(i=0;i<ammount;i++){
channelGains[i] = context.createGain();
channelSplitter.connect(channelGains[i],i,0);
channelGains[i].connect(channelMerger,0,i);
}
我在 chrome(39.0.2171.71 m) 中尝试过,其中 maxChannelCount 为 6。Firefox 输出 2。
编辑: 在摆弄了 channelSplitter 之后,我发现除了前两个之外的所有输出都保持沉默。根据spec,当使用通道解释“扬声器”时,这是正确的。 这意味着我需要自己填充通道,可能使用here 描述的算法。我仍然需要检查 chrome 是否正确输出所有 6 个通道。
【问题讨论】: