1

在我看来,CoreAudio 在将声波混合到单个通道时会一起添加声波。我的程序会发出合成声音。我知道每个声音的幅度。当我将它们一起播放时,我应该将它们加在一起并乘以所得波以保持在范围内吗?我可以这样做:

MaxAmplitude = max1 + max2 + max3 //Maximum amplitude of each sound wave
if MaxAmplitude > 1 then //Over range
    Output = (wave1 + wave2 + wave3)/MaxAmplitude //Meet range
else
    Output = (wave1 + wave2 + wave3) //Normal addition
end if

我可以这样做吗?我是否应该预先分析声波以找到实际的最大幅度(因为时间轴上的最大值可能不匹配)并使用它?

我想要的是一种方法,可以同时播放多个合成声音,而不会完全降低音量并且听起来无缝。如果我用几种合成乐器演奏和弦,我不想要求单个音符实际上是无声的。

谢谢你。

4

2 回答 2

2

在单个样本的基础上突然改变比例,这就是你的“if”语句所做的,听起来很糟糕,类似于剪辑。

您可以研究自适应 AGC(自动增益控制),它会更缓慢地改变比例因子,但在快速瞬变期间仍可能会削波或突然改变音量。

如果您使用 AGC 算法的前瞻来防止突然的瞬变削波,那么您的延迟会变得更糟。

如果您确实使用 AGC,那么孤立的音符听起来可能比在和弦中演奏时的音量要大得多,这可能无法正确代表音乐作品的意图(尽管这种类型的压缩在烦人的电视和广播广告中很常见)。

Scaling down the mixer output volume so that the notes will never clip or have their volume reduced other than when the composition indicates will result in a mix with greatly reduced volume for a large number of channels (which is why properly reproduced classical music on the radio is often too quiet to draw enough viewers to make enough money).

It's all a trade-off.

于 2011-12-18T03:59:11.663 回答
0

I don't see this is a problem. If you know the max amplitude of all your waves (for all time) it should work. Be sure not to change the amplitude on per sample basis but decide for every "note-on". It is a very simple algorithm but could suit your needs.

于 2011-12-29T22:28:52.413 回答