如何在Web Audio API中使用LFO调制AudioParam

时间:2013-04-04 20:08:36

标签: javascript web-audio

如何调制Web Audio API中的任何AudioParams,例如使用低频振荡器获取GainNode的值?

2 个答案:

答案 0 :(得分:7)

https://coderwall.com/p/h1jnmg

var saw = context.createOscillator(),
      sine = context.createOscillator(),
      sineGain = context.createGainNode();

//set up our oscillator types
saw.type = saw.SAWTOOTH;
sine.type = sine.SINE;

//set the amplitude of the modulation
sineGain.gain.value = 10;

//connect the dots
sine.connect(sineGain);
sineGain.connect(saw.frequency);

答案 1 :(得分:1)

您没有保存实际节点,只保存值 - 所以当您尝试连接到oscillator.frequency时,您传递的是一个整数值(400 - 您在节点中保存的频率)。尝试http://jsfiddle.net/GCSEq/6/ - 这会存储节点,并正确路由到AudioParam。

this.oscillator = context.createOscillator();
this.gain = context.createGainNode();

和     osctest2.play(osctest.oscillator.frequency,1000);

(您在控制台中收到错误。)