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 24 11:14:01 2019 +0000
Revision:
7:5ba884060d3b
Parent:
0:a539141b9dec
8

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MikamiUitOpen 0:a539141b9dec 1 //-------------------------------------------------------------------
MikamiUitOpen 0:a539141b9dec 2 // Hamming windowing with zero-padding
MikamiUitOpen 0:a539141b9dec 3 //
MikamiUitOpen 0:a539141b9dec 4 // 2016/07/23, Copyright (c) 2016 MIKAMI, Naoki
MikamiUitOpen 0:a539141b9dec 5 //-------------------------------------------------------------------
MikamiUitOpen 0:a539141b9dec 6
MikamiUitOpen 0:a539141b9dec 7 #ifndef HAMMING_WINDOW_HPP
MikamiUitOpen 0:a539141b9dec 8 #define HAMMING_WINDOW_HPP
MikamiUitOpen 0:a539141b9dec 9
MikamiUitOpen 0:a539141b9dec 10 #include "mbed.h"
MikamiUitOpen 0:a539141b9dec 11 #include "Array.hpp"
MikamiUitOpen 0:a539141b9dec 12
MikamiUitOpen 0:a539141b9dec 13 namespace Mikami
MikamiUitOpen 0:a539141b9dec 14 {
MikamiUitOpen 0:a539141b9dec 15 class HammingWindow
MikamiUitOpen 0:a539141b9dec 16 {
MikamiUitOpen 0:a539141b9dec 17 public:
MikamiUitOpen 0:a539141b9dec 18 // Constructor
MikamiUitOpen 0:a539141b9dec 19 HammingWindow(uint16_t nData, uint16_t nFft)
MikamiUitOpen 0:a539141b9dec 20 : N_(nData), NFFT_(nFft), w_(nData)
MikamiUitOpen 0:a539141b9dec 21 {
MikamiUitOpen 0:a539141b9dec 22 float pi2L = 6.283185f/(float)nData;
MikamiUitOpen 0:a539141b9dec 23 for (int k=0; k<nData; k++)
MikamiUitOpen 0:a539141b9dec 24 w_[k] = 0.54f - 0.46f*cosf(k*pi2L);
MikamiUitOpen 0:a539141b9dec 25 }
MikamiUitOpen 0:a539141b9dec 26
MikamiUitOpen 0:a539141b9dec 27 // Destructor
MikamiUitOpen 0:a539141b9dec 28 virtual ~HammingWindow() {}
MikamiUitOpen 0:a539141b9dec 29
MikamiUitOpen 0:a539141b9dec 30 // Windowing
MikamiUitOpen 0:a539141b9dec 31 void Execute(const float x[], float y[])
MikamiUitOpen 0:a539141b9dec 32 {
MikamiUitOpen 0:a539141b9dec 33 for (int n=0; n<N_; n++) y[n] = x[n]*w_[n];
MikamiUitOpen 0:a539141b9dec 34 for (int n=N_; n<NFFT_; n++) y[n] = 0;
MikamiUitOpen 0:a539141b9dec 35 }
MikamiUitOpen 0:a539141b9dec 36
MikamiUitOpen 0:a539141b9dec 37 private:
MikamiUitOpen 0:a539141b9dec 38 const int N_;
MikamiUitOpen 0:a539141b9dec 39 const int NFFT_;
MikamiUitOpen 0:a539141b9dec 40
MikamiUitOpen 0:a539141b9dec 41 Array<float> w_;
MikamiUitOpen 0:a539141b9dec 42
MikamiUitOpen 0:a539141b9dec 43 // disallow copy constructor and assignment operator
MikamiUitOpen 0:a539141b9dec 44 HammingWindow(const HammingWindow& );
MikamiUitOpen 0:a539141b9dec 45 HammingWindow& operator=(const HammingWindow& );
MikamiUitOpen 0:a539141b9dec 46 };
MikamiUitOpen 0:a539141b9dec 47 }
MikamiUitOpen 0:a539141b9dec 48 #endif // HAMMING_WINDOW_HPP