简体   繁体   English

Python中3D音频信号的平均RMS值

[英]Average RMS value of an 3D audio signal in Python

I am quite new to programming and Python. 我对编程和Python很陌生。 I am working on a project in which I built an Auditory filterbank with two banks of Gammatone filters. 我正在一个项目中,我用两个Gammatone过滤器库构建了一个Auditory过滤器库。 Now I ended up with a 39x10x8545 matrix. 现在,我得到了一个39x10x8545矩阵。 I want to calculate the average of rms energy across the time axis (over the 8545) to reduce the dimensionality of the signal. 我想计算整个时间轴(在8545上)的均方根能量的平均值,以减小信号的维数。 Can anyone suggest me a better method to do it efficiently in Python because I cannot afford much memory due to the audio signal being very large. 谁能建议我一个更好的方法来在Python中高效地执行此操作,因为音频信号非常大,我负担不起很多内存。 Thanks in advance. 提前致谢。

The RMS of is signal is the root mean squared, which is not the same as the mean. is信号的RMS是均方根,与均方根不同。 So you need to perform the RMS calculation. 因此,您需要执行RMS计算。

math.sqrt(numpy.mean(x*x))

There are several other pages on this site that discuss this in further: here , here , here 该网站上还有其他几页对此进行了进一步讨论: 此处此处此处

I would like to answer this question myself based on Djmoffat's answer. 我想根据Djmoffat的回答自己回答这个问题。 I tried his answer but found that the numpy.pow() gave me very slow results. 我尝试了他的答案,但发现numpy.pow()给了我非常慢的结果。 So I tried using 所以我尝试使用

math.sqrt(numpy.mean(x**2)) 

This gave me faster results. 这给了我更快的结果。 I understand that math.pow() is slow as it has to consider many other things like fractional powers and other things clearly discussed here . 我知道math.pow()速度很慢,因为它必须考虑许多其他事物,例如分数幂和此处明确讨论的其他事物。 The context is important as I am sure I will have just the integer powers and more precisely '2'. 上下文很重要,因为我确信我将只有整数幂,更确切地说是“ 2”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM