Realtime sound spectrogram using FFT or linear prediction. Spectrogram is displayed on the display of PC. リアルタイム・スペクトログラム.解析の手法:FFT,線形予測法.スペクトログラムは PC のディスプレー装置に表示される.PC 側のプログラム:F446_Spectrogram.

Dependencies:   Array_Matrix mbed SerialTxRxIntr F446_AD_DA UIT_FFT_Real

Committer:
MikamiUitOpen
Date:
Sun Nov 04 10:41:02 2018 +0000
Revision:
6:c38ec7939609
Parent:
0:a539141b9dec
7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:a539141b9dec 1 //-------------------------------------------------------
MikamiUitOpen 0:a539141b9dec 2 // Base abstract class for spectrum analysis (Header)
MikamiUitOpen 0:a539141b9dec 3 //
MikamiUitOpen 6:c38ec7939609 4 // 2018/11/04, Copyright (c) 2018 MIKAMI, Naoki
MikamiUitOpen 0:a539141b9dec 5 //-------------------------------------------------------
MikamiUitOpen 0:a539141b9dec 6
MikamiUitOpen 0:a539141b9dec 7 #ifndef BASE_ANALYZER_HPP
MikamiUitOpen 0:a539141b9dec 8 #define BASE_ANALYZER_HPP
MikamiUitOpen 0:a539141b9dec 9
MikamiUitOpen 0:a539141b9dec 10 #include "Array.hpp"
MikamiUitOpen 0:a539141b9dec 11 #include "fftReal.hpp"
MikamiUitOpen 0:a539141b9dec 12 #include "Hamming.hpp"
MikamiUitOpen 0:a539141b9dec 13
MikamiUitOpen 0:a539141b9dec 14 namespace Mikami
MikamiUitOpen 0:a539141b9dec 15 {
MikamiUitOpen 0:a539141b9dec 16 class AnalyzerBase
MikamiUitOpen 0:a539141b9dec 17 {
MikamiUitOpen 0:a539141b9dec 18 public:
MikamiUitOpen 0:a539141b9dec 19 // nData: Number of data to be analyzed
MikamiUitOpen 0:a539141b9dec 20 // nFft: Number of FFT points
MikamiUitOpen 0:a539141b9dec 21 // nUse: FFT, cepstrum: window width + zero padding
MikamiUitOpen 0:a539141b9dec 22 // Linear prediction: window width
MikamiUitOpen 0:a539141b9dec 23 AnalyzerBase(int nData, int nFft, int nUse);
MikamiUitOpen 0:a539141b9dec 24 virtual ~AnalyzerBase() {}
MikamiUitOpen 0:a539141b9dec 25 void Execute(const float xn[], float db[]);
MikamiUitOpen 0:a539141b9dec 26 // 高域強調の程度を決める定数の設定(b1 = 1 で差分,b1 = 0 で高域強調なし)
MikamiUitOpen 0:a539141b9dec 27 void SetHighEmphasizer(float b1) { b1_ = b1; }
MikamiUitOpen 0:a539141b9dec 28
MikamiUitOpen 0:a539141b9dec 29 protected:
MikamiUitOpen 0:a539141b9dec 30 const int N_DATA_;
MikamiUitOpen 0:a539141b9dec 31 const int N_FFT_;
MikamiUitOpen 0:a539141b9dec 32
MikamiUitOpen 0:a539141b9dec 33 FftReal fft_;
MikamiUitOpen 0:a539141b9dec 34
MikamiUitOpen 0:a539141b9dec 35 float Norm(Complex x)
MikamiUitOpen 0:a539141b9dec 36 { return x.real()*x.real() + x.imag()*x.imag(); }
MikamiUitOpen 0:a539141b9dec 37
MikamiUitOpen 0:a539141b9dec 38 private:
MikamiUitOpen 0:a539141b9dec 39 HammingWindow wHm_;
MikamiUitOpen 0:a539141b9dec 40 float b1_;
MikamiUitOpen 0:a539141b9dec 41
MikamiUitOpen 0:a539141b9dec 42 Array<float> xData_; // data to be analyzed
MikamiUitOpen 0:a539141b9dec 43 Array<float> wData_; // windowd data
MikamiUitOpen 0:a539141b9dec 44
MikamiUitOpen 0:a539141b9dec 45 virtual void Analyze(const float wData[], float db[]) = 0;
MikamiUitOpen 0:a539141b9dec 46
MikamiUitOpen 0:a539141b9dec 47 // disallow copy constructor and assignment operator
MikamiUitOpen 0:a539141b9dec 48 AnalyzerBase(const AnalyzerBase& );
MikamiUitOpen 0:a539141b9dec 49 AnalyzerBase& operator=(const AnalyzerBase& );
MikamiUitOpen 0:a539141b9dec 50 };
MikamiUitOpen 0:a539141b9dec 51 }
MikamiUitOpen 0:a539141b9dec 52 #endif // BASE_ANALYZER_HPP