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
Diff: main.cpp
- Revision:
- 15:a490686fce1e
- Parent:
- 14:cd4534fb34e7
- Child:
- 17:b74b1d99a8c1
diff -r cd4534fb34e7 -r a490686fce1e main.cpp --- a/main.cpp Fri Jan 01 05:32:58 2016 +0000 +++ b/main.cpp Sat Jan 02 13:32:35 2016 +0000 @@ -2,7 +2,7 @@ // Realtime spectrum analyzer // Input: A0 (CN5) // -// 2016/01/01, Copyright (c) 2016 MIKAMI, Naoki +// 2016/01/02, Copyright (c) 2016 MIKAMI, Naoki //------------------------------------------------ #include "button_group.hpp" @@ -13,8 +13,10 @@ int main() { + const int FS = 10000; // Sampling frequency: 10 kHz const int N_DATA = 260; // Number of data to be analyzed const int N_FFT = 512; // Number of date for FFT + const int X_WAV = 44; // Origin for x axis of waveform const int Y_WAV = 36; // Origin for y axis of waveform const int X0 = 40; // Origin for x axis of spectrum @@ -24,8 +26,6 @@ const int W_DB = 60; // Range in dB to be displayed const int X0_BTN = 340; // Holizontal position for left of buttons - const int FS = 10000; // Sampling frequency: 10 kHz - const uint32_t BACK_COLOR = 0xFF006A6C; // Teal green const uint32_t INACTIVE_COLOR = BACK_COLOR & 0xD0FFFFFF; const uint32_t TOUCHED_COLOR = 0xFF7F7FFF; @@ -77,18 +77,22 @@ method.DrawAll(ORIGINAL_COLOR); int inv = 0; // 0: "NORM", 1: "INV" int select = -1; - int stop = 0; while (true) { if (runStop.Touched(0)) + { input.Start(inv == 1); + normInv.Draw(inv, TOUCHED_COLOR); + normInv.Redraw(1-inv); + } + + int stop; runStop.GetTouchedNumber(stop, TOUCHED_COLOR); if (stop == 0) { normInv.GetTouchedNumber(inv, TOUCHED_COLOR); - normInv.Draw(inv, TOUCHED_COLOR); - normInv.Redraw(1-inv); + if (input.Filled()) { // Restart @@ -105,9 +109,11 @@ } else { - input.Stop(); // Stop timer interrupt if (runStop.Touched(1)) + { + input.Stop(); // Stop timer interrupt normInv.DrawAll(INACTIVE_COLOR, INACTIVE_TEXT_COLOR); + } if (method.GetTouchedNumber(select, TOUCHED_COLOR)) analyzer.Execute(sn, select); }