![](/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/SpectrumDisplay.hpp@0:5c237fdcba23, 2015-12-09 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Wed Dec 09 05:05:00 2015 +0000
- Revision:
- 0:5c237fdcba23
- Child:
- 4:99d4d5ea06a2
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 display spectrum (Header) |
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 SPECTRUM_DISPLAY_HPP |
MikamiUitOpen | 0:5c237fdcba23 | 8 | #define SPECTRUM_DISPLAY_HPP |
MikamiUitOpen | 0:5c237fdcba23 | 9 | |
MikamiUitOpen | 0:5c237fdcba23 | 10 | #include "LCD_DISCO_F746NG.h" |
MikamiUitOpen | 0:5c237fdcba23 | 11 | |
MikamiUitOpen | 0:5c237fdcba23 | 12 | namespace Mikami |
MikamiUitOpen | 0:5c237fdcba23 | 13 | { |
MikamiUitOpen | 0:5c237fdcba23 | 14 | class SpectrumDisplay |
MikamiUitOpen | 0:5c237fdcba23 | 15 | { |
MikamiUitOpen | 0:5c237fdcba23 | 16 | public: |
MikamiUitOpen | 0:5c237fdcba23 | 17 | SpectrumDisplay(LCD_DISCO_F746NG &lcd, |
MikamiUitOpen | 0:5c237fdcba23 | 18 | int nFft, int x0, int y0, |
MikamiUitOpen | 0:5c237fdcba23 | 19 | float db1, int bin, float maxDb, int fs, |
MikamiUitOpen | 0:5c237fdcba23 | 20 | uint32_t axisColor, uint32_t lineColor, |
MikamiUitOpen | 0:5c237fdcba23 | 21 | uint32_t backColor); |
MikamiUitOpen | 0:5c237fdcba23 | 22 | void Draw(float db[]); |
MikamiUitOpen | 0:5c237fdcba23 | 23 | void Clear(); |
MikamiUitOpen | 0:5c237fdcba23 | 24 | |
MikamiUitOpen | 0:5c237fdcba23 | 25 | private: |
MikamiUitOpen | 0:5c237fdcba23 | 26 | |
MikamiUitOpen | 0:5c237fdcba23 | 27 | const int N_FFT_; // number of date for FFT |
MikamiUitOpen | 0:5c237fdcba23 | 28 | const int X0_; // Origin for x axis |
MikamiUitOpen | 0:5c237fdcba23 | 29 | const int Y0_; // Origin for y axis |
MikamiUitOpen | 0:5c237fdcba23 | 30 | const float DB1_; // Pixels for 1 dB |
MikamiUitOpen | 0:5c237fdcba23 | 31 | const int BIN_; // Pixels per bin |
MikamiUitOpen | 0:5c237fdcba23 | 32 | const float MAX_DB_; // Maximum dB |
MikamiUitOpen | 0:5c237fdcba23 | 33 | const int FS_; // Sampling frequency: 10 kHz |
MikamiUitOpen | 0:5c237fdcba23 | 34 | const uint32_t AXIS_COLOR_; |
MikamiUitOpen | 0:5c237fdcba23 | 35 | const uint32_t LINE_COLOR_; |
MikamiUitOpen | 0:5c237fdcba23 | 36 | const uint32_t BACK_COLOR_; |
MikamiUitOpen | 0:5c237fdcba23 | 37 | |
MikamiUitOpen | 0:5c237fdcba23 | 38 | LCD_DISCO_F746NG& lcd_; |
MikamiUitOpen | 0:5c237fdcba23 | 39 | |
MikamiUitOpen | 0:5c237fdcba23 | 40 | void AxisX(); // x-axis |
MikamiUitOpen | 0:5c237fdcba23 | 41 | void AxisY(); // y-axis |
MikamiUitOpen | 0:5c237fdcba23 | 42 | |
MikamiUitOpen | 0:5c237fdcba23 | 43 | void DrawString(uint16_t x, uint16_t y, char str[]) |
MikamiUitOpen | 0:5c237fdcba23 | 44 | { lcd_.DisplayStringAt(x, y, (uint8_t *)str, LEFT_MODE); } |
MikamiUitOpen | 0:5c237fdcba23 | 45 | }; |
MikamiUitOpen | 0:5c237fdcba23 | 46 | } |
MikamiUitOpen | 0:5c237fdcba23 | 47 | #endif // SPECTRUM_DISPLAY_HPP |