web audio api: multiply waves

混江龙づ霸主 提交于 2019-12-12 13:46:55

问题


The Web Audio API lets me create a constant sine wave in a specified frequence signal like this:

var actx = new AudioContext();
var osc = actx.createOscillator();

osc.frequency.value = 500;
osc.connect(actx.destination);
osc.start();

How can I multiply this wave by another wave in order to "shape" it. For example how could I multiply it by another sine wave of 200 Hz.

Like so:


回答1:


Try something like

var osc1 = context.createOscillator();
var osc2 = context.createOscillator();
var gain = context.createGain();

osc1.frequency.value = 500;
osc2.frequency.value = 20;

osc1.connect(gain);
osc2.connect(gain.gain);

gain.connect(context.destination);

osc1.start();
osc2.start();


来源:https://stackoverflow.com/questions/35259046/web-audio-api-multiply-waves

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!