-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to obtain fundamental frequency and harmonics? #4
Comments
Hi @danielcrenna, it may be easier for you to interact with the sound card, take the FFT, and skip the spectrograph entirely. This project shows how to create a real-time FFT graph: https://github.com/swharden/Csharp-Data-Visualization/tree/master/examples/2019-06-08-audio-fft and finding the fundamental frequencies just involves finding the peaks. Also the audio monitor demo of ScottPlot here: https://github.com/swharden/ScottPlot/tree/master/demos/src/audio-monitor already does peak detection and displays the fundamental frequency in the corner I hope these demos help get you started! |
I originally misread this to mean you are new to programming - it seems by your GitHub this is not the case so I'll give you a more thorough answer! I use the NAudio library for this task. All that useful code is collected into this one file that calculates FFTs: https://github.com/swharden/Spectrogram/blob/master/src/Spectrogram/Operations.cs Making spectrographs is a lot of analytical noise. What you need for frequency detection is:
Fundamental frequencies will be a peak, and harmonics are every multiple of that peak (e.g., 200 Hz, 400 Hz, 600 Hz, 800 Hz, etc). You'll know what index values these are by the frequency calculation mentioned above.
Let's say you want to remove all frequencies between 500Hz and 1kHz.
I hope this helps! edit: I may be off by a factor of 2 when it comes to the number of points to expect. I also didn't mention a mirroring phenomenon which may be collapsed. With a little trial and error, and graphing the output, you'll probably quickly figure it out! There are many tutorials on FFT audio processing and, although a heavy topic, will prove useful to review if you're going to undertake this challenge because it's a bit complicated and easy to get wrong |
@swharden Thank you for being so generous with your time! I had a discussion with another programmer friend of mine about an hour before you posted your follow-up, and through that I learned that the iFFT is essentially for getting things back into time-space from frequency-space, which was one of the fundamental bits I was missing, and your comments are a nice roadmap to move forward. I'll certainly follow-up if I produce anything useful. Much obliged. |
I'm glad I was able to help!
If you come up with a simple-case example how to do these things, let me know and I'd be happy to host it or link to it on a few of my pages. Good luck! |
Hi Scott,
I'm brand new to audio programming, so I may be off the mark here, but I'm wondering if there is any way to assist obtaining the fundamental frequencies from the spectrogram/FFT output.
I'm trying to obtain the fundamental frequencies after serializing the FFT data that is created for the spectrogram, so I can create a new waveform with modified frequencies to the input waveform.
Does the Waterfall demo already output the fundamental/peak frequency? Does the spectrogram account for power spectral density?
The text was updated successfully, but these errors were encountered: