-2

i am in trial of creating an app with python which displays the exact value of present dominating frequency of audio from microphone input.just like as shown in this picture taken from a guitar tuner app

enter image description here

i just marked with red the part which i need to know how to program. i need to run it in PC so how to access the microphone port and how to know the frequency.

James Z
  • 12,209
  • 10
  • 24
  • 44
dani
  • 29
  • 1
  • 4

2 Answers2

1

Find a way of recording your audio from the mic port and then run a Fourier transform to look at the spectrum. Find the frequency that has the most energy and plot that on the meter.

nimish
  • 4,755
  • 3
  • 24
  • 34
  • 2
    You know that should not promote questions like that. – tupui Aug 27 '17 at 19:08
  • Thank u nimish i have done it already what u suggested iam looking for a code that displays the frequency in real time .u can understand if u try the app.thank u in advance – dani Aug 29 '17 at 12:32
1

I won't provide code since you have not shown anything at your end. But here are high-level steps and hints to go do it.

1) Use `pyaudio blocking wire stream to read input from microphone in the form of chunks [ pieces].

2) For each chunk , apply fft and get frequency for all the chunks and add to an array/list.
There are some useful discussion here and here So if you have following parameters as per (1)

RATE = 44100
chunk = 1024
RECORD_SECONDS = 1

You will have 44 bins, with each bins providing one frequency after FFT transformations.

3) You can select maximum frequency max(frequency_list) that you get from (2) per second, Times how many seconds you wish to record.

4) Write the chunks back to stream

5) You have now frequency per second till time duration of your recording in real-time that you can play with.

Anil_M
  • 10,893
  • 6
  • 47
  • 74