所以我在瀏覽器中創建了一個合成器,並且想爲它添加一些過濾器。我創建了所有的濾波器,並將我的振盪器連接到濾波器,並將濾波器連接到音頻目標。現在,當我選擇低通濾波器玩,我在控制檯收到此錯誤,將不添加任何影響:網絡音頻API過濾器不起作用
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);
}
這是什麼意思?
是允許的過濾器不是這些https://developer.mozilla.org/en-US/docs/Web/API/BiquadFilterNode/type,所以在你的案例'filter.type ='lowpass'' – Quince