【发布时间】:2020-05-22 01:23:05
【问题描述】:
javascript新手在这里。所以我一直在搞乱 Web Audio API 试图弄清楚事情,我发现exponentialRampToValueAtTime 只是我想要的,除了它似乎只做一次(?) 使用这个通用代码:
context = new AudioContext();
oscillator = context.createOscillator();
contextGain = context.createGain();
oscillator.type = 'sine';
oscillator.frequency = 440
oscillator.connect(contextGain);
contextGain.connect(context.destination);
oscillator.start(0);
contextGain.gain.value = 1 默认情况下,所以如果我运行contextGain.gain.exponentialRampToValueAtTime(0.1,context.currentTime + 2),它会从 1 平稳地下降到 0.1。但是如果我试图让它回到 1,比如contextGain.gain.exponentialRampToValueAtTime(1,context.currentTime + 2),它会突然跳到 1。为什么会发生这种情况?有什么方法可以让我想多少次就做多少次?提前致谢。
【问题讨论】: