FFT for real data using decimation-in-frequency algorithm. 実データに対するFFT.周波数間引きアルゴリズムを使用. このライブラリを登録した際のプログラム: Demo_FFT_IFFT
Dependents: UIT2_SpectrumAnalyzer F746_SpectralAnalysis_NoPhoto F746_FFT_Speed F746_RealtimeSpectrumAnalyzer ... more
fftReal.hpp@2:9649d0e2bb4a, 2015-12-18 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Fri Dec 18 10:01:28 2015 +0000
- Revision:
- 2:9649d0e2bb4a
- Parent:
- 1:559a63853f3f
- Child:
- 3:dc123081d491
3
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 | 2:9649d0e2bb4a | 4 | // Copyright (c) 2015 MIKAMI, Naoki, 2015/12/18 |
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 | 2:9649d0e2bb4a | 19 | public: |
MikamiUitOpen | 2:9649d0e2bb4a | 20 | // Constructor |
MikamiUitOpen | 2:9649d0e2bb4a | 21 | explicit FftReal(int16_t n); |
MikamiUitOpen | 2:9649d0e2bb4a | 22 | // Destructor |
MikamiUitOpen | 2:9649d0e2bb4a | 23 | ~FftReal(); |
MikamiUitOpen | 2:9649d0e2bb4a | 24 | // Execute FFT |
MikamiUitOpen | 2:9649d0e2bb4a | 25 | void Execute(const float x[], Complex y[]); |
MikamiUitOpen | 2:9649d0e2bb4a | 26 | // Execute IFFT |
MikamiUitOpen | 2:9649d0e2bb4a | 27 | void ExecuteIfft(const Complex y[], float x[]); |
MikamiUitOpen | 2:9649d0e2bb4a | 28 | |
MikamiUitOpen | 0:982a9acf3a07 | 29 | private: |
MikamiUitOpen | 0:982a9acf3a07 | 30 | const int N_FFT_; |
MikamiUitOpen | 0:982a9acf3a07 | 31 | const float N_INV_; |
MikamiUitOpen | 0:982a9acf3a07 | 32 | |
MikamiUitOpen | 0:982a9acf3a07 | 33 | Complex* wTable_; // twiddle factor |
MikamiUitOpen | 0:982a9acf3a07 | 34 | uint16_t* bTable_; // for bit reversal |
MikamiUitOpen | 0:982a9acf3a07 | 35 | Complex* u_; // working area |
MikamiUitOpen | 0:982a9acf3a07 | 36 | |
MikamiUitOpen | 0:982a9acf3a07 | 37 | // Processing except for last stage |
MikamiUitOpen | 1:559a63853f3f | 38 | void ExcludeLastStage(); |
MikamiUitOpen | 0:982a9acf3a07 | 39 | // Use for reordering of rit reversal in IFFT |
MikamiUitOpen | 0:982a9acf3a07 | 40 | int Index(int n) { return (N_FFT_-bTable_[n]); } |
MikamiUitOpen | 0:982a9acf3a07 | 41 | |
MikamiUitOpen | 2:9649d0e2bb4a | 42 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 0:982a9acf3a07 | 43 | FftReal(const FftReal& ); |
MikamiUitOpen | 0:982a9acf3a07 | 44 | FftReal& operator=(const FftReal& ); |
MikamiUitOpen | 0:982a9acf3a07 | 45 | }; |
MikamiUitOpen | 0:982a9acf3a07 | 46 | } |
MikamiUitOpen | 0:982a9acf3a07 | 47 | #endif // FFT_REAL_HPP |