每当我尝试一个简单的振荡器(检查 this example 。它不是我的,但它显示同样的问题)我在开始和结束时听到“咔哒”声。
我怎样才能绕过这个问题?
最佳答案
要停止咔嗒声,您需要平滑地斜升振荡器,而不是立即启动它。类似于以下内容:
var osc = context.createOscillator();
var gain = context.createGain();
osc.connect(gain);
gain.gain.setValueAtTime(0, context.currentTime);
gain.gain.linearRampToValueAtTime(1, context.currentTime + <some small time>);
osc.start();
...
// To stop the oscillator, ramp the gain down.
gain.gain.linearRampToValueAtTime(0, endTime - <small time>);
osc.stop(endTime);
关于javascript - WebAudio 振荡器 "click",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32948961/