WebAudio FM调制

时间:2015-10-12 12:31:40

标签: javascript html5 web-audio

我尝试使用来自慢速振荡器saw的脉冲调制sine频率。我究竟做错了什么? jsFiddle这里:https://jsfiddle.net/06ua9zLo/

window.AudioContext = window.AudioContext||window.webkitAudioContext;

var context = new AudioContext();

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

//set up our oscillator types
saw.type = 'sawtooth';
sine.type = 'sine';

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

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

saw.connect(context.destination);

sine.start();
saw.start();

1 个答案:

答案 0 :(得分:3)

您的设置很好。只需尝试改变调制器的频率并增加一点增益,你就会发现你实际上在做FM。例如:

sine.frequency.value = 15;
sineGain.gain.value = 100;

肯定会告诉你它有效。