音量标准化 [英] audio volume normalization

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

问题描述

我正在编写一个音乐播放器,我想标准化不同歌曲的音量.

I am writing a music player and I want to normalize the audio volume across different songs.

我可以想到一些不同的方法来做到这一点,例如:

I could think of some different ways to do this, e.g.:

  1. 遍历所有 PCM 样本(假设是从 -1 到 1 的浮点数)并选择 m = max(abs(sample)).然后将因子 1/m 应用于所有 PCM 样本.这将使峰值为 1.

  1. Go through all PCM samples (assume floating point from -1 to 1) and select the m = max(abs(sample)). Then apply the factor 1/m to all the PCM samples. This would make the peak be at 1.

遍历 PCM 流,对于每个位置,取其周围一定宽度的汉宁窗,计算绝对样本的平均值,然后从这些数据中选取最大值并标准化所有内容.

Go through the PCM stream and for each position, take the Hanning window of some width around it, calculate the average of absolute samples and from those data, pick the maximum and normalize everything.

与 2 相同,但可以通过其他方式获得某种平均值.

The same as 2 but some other way to get some sort of averaged value.

2 和 3 的缺点是我可能需要一些剪辑,因此会降低一些质量.不过,通过不标准化为 1 而是标准化为 0.95 左右,我也许可以在某种程度上避免这种情况.但我认为 2 和 3 的优点是这对用户来说可能是更自然的归一化.维基百科也有一些关于这方面的信息并提到了RMSReplayGainEBU R128 用于测量歌曲的响度.

2 and 3 have the disadvantage that I might need some clipping and thus loose some quality. By not normalizing to 1 but to 0.95 or so, I maybe could avoid this to some degree, though. But I think 2 and 3 have the advantage that this might be the more natural normalization for the user. Wikipedia also has some information about this and mentions RMS, ReplayGain or EBU R128 to measure the loudness of a song.

其他流行音乐播放器(如 iTunes 等)是如何做到这一点的?

How are other popular music players (like iTunes or so) doing this?

推荐答案

iTunes 使用 Sound Check 技术.Sound Check 是 Apple Inc. 的一项专有技术,其功能与 ReplayGain 相似.它可在 iTunes 和 iPod 上使用."(来自维基百科)所以,这对我来说不是解决方案.

iTunes uses the Sound Check technology. "Sound Check is a proprietary Apple Inc. technology similar in function to ReplayGain. It is available in iTunes and on the iPod." (from Wikipedia) So, this is no solution for me.

ReplayGain 似乎是最常见的技术.此处解释了该算法.示例实现是 mp3gain (GPL) 或ffmpeg-replaygain(GPL,源自 mp3gain).我的 现在在我的 MusicPlayer 项目中有自己的实现(BSD-许可).

It seems that ReplayGain is the most common technic. The algorithm is explained here. A sample implementation is mp3gain (GPL) or ffmpeg-replaygain (GPL, derived from mp3gain). I have my own implementation now in my MusicPlayer project (BSD-licence).

另见这些带有实现的项目:

See also these projects with implementations:

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

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