我创建了一个带振荡器的音频上下文但我无法控制输出的增益,即使使用gainNode.gain.value
:
var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioctx = new AudioContext();
var gainNode = audioctx.createGain();
var oscillator = audioctx.createOscillator();
var oscillator2 = audioctx.createOscillator();
oscillator.connect(audioctx.destination);
oscillator.start(0);
gainNode.connect(audioctx.destination);
gainNode.gain.value = 0;
答案 0 :(得分:1)
您需要将振荡器连接到增益节点,而不是目标:
oscillator.connect(gainNode);
oscillator.start(0);
gainNode.connect(audioctx.destination);
gainNode.gain.value = 0;