Javascript 如何逐渐改变webaudio中的低通频率?

Javascript 如何逐渐改变webaudio中的低通频率?,javascript,web-audio-api,Javascript,Web Audio Api,我试图逐渐改变我的低通滤波器的频率量,但不是逐渐发生,而是立即发生 此代码应以某个频率开始,在1秒时指数减少到200,然后在2秒时停止。相反,它保持不变,直到1秒,然后立即跳到较低的频率 var context=new(window.AudioContext | | window.webkitadiocontext)(); var振荡器=context.create振荡器(); var now=context.currentTime; //低通节点 var lowPass=context.cr

我试图逐渐改变我的低通滤波器的频率量,但不是逐渐发生,而是立即发生

此代码应以某个频率开始,在1秒时指数减少到200,然后在2秒时停止。相反,它保持不变,直到1秒,然后立即跳到较低的频率

var context=new(window.AudioContext | | window.webkitadiocontext)();
var振荡器=context.create振荡器();
var now=context.currentTime;
//低通节点
var lowPass=context.createBiquadFilter();
lowPass.connect(context.destination);
低通频率值=500;
低通Q值=0.5;
低通。频率。指数RamptoValueAttime(200,现在+1);
振荡器。连接(低通);
振荡器。开始(现在);
振荡器。停止(现在+2)
AudioParam接口有两种模式:
A.立即
B.自动化
在模式A中,只需设置参数的value属性。
在模式B中,如果你想从500“渐变”到200,你有
要首先使用自动化事件将值设置为500,例如:
频率设置值时间(500,0)
startTime参数为零时立即应用该值
根据规格。
您尝试的是混合这两种模式,但后者
不考虑第一个的值。

在Chrome或Firefox中都看不到这一点。至少您需要执行
lowPass.connect(context.destination)
。这应该适用于所有浏览器,也适用于Firefox。但在进行指数渐变之前,可能需要添加
低通.frequency.setValueAtTime(500,现在)
。 The AudioParam interface has 2 modes: A. Immediate B. Automated In mode A you simply set the value property of the parameter. In mode B, if you want to 'ramp' from 500 to 200 you have to use an automation event first to set the value to 500, eg: frequency.setValueAtTime(500, 0) A startTime parameter of zero applies the value immediately according to the specs. What you are trying is to intermingle both modes, but the latter does not take the value of the first into account.