スペクトログラム このプログラムの説明は,CQ出版社「トランジスタ技術」の2021年10月号から開始された連載記事「STM32マイコンではじめるPC計測」の中にあります.このプログラムといっしょに使うPC側のプログラムについても同誌を参照してください.

Dependencies:   Array_Matrix mbed SerialTxRxIntr DSP_ADDA UIT_FFT_Real Window

Revision:
1:d4e3f39ce206
Parent:
0:3bf11d2ab6ad
--- a/MySpectrogram/FFT_Spectrogram.hpp	Thu Sep 09 08:55:42 2021 +0000
+++ b/MySpectrogram/FFT_Spectrogram.hpp	Wed Dec 08 03:15:17 2021 +0000
@@ -1,11 +1,11 @@
 //-------------------------------------------------------
 //  スペクトログラムで使う FFT 解析用クラス(ヘッダ)
 //
-//  2021/05/24, Copyright (c) 2021 MIKAMI, Naoki
+//  2021/11/17, Copyright (c) 2021 MIKAMI, Naoki
 //-------------------------------------------------------
 
-#ifndef FFT_SPECTROGRAM_HPP
-#define FFT_SPECTROGRAM_HPP
+#ifndef FFT_ANALYZER_HPP
+#define FFT_ANALYZER_HPP
 
 #include "Array.hpp"
 #include "fftReal.hpp"
@@ -16,32 +16,35 @@
     class FftSpectropgram
     {
     public:
-        // nData: 解析で使うデータ数
-        // nFft:  解析で使う FFT の点数
-        FftSpectropgram(int nData, int nFft);
+        // nFft:  FFT のデータ点の数
+        explicit FftSpectropgram(int nFft);
         virtual ~FftSpectropgram() {}
-        void Execute(const Array<float> &xn, Array<float> &db);
-        // 高域強調の程度を決める定数の設定(b1 = 1 で差分,b1 = 0 で高域強調なし)
-        void SetHighEmphasizer(float b1) { b1_ = b1; }
+        void Execute(const Array<float> &xn, Array<float> &absFt);
+
+        // データのコピーを行う際の高域強調の有無切り替え
+        void SwEmphasis(bool on)
+        {   fp = on ? &FftSpectropgram::CopyH : &FftSpectropgram::Copy; }
 
     private:
-        const int N_DATA_;
         const int N_FFT_;
 
         FftReal fft_;
-        HammingWindow wHm_;
-        float b1_;
+        HammingWindow wHm_;     // ハミング窓
 
-        Array<float> xData_;    // 解析で使うデータ
+        Array<float> xData_;    // 解析対象の時系列データ
         Array<float> wData_;    // 窓掛けされたデータ
-        Array<Complex> yFft_;   // FFT の出力
+        Array<Complex> yFft_;   // FFT の結果
 
-        float Norm(Complex x)
-        { return x.real()*x.real() + x.imag()*x.imag(); }
+        // コピーの際に使う関数に対する関数ポインタ
+        void (FftSpectropgram::*fp)(const Array<float> &xn);
+        // データを作業領域にコピー:高域強調は行わない
+        void Copy(const Array<float> &xn) { xData_ = xn; }
+        // データを作業領域にコピー:高域強調は行う
+        void CopyH(const Array<float> &xn);
 
         // コピー・コンストラクタおよび代入演算子の禁止のため
         FftSpectropgram(const FftSpectropgram& );
         FftSpectropgram& operator=(const FftSpectropgram& );
     };
 }
-#endif  // FFT_SPECTROGRAM_HPP
\ No newline at end of file
+#endif  // FFT_ANALYZER_HPP
\ No newline at end of file