![](/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/waveform_display.hpp@0:5c237fdcba23, 2015-12-09 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Wed Dec 09 05:05:00 2015 +0000
- Revision:
- 0:5c237fdcba23
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 0:5c237fdcba23 | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 0:5c237fdcba23 | 2 | // Class for waveform display |
MikamiUitOpen | 0:5c237fdcba23 | 3 | // |
MikamiUitOpen | 0:5c237fdcba23 | 4 | // 2015/12/07, Copyright (c) 2015 MIKAMI, Naoki |
MikamiUitOpen | 0:5c237fdcba23 | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 0:5c237fdcba23 | 6 | |
MikamiUitOpen | 0:5c237fdcba23 | 7 | #ifndef F746_WAVEFORM_DISPLAY_HPP |
MikamiUitOpen | 0:5c237fdcba23 | 8 | #define F746_WAVEFORM_DISPLAY_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 WaveformDisplay |
MikamiUitOpen | 0:5c237fdcba23 | 15 | { |
MikamiUitOpen | 0:5c237fdcba23 | 16 | public: |
MikamiUitOpen | 0:5c237fdcba23 | 17 | WaveformDisplay(LCD_DISCO_F746NG &lcd, |
MikamiUitOpen | 0:5c237fdcba23 | 18 | uint16_t x0, uint16_t y0, int nData, |
MikamiUitOpen | 0:5c237fdcba23 | 19 | uint16_t rShift, |
MikamiUitOpen | 0:5c237fdcba23 | 20 | uint32_t axisColor, uint32_t lineColor, |
MikamiUitOpen | 0:5c237fdcba23 | 21 | uint32_t backColor) |
MikamiUitOpen | 0:5c237fdcba23 | 22 | : X0_(x0), Y0_(y0), N_DATA_(nData), R_SHIFT_(rShift), |
MikamiUitOpen | 0:5c237fdcba23 | 23 | AXIS_COLOR_(axisColor), LINE_COLOR_(lineColor), |
MikamiUitOpen | 0:5c237fdcba23 | 24 | BACK_COLOR_(backColor), lcd_(lcd) { Axis(); } |
MikamiUitOpen | 0:5c237fdcba23 | 25 | |
MikamiUitOpen | 0:5c237fdcba23 | 26 | void Execute(const int16_t xn[]) |
MikamiUitOpen | 0:5c237fdcba23 | 27 | { |
MikamiUitOpen | 0:5c237fdcba23 | 28 | Axis(); |
MikamiUitOpen | 0:5c237fdcba23 | 29 | lcd_.SetTextColor(LINE_COLOR_); |
MikamiUitOpen | 0:5c237fdcba23 | 30 | uint16_t x1 = X0_; |
MikamiUitOpen | 0:5c237fdcba23 | 31 | uint16_t y1 = Y0_ - (xn[0] >> R_SHIFT_); |
MikamiUitOpen | 0:5c237fdcba23 | 32 | for (int n=1; n<N_DATA_; n++) |
MikamiUitOpen | 0:5c237fdcba23 | 33 | { |
MikamiUitOpen | 0:5c237fdcba23 | 34 | uint16_t x2 = X0_ + n; |
MikamiUitOpen | 0:5c237fdcba23 | 35 | uint16_t y2 = Y0_ - (xn[n] >> R_SHIFT_); |
MikamiUitOpen | 0:5c237fdcba23 | 36 | lcd_.DrawLine(x1, y1, x2, y2); |
MikamiUitOpen | 0:5c237fdcba23 | 37 | x1 = x2; |
MikamiUitOpen | 0:5c237fdcba23 | 38 | y1 = y2; |
MikamiUitOpen | 0:5c237fdcba23 | 39 | } |
MikamiUitOpen | 0:5c237fdcba23 | 40 | } |
MikamiUitOpen | 0:5c237fdcba23 | 41 | |
MikamiUitOpen | 0:5c237fdcba23 | 42 | private: |
MikamiUitOpen | 0:5c237fdcba23 | 43 | const uint16_t X0_; |
MikamiUitOpen | 0:5c237fdcba23 | 44 | const uint16_t Y0_; |
MikamiUitOpen | 0:5c237fdcba23 | 45 | const int N_DATA_; |
MikamiUitOpen | 0:5c237fdcba23 | 46 | const uint16_t R_SHIFT_; |
MikamiUitOpen | 0:5c237fdcba23 | 47 | const uint32_t AXIS_COLOR_; |
MikamiUitOpen | 0:5c237fdcba23 | 48 | const uint32_t LINE_COLOR_; |
MikamiUitOpen | 0:5c237fdcba23 | 49 | const uint32_t BACK_COLOR_; |
MikamiUitOpen | 0:5c237fdcba23 | 50 | |
MikamiUitOpen | 0:5c237fdcba23 | 51 | LCD_DISCO_F746NG& lcd_; |
MikamiUitOpen | 0:5c237fdcba23 | 52 | |
MikamiUitOpen | 0:5c237fdcba23 | 53 | void Axis() |
MikamiUitOpen | 0:5c237fdcba23 | 54 | { |
MikamiUitOpen | 0:5c237fdcba23 | 55 | lcd_.SetTextColor(BACK_COLOR_); |
MikamiUitOpen | 0:5c237fdcba23 | 56 | lcd_.FillRect(X0_, Y0_-36, N_DATA_, 72); |
MikamiUitOpen | 0:5c237fdcba23 | 57 | |
MikamiUitOpen | 0:5c237fdcba23 | 58 | lcd_.SetTextColor(AXIS_COLOR_); |
MikamiUitOpen | 0:5c237fdcba23 | 59 | lcd_.DrawLine(X0_-5, Y0_, X0_+N_DATA_+5, Y0_); |
MikamiUitOpen | 0:5c237fdcba23 | 60 | } |
MikamiUitOpen | 0:5c237fdcba23 | 61 | }; |
MikamiUitOpen | 0:5c237fdcba23 | 62 | } |
MikamiUitOpen | 0:5c237fdcba23 | 63 | #endif // F746_WAVEFORM_DISPLAY_HPP |