我无法使 AudioContext 静音
I can't mute an AudioContext
我第一次尝试在 Javascript 中使用网络音频 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
与 context
的 destination
之间似乎仍然存在直接联系。
如果您从原始示例中删除 this line,它应该可以工作。
this.sourceNode.connect(this.context.destination);
我第一次尝试在 Javascript 中使用网络音频 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
与 context
的 destination
之间似乎仍然存在直接联系。
如果您从原始示例中删除 this line,它应该可以工作。
this.sourceNode.connect(this.context.destination);