我无法静音AudioContext

问题描述

我第一次尝试在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时,它的声音会更大。

您知道为什么我可以增加音量但不能降低音量吗?

解决方法

根据您的描述,听起来好像sourceNode的{​​{1}}到destination仍然有直接连接。

如果从原始示例中删除this line,它应该可以工作。

context