本文介绍了可视化PCM样品的体积的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的C ++应用程序中有几个PCM音频(G.711)。我想要在每个块中显示不同的音频音量。

I have several chunks of PCM audio (G.711) in my C++ application. I would like to visualize the different audio volume in each of these chunks.

我的第一次尝试是计算每个块的样本值的平均值,并将其用作音量指示器,但这不工作良好。我确实得到0的块与沉默和不同的值块的音频,但是值只是有点不同,似乎不像实际的音量。

My first attempt was to calculate the average of the sample values for each chunk and use that as an a volume indicator, but this doesn't work well. I do get 0 for chunks with silence and differing values for chunks with audio, but the values only differ slighly and don't seem to resemble the actual volume.

是一个更好的算法计算音量?

What would be a better algorithem calculate the volume ?

我听到G.711音频是对数PCM。

I hear G.711 audio is logarithmic PCM. How should I take that into account ?

推荐答案

注意,我没有使用G.711 PCM音频本身,假设您在处理值之前执行从编码振幅到实际幅度的正确转换。

Note, I haven't worked with G.711 PCM audio myself, but I presume that you are performing the correct conversion from the encoded amplitude to an actual amplitude before processing the values.

您会期望大多数样本的平均值近似为零因为声音波形在零边振荡。

You'd expect the average value of most samples to be approximately zero as sound waveforms oscillate either side of zero.

粗体积计算将是rms(均方根),即对样本的平方进行滚动平均,该平均值的平方根。这将给你一个有声的数量;数量与波形中表示的功率相关。

A crude volume calculation would be rms (root mean square), i.e. taking a rolling average of the square of the samples and take the square root of that average. This will give you a postive quantity when there is some sound; the quantity is related to the power represented in the waveform.

对于与人类对音量的感知更好相关的内容,您可能想要调查。

For something better related to human perception of volume you may want to investigate the sort of techniques used in Replay Gain.

这篇关于可视化PCM样品的体积的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 00:57