使用Python 2.6对音频文件进行快速频谱分析?
我想要做的是有一个子程序,每 200 毫秒分析一次给定的声音文件,并将特定频率范围的频率强度值(从 0 到 1 作为浮点数)吐出到一个数组中,稍后我将其节省。然后,该值将继续用作图形的不透明度值,该图形应该“选通”到音频文件。
问题是,我以前从未尝试过音频分析,也不知道从哪里开始。我查看了 pymedia 和 scipy/numpy ,认为我可以使用 FFT 来实现这一目标,但我不太确定如何操纵这些数据以最终得到所需的结果。 pymedia 的 SpectrAnalyzer 类的文档实际上不存在,并且网站上的示例实际上不适用于该库的最新版本 - 这并不能让我的生活更轻松。
我将如何开始这个项目?我完全不知道我应该使用哪些库。
What I want to do is to have a subroutine that analyses every 200 milliseconds of a sound file which it is given and spits out the frequency intensity value (from 0 to 1 as a float) of a specific frequency range into an array which I later save. This value then goes on to be used as the opacity value for a graphic which is supposed to 'strobe' to the audio file.
The problem is, I have never ventured into audio analysis before and have no clue where to start. I have looked pymedia and scipy/numpy thinking I would be able to use FFT in order to achieve this, but I am not really sure how I would manipulate this data to end up with the desired result. The documentation on the SpectrAnalyzer class of pymedia is virtually non-existant and the examples on the website do not actually work with the latest release of the library - which isn't exactly making my life easier.
How would I go about starting this project? I am at a complete loss as to what libraries I should even be using.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您首先需要了解采样的工作原理,然后您应该使用 Scipy FFT 例程(它们非常快)来吐出频率强度值,然后您可以使用 Matplotlib 绘制此类图形。
有关使用 Python 进行分析的文章,请参阅此处声音文件,这里是一个关于Python中的FFT和频谱图的类似问题。
You will first need to understand how sampling works, then you should use Scipy FFT routines (they are pretty fast) in order spit out frequency intensity values, then you can use Matplotlib to plot such graphics.
See here for an article about using Python to analyze sound files and here is a similar question about FFT and Spectograms in Python.