Comments (5)
micDataImag = 0; <--- duh.
micDataImag[i] = 0;
from arduinofft.
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.
The microphone is a PDM microphone not PCM, but I'm told that the I2S driver interface takes care of that weird format and all I need to do is just read. I couldn't find any useable documentation on any of that - but I found a demo someone else had done also using 64000 and used the same settings. Whether or not PDM leads to different effective sample rates than PCM I have no idea. But the fundamental frequency emitted from ardiuinoFFT when I use a 1kHz tone is 1.000Khz. So - guess it must be correct.
from arduinofft.
Hello,
so with this fix, the code is working as it should now?
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 new
in c++ and then delete[]
to deallocate it, which is a bit nicer than malloc. Or you can init array on stack/data segment without malloc or new if you know the size beforehand, like: double data[size];
from arduinofft.
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;
double vReal[512];
double vImag[512];
arduinoFFT FFT = arduinoFFT(vReal, vImag, 512, 64000);
Then call:
FFT.Compute(FFT_FORWARD);
FFT.ComplexToMagnitude();
double peak = FFT.MajorPeakParabola();
Then I get something sensible. I wasn't sure what FFT functions I needed to call before FFT.MajorPeakParabola();
But this seemed to work. No idea if I needed to remove DC or not beforehand, but I don't think it changes anything.
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.
I have it working but its a bit messy to integrate with my existing code right now.
What I really need is a bandpass filter, which I think I will can do on the samples directly before passing into fft.
from arduinofft.
@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.
from arduinofft.
Related Issues (20)
- Needs function to calculate octaves
- Implement C++ template HOT 5
- (improvement) use sqrtf() on ESP32 HOT 2
- Windowing / Weighing Factor HOT 1
- too much time cost for compute FFT on Esp32-C3 HOT 6
- Weird results while imag input other than 0 at example FFT_1 HOT 2
- Updating Documentation and Examples HOT 1
- Performance++ HOT 10
- Needed FFT real time example HOT 1
- average FFT result HOT 1
- calc complex amplitude for only specific frequencies HOT 1
- What is the relation of the calculated magnitude to the original signal
- Windowing compensation factors HOT 1
- First two bins 0 Hz and 62.5 Hz always an order of magnitude larger than all other bins HOT 5
- v2.0 does not extract major peak, while v1.6.2 does HOT 24
- Inverse function does not work correctly HOT 1
- FFT Uncertainty HOT 1
- Issue with library dictionary HOT 1
- Cannot detect frequency from sound sensor in v2 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arduinofft.