我第一次尝试在 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 时,它的工作和声音更大。
你知道为什么我可以提高音量但不能降低音量吗?