# How to do a Fourier transform on input from a microphone and obtain the average amplitude of a certain frequency range [closed]

I'm building a sound visualizer with LED strips controlled by python, and I'm trying to learn how to use pyAudio to perform rapid Fourier transforms on live mic input and obtain the average amplitude of a certain range of frequencies.

How do I open a sound stream and consistently update the current amplitude (say, a variable called "amplitude") of a given frequency range with the live FFT data? I have set up all the hardware and all the basic pyAudio functions work so far.

• You can grab a chunk of data using the example PyAudio code here: people.csail.mit.edu/hubert/pyaudio/#record-example. Next, you can use numpy.fft.fft to compute the FFT of the most recent data chunk. If you are interested in a frequency range $(f_1, f_2)$ you can look at FFT numbers $\lfloor Nf_1/f_s \rfloor \leq n \leq \lceil Nf_2/f_s \rceil$ where $N$ is the FFT length and $f_s$ is the sampling rate. – Atul Ingle Jan 4 '17 at 5:35