混合声音的算法 [英] Algorithm to mix sound

查看:30
本文介绍了混合声音的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将两个原始声音流相加.出于这个问题的目的,我们可以假设它们具有相同的比特率和比特深度(比如 16 位采样,44.1khz 采样率).

I have two raw sound streams that I need to add together. For the purposes of this question, we can assume they are the same bitrate and bit depth (say 16 bit sample, 44.1khz sample rate).

显然,如果我只是将它们加在一起,我的 16 位空间就会溢出和下溢.如果我将它们加在一起并除以二,那么每个的音量都会减半,这在声音上是不正确的——如果两个人在一个房间里说话,他们的声音不会变小一半,麦克风可以接听他们两者都没有碰到限制器.

Obviously if I just add them together I will overflow and underflow my 16 bit space. If I add them together and divide by two, then the volume of each is halved, which isn't correct sonically - if two people are speaking in a room, their voices don't become quieter by half, and a microphone can pick them both up without hitting the limiter.

  • 那么在我的软件混音器中将这些声音添加在一起的正确方法是什么?
  • 我错了,正确的方法是将每个音量减半?
  • 我是否需要添加压缩器/限制器或其他一些处理阶段才能获得我想要的音量和混音效果?

-亚当

推荐答案

你应该把它们加在一起,但把结果限制在允许的范围内,以防止上溢/下溢.

You should add them together, but clip the result to the allowable range to prevent over/underflow.

如果发生剪辑,您在音频中引入失真,但这是不可避免的.您可以使用剪辑代码检测"这种情况并将其报告给用户/操作员(相当于混音器上的红色剪辑"灯......)

In the event of the clipping occuring, you will introduce distortion into the audio, but that's unavoidable. You can use your clipping code to "detect" this condition and report it to the user/operator (equivalent of red 'clip' light on a mixer...)

您可以实现一个更合适"的压缩器/限制器,但在不知道您的确切应用的情况下,很难说它是否值得.

You could implement a more "proper" compressor/limiter, but without knowing your exact application, it's hard to say if it would be worth it.

如果您要进行大量音频处理,您可能希望将您的音频电平表示为浮点值,并且在处理结束时仅返回到 16 位空间.高端数字音频系统通常以这种方式工作.

If you're doing lots of audio processing, you might want to represent your audio levels as floating-point values, and only go back to the 16-bit space at the end of the process. High-end digital audio systems often work this way.

这篇关于混合声音的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆