for LPC1114FN28 (Cortex-M0)
Fork of UIT_FFT_Real by
fftReal.hpp@0:982a9acf3a07, 2014-12-19 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Fri Dec 19 12:10:34 2014 +0000
- Revision:
- 0:982a9acf3a07
- Child:
- 1:ba9ce95ec9a4
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:982a9acf3a07 | 1 | //------------------------------------------------------------------- |
MikamiUitOpen | 0:982a9acf3a07 | 2 | // FFT class for real data ---- Header |
MikamiUitOpen | 0:982a9acf3a07 | 3 | // This class can execute FFT and IFFT |
MikamiUitOpen | 0:982a9acf3a07 | 4 | // Copyright (c) 2014 MIKAMI, Naoki, 2014/12/19 |
MikamiUitOpen | 0:982a9acf3a07 | 5 | //------------------------------------------------------------------- |
MikamiUitOpen | 0:982a9acf3a07 | 6 | |
MikamiUitOpen | 0:982a9acf3a07 | 7 | #ifndef FFT_REAL_HPP |
MikamiUitOpen | 0:982a9acf3a07 | 8 | #define FFT_REAL_HPP |
MikamiUitOpen | 0:982a9acf3a07 | 9 | |
MikamiUitOpen | 0:982a9acf3a07 | 10 | #include "mbed.h" |
MikamiUitOpen | 0:982a9acf3a07 | 11 | #include <complex> // requisite for complex |
MikamiUitOpen | 0:982a9acf3a07 | 12 | |
MikamiUitOpen | 0:982a9acf3a07 | 13 | namespace Mikami |
MikamiUitOpen | 0:982a9acf3a07 | 14 | { |
MikamiUitOpen | 0:982a9acf3a07 | 15 | typedef complex<float> Complex; // define "Complex" |
MikamiUitOpen | 0:982a9acf3a07 | 16 | |
MikamiUitOpen | 0:982a9acf3a07 | 17 | class FftReal |
MikamiUitOpen | 0:982a9acf3a07 | 18 | { |
MikamiUitOpen | 0:982a9acf3a07 | 19 | private: |
MikamiUitOpen | 0:982a9acf3a07 | 20 | const int N_FFT_; |
MikamiUitOpen | 0:982a9acf3a07 | 21 | const float N_INV_; |
MikamiUitOpen | 0:982a9acf3a07 | 22 | |
MikamiUitOpen | 0:982a9acf3a07 | 23 | Complex* wTable_; // twiddle factor |
MikamiUitOpen | 0:982a9acf3a07 | 24 | uint16_t* bTable_; // for bit reversal |
MikamiUitOpen | 0:982a9acf3a07 | 25 | Complex* u_; // working area |
MikamiUitOpen | 0:982a9acf3a07 | 26 | |
MikamiUitOpen | 0:982a9acf3a07 | 27 | // Processing except for last stage |
MikamiUitOpen | 0:982a9acf3a07 | 28 | void ExcludeLastTtage(); |
MikamiUitOpen | 0:982a9acf3a07 | 29 | // Use for reordering of rit reversal in IFFT |
MikamiUitOpen | 0:982a9acf3a07 | 30 | int Index(int n) { return (N_FFT_-bTable_[n]); } |
MikamiUitOpen | 0:982a9acf3a07 | 31 | |
MikamiUitOpen | 0:982a9acf3a07 | 32 | FftReal(const FftReal& ); |
MikamiUitOpen | 0:982a9acf3a07 | 33 | FftReal& operator=(const FftReal& ); |
MikamiUitOpen | 0:982a9acf3a07 | 34 | |
MikamiUitOpen | 0:982a9acf3a07 | 35 | public: |
MikamiUitOpen | 0:982a9acf3a07 | 36 | // Constructor |
MikamiUitOpen | 0:982a9acf3a07 | 37 | explicit FftReal(int16_t n); |
MikamiUitOpen | 0:982a9acf3a07 | 38 | // Destructor |
MikamiUitOpen | 0:982a9acf3a07 | 39 | ~FftReal(); |
MikamiUitOpen | 0:982a9acf3a07 | 40 | // Execute FFT |
MikamiUitOpen | 0:982a9acf3a07 | 41 | void Execute(const float x[], Complex y[]); |
MikamiUitOpen | 0:982a9acf3a07 | 42 | // Execute IFFT |
MikamiUitOpen | 0:982a9acf3a07 | 43 | void ExecuteIfft(const Complex y[], float x[]); |
MikamiUitOpen | 0:982a9acf3a07 | 44 | }; |
MikamiUitOpen | 0:982a9acf3a07 | 45 | } |
MikamiUitOpen | 0:982a9acf3a07 | 46 | #endif // FFT_REAL_HPP |