音频的音调认识 [英] Recognising tone of the audio

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

问题描述

我有一把吉他,我需要我的电脑才能够告诉正在播放什么注意事项,认识了基调。是否有可能做到这一点在Python中,也有可能与pygame的?如果能够这样做的pygame的将是非常有益的。

I have a guitar and I need my pc to be able to tell what note is being played, recognizing the tone. Is it possible to do it in python, also is it possible with pygame? Being able of doing it in pygame would be very helpful.

推荐答案

要认识到的音频信号的频率,你可以使用FFT(的快速傅立叶变换)算法。据我所知,pygame的有没有办法录制音频,也不支持FFT变换。

To recognize the frequency of an audio signal, you would use the FFT (fast Fourier transform) algorithm. As far as I can tell, PyGame has no means to record audio, nor does it support the FFT transform.

首先,你需要捕获从声卡原始采样数据;这种数据被称为PCM(脉冲code调制)。捕捉到在Python音频的最简单方法是使用 PyAudio库(Python绑定到PortAudio)。 的GStreamer 也能做到这一点,它可能是你的目的是矫枉过正。在48000赫兹的速度捕获16位采样为pretty典型,可能是最好的一个正常的声卡会给你。

First, you need to capture the raw sampled data from the sound card; this kind of data is called PCM (Pulse Code Modulation). The simplest way to capture audio in Python is using the PyAudio library (Python bindings to PortAudio). GStreamer can also do it, it's probably an overkill for your purposes. Capturing 16-bit samples at a rate of 48000 Hz is pretty typical and probably the best a normal sound card will give you.

一旦你有了原始的PCM音频数据时,可以使用从 SciPy的在 fftpack 模块库运行通过FFT样本变换。这会给你所分析的音频信号,即有多强在某些频段信号的的频率分布的。然后,它的发现具有最强信号的频率的一个问题。

Once you have raw PCM audio data, you can use the fftpack module from the scipy library to run the samples through the FFT transform. This will give you a frequency distribution of the analysed audio signal, i.e., how strong is the signal in certain frequency bands. Then, it's a matter of finding the frequency that has the strongest signal.

您的 的可能需要一些额外的过滤,以避免我不知道谐波频率。

You might need some additional filtering to avoid harmonic frequencies I am not sure.

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

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