我一直在四处寻找使用Web音频API创建音频均衡器:http://webaudio.github.io/web-audio-api/网络音频API均衡器
我发现了很多有关创建可视化线程的,但当然不是我想做的事。我只是想要使用频率滑块来改变声音。我发现biquadFilter应该做的工作,但我不能得到一个好的结果。当我改变任何频率值时,声音会一直改变,但它会降低声音的质量,同时会改变频率。
我第一次加载声音:
Audio.prototype.init = function(callback){
var $this = this;
this.gainScale = d3.scale.linear().domain([0,1]).range([-40,40]);
this.context = new AudioContext();
this.loadSounds(function(){
$this.loadSound(0);
$this.play();
callback.call();
});
};
一切运作良好,声音播放时,准备好了。
我有10个频率滑块[32,64,125,250,500,1000,2000,4000,8000,16000]。 对于每个滑块创建过滤器,我将其连接到源,如描述在这里:Creating a 10-Band Equalizer Using Web Audio API:
Audio.prototype.createFilter = function(index,frequency){
if(this.filters == undefined) this.filters = [];
var filter = this.context.createBiquadFilter();
filter = this.context.createBiquadFilter();
filter.type = 2;
filter.frequency.value = frequency;
// Connect source to filter, filter to destination.
this.source.connect(filter);
filter.connect(this.context.destination);
this.filters[index] = filter;
};
最后,当我改变滑块的值I更新滤波器:
Audio.prototype.updateFilter = function(index,newVal){
this.filters[index].frequency.gain = this.gainScale(newVal);
};
注意:我的this.gainScale函数将[0,1]中的值作为输入,并返回[-40,40]中的值以将增益设置为-40至40之间的每个频率。
将不胜感激任何帮助!
嗨,非常感谢,它解决了我的大部分问题,并开始听起来像是不是太糟糕。 基本上,我现在只是创建没有类型的过滤器,而不连接它们。 然后,我根据过滤器索引给出一个类型(0:lowshelf,0 Charles
结合每个频率的低架和高架滤波器怎么样? –
例如,如果您想修改250赫兹的增益,将350减少到350以上,将第二个高架减少到150,从而将所有的部分切割到150以下。连接两个增益并一次修改它们的值?您认为这样会起作用吗? –