-
Notifications
You must be signed in to change notification settings - Fork 161
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
I thought I was nearly there but can't quite get it over the line. #80
Comments
micDataImag = 0; <--- duh. |
Hello, Also, if you are doing this in a loop, it might be worth initializing memory outside of it, so you don't allocate and free every iteration, as that is just wasting time. Also, you can use |
Well not really with that code. I found that it worked if I specified on the constructor as below but not as I showed it there;
Then call:
Then I get something sensible. I wasn't sure what FFT functions I needed to call before FFT.MajorPeakParabola(); There were other problems with the I2S sampling. I just wanted to get to the point where the mic was being sampled via I2s continually and I could just drop in when I felt like it and grab 512 samples and get the most dominant frequency. What I really need is a bandpass filter, which I think I will can do on the samples directly before passing into fft. |
@DrJaymz, I see a problem with the setup you describe. The sampling rate should be at least twice the highest expected frequency. Since you mention that you can hear yourself speaking, I infer you are dealing with audio. Therefore, the sampling frequency should be at least 44000. |
The sampling frequency is 64000hz. I am using the m5stack core 2 built in spm1423 microphone. I tried 22000, then 44100 and 48000 and at 64000 I got the best sound. My window size is 512 samples. |
My goal was to work out the loudest amplitude fundamental from my samples and return its frequency. Using esp32.
Obviously before I start I got my I2S device recording and playing back - I can hear myself so thats working.
Then I needed to convert my data to double. Presumably so that it has positive and negative around 0 values.
I checked this for sanity and it also looks correct. i.e. you get a waveform centred on 0.
So then, it should just be a matter of run the FFT over my samples and use the FindMajorPeak but it fails on the FFT compute step.
I have 1024 samples at this point, block size = 1, sample rate is 22000 but should be enough to run compute and get something sensible.
TBH, I know what FFT does, I'm not great at working out how big the samples needed to be and I'm used to higher level languages where I don't need to be careful with the allocation and I don't need to get in to pointers; so these are probably where I'm getting it wrong if that helps?
The text was updated successfully, but these errors were encountered: