所以我在浏览器中创建了一个合成器,并想添加几个过滤器。我创建了所有的滤波器,并将振荡器连接到滤波器,将滤波器连接到音频目标。现在,当我选择低通滤波器播放时,我在控制台中得到这个错误,并且没有添加任何效果:
The provided value '3' is not a valid enum value of type BiquadFilterType.
我的代码片段:
function init() {
octaveNumber = document.getElementById("octaveNum");
audioCtx = new (window.AudioContext || window.webkitAudioContext);
osc = audioCtx.createOscillator();
volume = audioCtx.createGain();
filter = audioCtx.createBiquadFilter();
osc.connect(filter);
volume.connect(audioCtx.destination);
booleanVal = false;
osc.frequency.value = freqSlider.value
osc.start();
gainDisplay.innerHTML = gainSlider.value;
}
lowpass.addEventListener("click", function(event) {
filter.type = 3; // In this case it's a lowshelf filter
filter.frequency.value = 440;
filter.Q.value = 0;
filter.gain.value = 0;
})
function start() {
UI('start');
volume.gain.value = gainSlider.value;
filter.connect(volume);
}
这是什么意思?