oldexamplecode
Dependencies: mbed
DFT.h@0:6863633bf8a4, 2017-03-24 (annotated)
- Committer:
- rik
- Date:
- Fri Mar 24 11:22:30 2017 +0000
- Revision:
- 0:6863633bf8a4
oldexamplecode;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rik | 0:6863633bf8a4 | 1 | |
rik | 0:6863633bf8a4 | 2 | // This file first preprocesses a 1024 long data array by: |
rik | 0:6863633bf8a4 | 3 | // - Calculating and substracting the mean |
rik | 0:6863633bf8a4 | 4 | // - Applying a hanning window |
rik | 0:6863633bf8a4 | 5 | // - Re-indexing the array |
rik | 0:6863633bf8a4 | 6 | // It then applies a radix-2 Cooley Tukey FFT to create a DFT of the original signal |
rik | 0:6863633bf8a4 | 7 | |
rik | 0:6863633bf8a4 | 8 | #pragma once |
rik | 0:6863633bf8a4 | 9 | #ifndef _DFT_H_ |
rik | 0:6863633bf8a4 | 10 | #define _DFT_H_ |
rik | 0:6863633bf8a4 | 11 | |
rik | 0:6863633bf8a4 | 12 | #include <string.h> // Only for memcpy |
rik | 0:6863633bf8a4 | 13 | #include "LookupTables.h" |
rik | 0:6863633bf8a4 | 14 | #include "complexmath.h" |
rik | 0:6863633bf8a4 | 15 | |
rik | 0:6863633bf8a4 | 16 | // Preprocesses the data array and performs a dft on it, ARRAY MUST BE 1024 LONG |
rik | 0:6863633bf8a4 | 17 | void performFFT(float* datam, int datalength); |
rik | 0:6863633bf8a4 | 18 | |
rik | 0:6863633bf8a4 | 19 | // Performs a radix-2 cooley tukey FFT on the data array |
rik | 0:6863633bf8a4 | 20 | void cooleyTukeyRadix2(float* data, int datalength); |
rik | 0:6863633bf8a4 | 21 | |
rik | 0:6863633bf8a4 | 22 | // Calculates and subtracts the signal mean |
rik | 0:6863633bf8a4 | 23 | void subMean(float* data, int datalength); |
rik | 0:6863633bf8a4 | 24 | |
rik | 0:6863633bf8a4 | 25 | // Reindexes the array in preperation of the FFT |
rik | 0:6863633bf8a4 | 26 | void reindexData(float* data, int datalength); |
rik | 0:6863633bf8a4 | 27 | |
rik | 0:6863633bf8a4 | 28 | // Removes the DC component and null everything above the nyquist frequency |
rik | 0:6863633bf8a4 | 29 | void afterProcessing(float* data, int datalength); |
rik | 0:6863633bf8a4 | 30 | |
rik | 0:6863633bf8a4 | 31 | // Filter a frequency and its multiples |
rik | 0:6863633bf8a4 | 32 | void filterfreq(int frequency, float* data, int datalength); |
rik | 0:6863633bf8a4 | 33 | |
rik | 0:6863633bf8a4 | 34 | // Calculate total magnitude, frequency magnitude component integrating module (FMCIM) |
rik | 0:6863633bf8a4 | 35 | int calcPSD(float* data, int datalength); |
rik | 0:6863633bf8a4 | 36 | |
rik | 0:6863633bf8a4 | 37 | #endif |