sound filtering and FFT.  How to get started? - Page 1
Forum section: electronics / projects

author: viper
author_rank: Regular Contributor
timestamp: September 07, 2025, 11:07:38 pm
content: I need to analyze sound from a microphone, then filter down to only a certain target frequency range, then down to very specific target known frequencies. I'm expecting FFT to get me there, but I've never done this. I need to write some code into an ESP for this. Hoping someone can send me down the right path to get my feet wet?

author: ledtester
author_rank: Super Contributor
timestamp: September 07, 2025, 11:20:38 pm
content: Look up the Goertzel algorithm.Here's a Hackaday article overview of it:https://hackaday.com/2020/11/13/dsp-spreadsheet-the-goertzel-algorithm-is-fouriers-simpler-cousin/and here is a forum post which contains a link to a software DTMF detector for a microcontroller:https://www.eevblog.com/forum/microcontrollers/help-grandma-hear-her-doorbell%21/msg5664081/#msg5664081Decoding DTMF requires detecting the presence of eight different frequencies.https://en.wikipedia.org/wiki/DTMF_signaling

author: viper
author_rank: Regular Contributor
timestamp: September 08, 2025, 12:14:09 am
content: Appreciate! Now looking into less complex algorithms that could do this.I guess I was wondering if there was preferred software to assist in this task? Free or otherwise? Was wondering if matlab, labview, etc would help examine the wave forms and help determine the best math approach?Obviously I am green on this stuff. Trying to do some learning. In my head I have to figure out how to capture the raw wave forms encountered. Then apply some filtering or correlations to identify the target frequencies with some visual references. My scope can't do that. Then figure out which math approach to run on the ESP.I'm sure that all sounds vague AF because I know I am missing something in this chain.

author: ledtester
author_rank: Super Contributor
timestamp: September 08, 2025, 01:57:03 am
content: Quote from: viper on September 08, 2025, 12:14:09 amThe Goertzel algorithm assumes you know which frequencies you are interested in.I would look at Audacity as a free way to analyze your sound:https://www.audacityteam.org/It has a bunch of tools to analyze the spectrum of an audio sample:https://support.audacityteam.org/audio-analysis/spectral-analysisThe easiest way to get your audio into Audacity is to record it on your PC as a .wav file.Otherwise you can import a stream of ADC readings into Audacity as a "raw" file.A quick summary of a raw PCM file is that it is a sequence of signed 16-bit integers. Each integer will be represented in the file as two bytes and you can decide to put the low byte first or the high byte first.To load the file into Audacity, use the File -> Import -> Raw Data menu option, select the file and then select "Signed 16-bit PCM", the byte order, "1-Channel Mono" and the sample rate you recorded the samples at.

author: viper
author_rank: Regular Contributor
timestamp: September 08, 2025, 02:57:01 am
content: Thanks, I was headed in the Audacity direction.I was going to load and study, but maybe you can answer, for test work, my hope was to use an I2S MEMS mic and connect to laptop. Curious if Audacity can accept that input as either live data and/or save file to use for filter work? I was trying to keep some things digital for this work.If that can work, I'd probably need to figure out a USB I2S device for that. I haven't thought this through yet...lol I have a mic jack on laptops but I'm sure that is for electrets in which I was hoping to stick with the mic type I would actually be wanting to use. It may not matter much for the test work though and I'm over thinking it as usual....

author: ledtester
author_rank: Super Contributor
timestamp: September 08, 2025, 03:38:52 am
content: There seems to be support for recording audio from I2S on a Raspberry Pi:https://learn.adafruit.com/adafruit-i2s-mems-microphone-breakout/raspberry-pi-wiring-test