I'm a newcomer to signal processing, so forgive my ignorance. I'm working on a project in Python that will play a .wav file and pick out the dominant frequency as it plays. I've found a few examples on the web, but none seem to be accurate for stereo files. It seems like I need to do something with an FFT, but I don't know too much about it. Any help would be greatly appreciated. Thanks!
1 Answer
Here's a recent blog post that may be helpful:
https://jakevdp.github.io/blog/2013/08/28/understanding-the-fft/
You want to install numpy (and probably scipy, too), and read up on the Discrete Fourier Transform (DFT; this is what the FFT computes). I'm not that up on Python media packages for the playback part. Python's wave module may be enough.
The algorithm could be as simple as computing the FFT of the last, say, 4096 samples, getting the index of the maximum absolute value, and multiplying by the bin width. Or you can get fancier and use a Hanning window, peak interpolation, overlap processing, and exponential averaging.