![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Real-time spectrum analyzer for ST Nucleo F401RE using Seeed Studio 2.8'' TFT Touch Shield V2.0.
Dependencies: SeeedStudioTFTv2 UITDSP_ADDA UIT_FFT_Real mbed
SpactrumAnalysisClasses/Hamming.hpp@0:c5b026c2d07e, 2015-07-26 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sun Jul 26 02:48:23 2015 +0000
- Revision:
- 0:c5b026c2d07e
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:c5b026c2d07e | 1 | //------------------------------------------------------------------- |
MikamiUitOpen | 0:c5b026c2d07e | 2 | // Hamming windowing with zero-padding |
MikamiUitOpen | 0:c5b026c2d07e | 3 | // Copyright (c) 2014 MIKAMI, Naoki, 2014/12/21 |
MikamiUitOpen | 0:c5b026c2d07e | 4 | //------------------------------------------------------------------- |
MikamiUitOpen | 0:c5b026c2d07e | 5 | |
MikamiUitOpen | 0:c5b026c2d07e | 6 | #ifndef HAMMING_WINDOW_HPP |
MikamiUitOpen | 0:c5b026c2d07e | 7 | #define HAMMING_WINDOW_HPP |
MikamiUitOpen | 0:c5b026c2d07e | 8 | |
MikamiUitOpen | 0:c5b026c2d07e | 9 | #include "mbed.h" |
MikamiUitOpen | 0:c5b026c2d07e | 10 | |
MikamiUitOpen | 0:c5b026c2d07e | 11 | namespace Mikami |
MikamiUitOpen | 0:c5b026c2d07e | 12 | { |
MikamiUitOpen | 0:c5b026c2d07e | 13 | class HammingWindow |
MikamiUitOpen | 0:c5b026c2d07e | 14 | { |
MikamiUitOpen | 0:c5b026c2d07e | 15 | private: |
MikamiUitOpen | 0:c5b026c2d07e | 16 | const int N_; |
MikamiUitOpen | 0:c5b026c2d07e | 17 | const int NFFT_; |
MikamiUitOpen | 0:c5b026c2d07e | 18 | |
MikamiUitOpen | 0:c5b026c2d07e | 19 | float* w_; |
MikamiUitOpen | 0:c5b026c2d07e | 20 | |
MikamiUitOpen | 0:c5b026c2d07e | 21 | public: |
MikamiUitOpen | 0:c5b026c2d07e | 22 | // Constructor |
MikamiUitOpen | 0:c5b026c2d07e | 23 | HammingWindow(uint16_t nData, uint16_t nFft) |
MikamiUitOpen | 0:c5b026c2d07e | 24 | : N_(nData), NFFT_(nFft) |
MikamiUitOpen | 0:c5b026c2d07e | 25 | { |
MikamiUitOpen | 0:c5b026c2d07e | 26 | w_ = new float[nData]; |
MikamiUitOpen | 0:c5b026c2d07e | 27 | float pi2L = 6.283185f/(float)nData; |
MikamiUitOpen | 0:c5b026c2d07e | 28 | for (int k=0; k<nData; k++) |
MikamiUitOpen | 0:c5b026c2d07e | 29 | w_[k] = 0.54f - 0.46f*cosf(k*pi2L); |
MikamiUitOpen | 0:c5b026c2d07e | 30 | } |
MikamiUitOpen | 0:c5b026c2d07e | 31 | |
MikamiUitOpen | 0:c5b026c2d07e | 32 | // Destructor |
MikamiUitOpen | 0:c5b026c2d07e | 33 | ~HammingWindow() {delete[] w_;} |
MikamiUitOpen | 0:c5b026c2d07e | 34 | |
MikamiUitOpen | 0:c5b026c2d07e | 35 | // Windowing |
MikamiUitOpen | 0:c5b026c2d07e | 36 | void Execute(const float x[], float y[]) |
MikamiUitOpen | 0:c5b026c2d07e | 37 | { |
MikamiUitOpen | 0:c5b026c2d07e | 38 | for (int n=0; n<N_; n++) y[n] = x[n]*w_[n]; |
MikamiUitOpen | 0:c5b026c2d07e | 39 | for (int n=N_; n<NFFT_; n++) y[n] = 0; |
MikamiUitOpen | 0:c5b026c2d07e | 40 | } |
MikamiUitOpen | 0:c5b026c2d07e | 41 | }; |
MikamiUitOpen | 0:c5b026c2d07e | 42 | } |
MikamiUitOpen | 0:c5b026c2d07e | 43 | #endif // HAMMING_WINDOW_HPP |
MikamiUitOpen | 0:c5b026c2d07e | 44 |