【问题标题】:I can't mute an AudioContext我不能静音 AudioContext
【发布时间】:2020-09-01 07:45:55
【问题描述】:

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

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

【问题讨论】:

  • 您能否创建一些示例代码来重现您的问题?更好的是,发布一个 JSFiddle 链接?

标签: javascript web-audio-api


【解决方案1】:

从您的描述看来,从sourceNodecontextdestination 之间仍然存在直接连接。

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

this.sourceNode.connect(this.context.destination);

【讨论】:

    猜你喜欢
    • 2022-01-21
    • 1970-01-01
    • 1970-01-01
    • 2020-05-04
    • 2021-07-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    相关资源
    最近更新 更多