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

Dependencies:   Array_Matrix mbed SerialTxRxIntr DSP_ADDA UIT_FFT_Real Window

Revision:
0:3bf11d2ab6ad
Child:
1:d4e3f39ce206
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MySpectrogram/FFT_Spectrogram.hpp	Thu Sep 09 08:55:42 2021 +0000
@@ -0,0 +1,47 @@
+//-------------------------------------------------------
+//  スペクトログラムで使う FFT 解析用クラス(ヘッダ)
+//
+//  2021/05/24, Copyright (c) 2021 MIKAMI, Naoki
+//-------------------------------------------------------
+
+#ifndef FFT_SPECTROGRAM_HPP
+#define FFT_SPECTROGRAM_HPP
+
+#include "Array.hpp"
+#include "fftReal.hpp"
+#include "Hamming.hpp"
+
+namespace Mikami
+{
+    class FftSpectropgram
+    {
+    public:
+        // nData: 解析で使うデータ数
+        // nFft:  解析で使う FFT の点数
+        FftSpectropgram(int nData, int nFft);
+        virtual ~FftSpectropgram() {}
+        void Execute(const Array<float> &xn, Array<float> &db);
+        // 高域強調の程度を決める定数の設定(b1 = 1 で差分,b1 = 0 で高域強調なし)
+        void SetHighEmphasizer(float b1) { b1_ = b1; }
+
+    private:
+        const int N_DATA_;
+        const int N_FFT_;
+
+        FftReal fft_;
+        HammingWindow wHm_;
+        float b1_;
+
+        Array<float> xData_;    // 解析で使うデータ
+        Array<float> wData_;    // 窓掛けされたデータ
+        Array<Complex> yFft_;   // FFT の出力
+
+        float Norm(Complex x)
+        { return x.real()*x.real() + x.imag()*x.imag(); }
+
+        // コピー・コンストラクタおよび代入演算子の禁止のため
+        FftSpectropgram(const FftSpectropgram& );
+        FftSpectropgram& operator=(const FftSpectropgram& );
+    };
+}
+#endif  // FFT_SPECTROGRAM_HPP
\ No newline at end of file