将主增益添加到音频图中

Adding master gain in to an Audio Graph

我使用网络音频 API 实现了一个简单的混音器。我基本上是为每个源创建一个缓冲区,添加一些过滤器,然后连接到目的地:

this.track.connect(this.highPassFilter);
this.highPassFilter.connect(this.lowShelfFilter)
this.lowShelfFilter.connect(this.highShelfFilter)
this.highShelfFilter.connect(this.midFilter);
this.midFilter.connect(this.panner)
this.panner.connect(this.gain)
this.gain.connect(this.ctx.destination)

我想做的是能够创建一个主增益和主压缩器。鉴于我所有的 'tracks' 都直接连接到 context.destination,然后当按下播放按钮时,所有这些基本上都是一致播放的,我怎样才能将主增益连接到链中?

我想你已经知道怎么做了。您需要做的是创建您的主增益和压缩器,将这两者连接在一起,然后将您的所有音轨连接到它们,如下所示:

[track] -> masterGain -> masterCompressor -> ctx.destination

或相反,随心所欲(masterCompressor -> masterGain -> ctx.destination)。