0

我第一次尝试在 Javascript 中使用 Web Audio API。

对于个人项目,我正在尝试控制音量,但我遇到了一些困难。

我正在使用这个 git 项目:https ://github.com/kelvinau/circular-audio-wave

在这个项目中,我添加了这个在函数 play() 中使用的函数:

changeVolume() {
    const volume = this.context.createGain();
    volume.gain.value = 0.1;
    volume.connect(this.context.destination)
    this.sourceNode.connect(volume)
}

当我将增益设置为 0 时,它不会静音。但是当我设置为 3 时,它的工作和声音更大。

你知道为什么我可以提高音量但不能降低音量吗?

4

1 回答 1

0

根据您的描述,听起来好像仍然存在从sourceNode到 的destination直接连接context

如果您从原始示例中删除此行,它应该可以工作。

this.sourceNode.connect(this.context.destination);
于 2020-08-31T23:45:55.450 回答