我将继续详细说明我对 idbehold 问题的回答:
我会说您可能想要使用类型为 5(峰值)的滤波器,它允许所有频率通过,并且仅在您设置相应 filter.frequency.value 的频率处放大/降低。这使您可以串联连接过滤器,因此您不需要单独的音频路径。您还可以考虑将低架滤波器用作第一个滤波器,将一个高架滤波器用作第三个滤波器,这在 3 频段均衡器中很常见。
如果您串联使用峰值滤波器,则不需要为每个频率设置单独的增益节点,只需为特定滤波器设置 filter.gain.value。
代码如下所示:
var lowshelf = context.createBiquadFilter(),
mid = context.createBiquadFilter(),
highshelf = context.createBiquadFilter();
//set the filter types (you could set all to 5, for a different result, feel free to experiment)
lowshelf.type = 3;
mid.type = 5;
highshelf.type = 4;
//connect 'em in order
yourInput.connect(lowshelf);
lowshelf.connect(mid);
mid.connect(highshelf);
highshelf.connect(yourOutput);
然后您可以使用各自的 Q、频率和增益值调整每个频段(检查 https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#BiquadFilterNode 以查看哪些参数适用于哪种滤波器类型),例如:
lowshelf.gain.value = 0.6;
lowshelf.frequency.value = 300;
编辑:
要添加单独的增益,只需这样做
var gainNode = context.createGainNode();
然后要么做
gainNode.connect(lowshelf); //pre EQ
或
highshelf.connect(gainNode); //post EQ
取决于您是希望它在 EQ 之后还是在 EQ 之前。你通过做来控制收益
gainNode.gain.value = 0.6;