Realtime spectrogram for DISCO-F746NG. On-board MEMS microphone is used for input sound signal. リアルタイムスペクトログラム.入力:MEMSマイク
Dependencies: F746_GUI F746_SAI_IO UIT_FFT_Real
Diff: MyClasses_Functions/Hamming.hpp
- Revision:
- 0:9470a174c910
- Child:
- 2:1f092ac020e1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MyClasses_Functions/Hamming.hpp Sun May 22 06:28:40 2016 +0000 @@ -0,0 +1,47 @@ +//------------------------------------------------------------------- +// Hamming windowing with zero-padding +// +// 2015/12/17, Copyright (c) 2015 MIKAMI, Naoki +//------------------------------------------------------------------- + +#ifndef HAMMING_WINDOW_HPP +#define HAMMING_WINDOW_HPP + +#include "mbed.h" + +namespace Mikami +{ + class HammingWindow + { + public: + // Constructor + HammingWindow(uint16_t nData, uint16_t nFft) + : N_(nData), NFFT_(nFft), w_(new float[nData]) + { + float pi2L = 6.283185f/(float)nData; + for (int k=0; k<nData; k++) + w_[k] = 0.54f - 0.46f*cosf(k*pi2L); + } + + // Destructor + ~HammingWindow() {delete[] w_;} + + // Windowing + void Execute(const float x[], float y[]) + { + for (int n=0; n<N_; n++) y[n] = x[n]*w_[n]; + for (int n=N_; n<NFFT_; n++) y[n] = 0; + } + + private: + const int N_; + const int NFFT_; + + float* w_; + + // disallow copy constructor and assignment operator + HammingWindow(const HammingWindow& ); + HammingWindow& operator=(const HammingWindow& ); + }; +} +#endif // HAMMING_WINDOW_HPP