所以我在浏览器中创建了一个合成器,并希望为它添加一些过滤器。我创建了所有过滤器的东西,并将我的振荡器连接到滤波器,将连接器连接到音频目的地。现在当我选择低通滤波器播放时,我在控制台中收到此错误并且没有添加任何效果:
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);
}
这是什么意思?