![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Realtime spectrum analyzer. Using FFT, linear prediction, or cepstrum smoothing. Version using MEMS microphone and CODEC, named "F746_RealtimeSpectrumAnalyzer_MEMS_Mic" is registered. リアルタイム スペクトル解析器.解析の手法:FFT,線形予測法,ケプストラムによる平滑化の3種類.このプログラムの説明は,CQ出版社のインターフェース誌,2016年4月号に掲載.外付けのマイクまたは他の信号源等を A0 に接続する.線形予測法,ケプストラムは,スペクトル解析の対象を音声信号に想定してパラメータを設定している.MEMS マイクと CODEC を使ったバージョンを "F746_RealtimeSpectrumAnalyzer_MEMS_Mic" として登録.
Dependencies: BSP_DISCO_F746NG BUTTON_GROUP LCD_DISCO_F746NG TS_DISCO_F746NG UIT_FFT_Real mbed
MyClasses/Hamming.hpp@18:6630d61aeb3c, 2016-02-22 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Mon Feb 22 13:54:51 2016 +0000
- Revision:
- 18:6630d61aeb3c
- Parent:
- 6:b27ef8d98edc
19
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:5c237fdcba23 | 1 | //------------------------------------------------------------------- |
MikamiUitOpen | 0:5c237fdcba23 | 2 | // Hamming windowing with zero-padding |
MikamiUitOpen | 0:5c237fdcba23 | 3 | // |
MikamiUitOpen | 6:b27ef8d98edc | 4 | // 2015/12/17, Copyright (c) 2015 MIKAMI, Naoki |
MikamiUitOpen | 0:5c237fdcba23 | 5 | //------------------------------------------------------------------- |
MikamiUitOpen | 0:5c237fdcba23 | 6 | |
MikamiUitOpen | 0:5c237fdcba23 | 7 | #ifndef HAMMING_WINDOW_HPP |
MikamiUitOpen | 0:5c237fdcba23 | 8 | #define HAMMING_WINDOW_HPP |
MikamiUitOpen | 0:5c237fdcba23 | 9 | |
MikamiUitOpen | 0:5c237fdcba23 | 10 | #include "mbed.h" |
MikamiUitOpen | 0:5c237fdcba23 | 11 | |
MikamiUitOpen | 0:5c237fdcba23 | 12 | namespace Mikami |
MikamiUitOpen | 0:5c237fdcba23 | 13 | { |
MikamiUitOpen | 0:5c237fdcba23 | 14 | class HammingWindow |
MikamiUitOpen | 0:5c237fdcba23 | 15 | { |
MikamiUitOpen | 0:5c237fdcba23 | 16 | public: |
MikamiUitOpen | 0:5c237fdcba23 | 17 | // Constructor |
MikamiUitOpen | 0:5c237fdcba23 | 18 | HammingWindow(uint16_t nData, uint16_t nFft) |
MikamiUitOpen | 0:5c237fdcba23 | 19 | : N_(nData), NFFT_(nFft), w_(new float[nData]) |
MikamiUitOpen | 0:5c237fdcba23 | 20 | { |
MikamiUitOpen | 0:5c237fdcba23 | 21 | float pi2L = 6.283185f/(float)nData; |
MikamiUitOpen | 0:5c237fdcba23 | 22 | for (int k=0; k<nData; k++) |
MikamiUitOpen | 0:5c237fdcba23 | 23 | w_[k] = 0.54f - 0.46f*cosf(k*pi2L); |
MikamiUitOpen | 0:5c237fdcba23 | 24 | } |
MikamiUitOpen | 0:5c237fdcba23 | 25 | |
MikamiUitOpen | 0:5c237fdcba23 | 26 | // Destructor |
MikamiUitOpen | 0:5c237fdcba23 | 27 | ~HammingWindow() {delete[] w_;} |
MikamiUitOpen | 0:5c237fdcba23 | 28 | |
MikamiUitOpen | 0:5c237fdcba23 | 29 | // Windowing |
MikamiUitOpen | 0:5c237fdcba23 | 30 | void Execute(const float x[], float y[]) |
MikamiUitOpen | 0:5c237fdcba23 | 31 | { |
MikamiUitOpen | 0:5c237fdcba23 | 32 | for (int n=0; n<N_; n++) y[n] = x[n]*w_[n]; |
MikamiUitOpen | 0:5c237fdcba23 | 33 | for (int n=N_; n<NFFT_; n++) y[n] = 0; |
MikamiUitOpen | 0:5c237fdcba23 | 34 | } |
MikamiUitOpen | 6:b27ef8d98edc | 35 | |
MikamiUitOpen | 6:b27ef8d98edc | 36 | private: |
MikamiUitOpen | 6:b27ef8d98edc | 37 | const int N_; |
MikamiUitOpen | 6:b27ef8d98edc | 38 | const int NFFT_; |
MikamiUitOpen | 6:b27ef8d98edc | 39 | |
MikamiUitOpen | 6:b27ef8d98edc | 40 | float* w_; |
MikamiUitOpen | 6:b27ef8d98edc | 41 | |
MikamiUitOpen | 6:b27ef8d98edc | 42 | // disallow copy constructor and assignment operator |
MikamiUitOpen | 6:b27ef8d98edc | 43 | HammingWindow(const HammingWindow& ); |
MikamiUitOpen | 6:b27ef8d98edc | 44 | HammingWindow& operator=(const HammingWindow& ); |
MikamiUitOpen | 0:5c237fdcba23 | 45 | }; |
MikamiUitOpen | 0:5c237fdcba23 | 46 | } |
MikamiUitOpen | 0:5c237fdcba23 | 47 | #endif // HAMMING_WINDOW_HPP |