0

I'm developing an Android application, what that i need is recognize a musical tone, for example, if you took my guitar and you played a C I would like my application was able to tell me the note that I played.

The basic operation would be simple, and the sound from the microphone recorded through some sort of recognition would have the output of which I need.

The only one thing that i don't know is: it is possible do this ?

If is yes, is it possible recognize more than one notes over a period of time?

  • See this code: https://code.google.com/p/android-guitar-tuner/source/browse/trunk/src/com/example/GuitarTuner/FFT.java?r=2 – Phantômaxx Dec 17 '14 at 14:47

1 Answers1

3

Possible? Certainly. There are already apps on the store that do this: Take this for example. As for how to do it, this question might lead you in the right direction, and here's the text for that question:

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.

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.

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.

Community
  • 1
  • 1
Andrew Orobator
  • 7,978
  • 3
  • 36
  • 36
  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – 2Dee Dec 17 '14 at 15:05
  • Good point. I've edited my answer with the text from the answer I linked. – Andrew Orobator Dec 17 '14 at 15:08
  • 1
    Wow, it's a really nice answer now. You, sir, deserve an upvote ! – 2Dee Dec 17 '14 at 15:11