Javascript 多个振荡器尖叫,增益在网络音频中没有影响

Javascript 多个振荡器尖叫,增益在网络音频中没有影响,javascript,web-audio-api,web-midi,Javascript,Web Audio Api,Web Midi,我正在用WebMIDI控件构建一个简单的合成器。增益节点对振荡器没有影响,它在整个时间内都处于满音量。而且,当我弹奏和弦时,频率是正确的,但有抖动和尖叫的效果。当使用我的MIDI控制器以及使用控制台启动和停止合成器时,会出现问题 这是我的合成器代码: var synth = { voices: {}, start: function (note, vol) { this.voices[note] = { gain: audio.createGain(),

我正在用WebMIDI控件构建一个简单的合成器。增益节点对振荡器没有影响,它在整个时间内都处于满音量。而且,当我弹奏和弦时,频率是正确的,但有抖动和尖叫的效果。当使用我的MIDI控制器以及使用控制台启动和停止合成器时,会出现问题

这是我的合成器代码:

var synth = {
  voices: {},

  start: function (note, vol) {
      this.voices[note] = {
          gain: audio.createGain(),
          osc: audio.createOscillator()
      }

      this.voices[note].gain.connect(audio.destination);

      this.voices[note].osc.frequency.value = noteToFreq(note);
      this.voices[note].osc.connect(this.voices[note].gain);

      this.voices[note].osc.start(0);
      this.voices[note].gain.gain.setTargetAtTime(vol, audio.currentTime, 0.5);
  },

  stop: function (note) {
    this.voices[note].gain.gain.setTargetAtTime(0, audio.currentTime, 2);
    this.voices[note].osc.stop(audio.currentTime + 2);
  }
}

振荡器为全量程-即[1,+1]。当对两个信号求和时(例如,将它们连接到同一个输出节点-它们在[-2,+2]的范围内),这将缩短一些时间。将它们通过一个值为0.5的增益节点运行,看看是否可以消除问题。(理想情况下,可以稍微降低增益,然后通过一个压缩器/限制器运行它们。)