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

Files at this revision

API Documentation at this revision

Comitter:
MikamiUitOpen
Date:
Sat Dec 12 03:20:09 2020 +0000
Parent:
3:dc123081d491
Commit message:
5

Changed in this revision

fftReal.cpp Show annotated file Show diff for this revision Revisions of this file
fftReal.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/fftReal.cpp	Mon Jan 13 08:54:18 2020 +0000
+++ b/fftReal.cpp	Sat Dec 12 03:20:09 2020 +0000
@@ -3,7 +3,7 @@
 //      FFT     複素共役になる部分は計算しない
 //      IFFT    複素共役の部分を除いた値から計算する
 //
-//  2020/01/13, Copyright (c) 2020 MIKAMI, Naoki
+//  2020/12/12, Copyright (c) 2020 MIKAMI, Naoki
 //------------------------------------------------------------------------------
 
 #include "fftReal.hpp"
@@ -15,9 +15,8 @@
             : N_FFT_(n), N_INV_(1.0f/n), wTable_(n/2), bTable_(n), u_(n)
     {
         // __clz(): リーディング 0 の数を取得する命令に対応
-        uint32_t shifted = n << (__clz(n)+1);
-
-        MBED_ASSERT(shifted == 0);
+        uint32_t shifted = n << (__clz(n) + 1);
+        MBED_ASSERT(shifted == 0);  // n が 2 のべき乗であることをチェック
 
         // 回転子の表を作成
         Complex arg = Complex(0, -6.283185f/N_FFT_);
@@ -52,7 +51,7 @@
 
     // IFFT の実行
     //      このクラスで計算された FFT の結果の IFFT を計算する
-    //      実行結果    x[0] ~ x[N_FFT_]
+    //      実行結果    x[0] ~ x[N_FFT_-1]
     void FftReal::ExecuteIfft(const Complex y[], float x[])
     {
         int half = N_FFT_/2;
@@ -89,7 +88,7 @@
                 uint16_t kx = 0;
                 for (int k=kp; k<kp+nHalf; k++)
                 {
-                    // Butterfly operation
+                    // バタフライ演算
                     Complex uTmp = u_[k+nHalf];
                     u_[k+nHalf] = (u_[k] - uTmp)*wTable_[kx];
                     u_[k] = u_[k] + uTmp;
@@ -97,6 +96,6 @@
                 }
             }
             nHalf = nHalf/2;
-        }        
+        }
     }
-}
\ No newline at end of file
+}
--- a/fftReal.hpp	Mon Jan 13 08:54:18 2020 +0000
+++ b/fftReal.hpp	Sat Dec 12 03:20:09 2020 +0000
@@ -1,19 +1,18 @@
 //-------------------------------------------------------------------
 //  データが実数の場合の FFT class(ヘッダ)
 //
-//  2020/01/13, Copyright (c) 2020 MIKAMI, Naoki
+//  2020/12/12, Copyright (c) 2020 MIKAMI, Naoki
 //-------------------------------------------------------------------
 
 #ifndef FFT_REAL_HPP
 #define FFT_REAL_HPP
 
-#include "mbed.h"
+#include "Array.hpp"    // "Array_Matrix" という名前で Mbed に登録
 #include <complex>      // complex で使用
-#include "Array.hpp"    // "Array_Matrix" という名前で Mbed に登録
 
 namespace Mikami
 {
-    typedef complex<float> Complex; // define "Complex"
+    typedef complex<float> Complex; // "Complex" の定義
 
     class FftReal
     {
@@ -34,12 +33,12 @@
 
         // 最終ステージを除いた処理
         void ExcludeLastStage();
-        // IFFT の美と逆順の並べ替えで使用
-        int Index(int n) { return (N_FFT_-bTable_[n]); }
+        // IFFT のビット逆順の並べ替えで使用
+        int Index(int n) const { return (N_FFT_-bTable_[n]); }
 
         // コピー・コンストラクタおよび代入演算子の禁止のため
         FftReal(const FftReal& );
         FftReal& operator=(const FftReal& );
     };
 }
-#endif  // FFT_REAL_HPP
\ No newline at end of file
+#endif  // FFT_REAL_HPP