Realtime spectrogram for DISCO-F746NG. On-board MEMS microphone is used for input sound signal. リアルタイムスペクトログラム.入力:MEMSマイク
Dependencies: F746_GUI F746_SAI_IO UIT_FFT_Real
Diff: MySpectrogram/MethodCollection.hpp
- Revision:
- 5:c0877670b0ac
- Parent:
- 3:6a2c8ff46f73
- Child:
- 6:b3885567877c
--- a/MySpectrogram/MethodCollection.hpp Sun Oct 02 10:51:10 2016 +0000 +++ b/MySpectrogram/MethodCollection.hpp Fri Mar 17 02:06:23 2017 +0000 @@ -1,7 +1,7 @@ //-------------------------------------------------------------- // スペクトログラムで使う大域関数 // -// 2016/08/11, Copyright (c) 2016 MIKAMI, Naoki +// 2017/03/17, Copyright (c) 2017 MIKAMI, Naoki //-------------------------------------------------------------- #ifndef METHOD_COLLECTION_HPP @@ -31,45 +31,45 @@ // 座標軸 void DrawAxis(int x0, int y0, int w0, int h0, uint32_t axisColor, - uint16_t ms100, uint16_t px1kHz, LCD_DISCO_F746NG *lcd) + uint16_t ms100, uint16_t px1kHz, LCD_DISCO_F746NG &lcd) { const uint16_t TICK = 5; // 目盛線の長さ // 横標軸 - lcd->SetTextColor(axisColor); - lcd->DrawHLine(x0, y0+TICK, w0); + lcd.SetTextColor(axisColor); + lcd.DrawHLine(x0, y0+TICK, w0); for (int n=0; n<=w0/ms100; n++) - if ((n % 10)== 0) lcd->DrawVLine(x0+n*ms100, y0, 5); - else lcd->DrawVLine(x0+n*ms100, y0+3, 2); + if ((n % 10)== 0) lcd.DrawVLine(x0+n*ms100, y0, 5); + else lcd.DrawVLine(x0+n*ms100, y0+3, 2); for (int n=0; n<=w0/ms100; n+=10) NumericLabel<int> num(x0+n*ms100, y0+TICK+3, "%1d", (int)(n*0.1f), Label::CENTER); Label time(x0+w0/2, y0+22, "TIME [s]", Label::CENTER); // 縦標軸 - lcd->SetTextColor(axisColor); - lcd->DrawVLine(x0-TICK, y0-h0, h0); + lcd.SetTextColor(axisColor); + lcd.DrawVLine(x0-TICK, y0-h0, h0); for (int n=0; n<=h0/px1kHz; n++) - lcd->DrawHLine(x0-TICK, y0-n*px1kHz, TICK); + lcd.DrawHLine(x0-TICK, y0-n*px1kHz, TICK); for (int n=0; n<=h0/px1kHz; n++) NumericLabel<int> num(x0-TICK-12, y0-n*px1kHz-5, "%1d", n); Label hz(x0-32, y0-5*px1kHz-20, "[kHz]"); } // 色と dB の関係の表示 - void ColorDb(int y0, uint32_t axisColor, LCD_DISCO_F746NG *lcd) + void ColorDb(int y0, uint32_t axisColor, LCD_DISCO_F746NG &lcd) { - lcd->SetTextColor(axisColor); - lcd->DrawVLine(455, y0-100, 100); + lcd.SetTextColor(axisColor); + lcd.DrawVLine(455, y0-100, 100); for (int n=0; n<=8; n++) - lcd->DrawHLine(455, y0-(n*100)/8, 4); + lcd.DrawHLine(455, y0-(n*100)/8, 4); for (int n=0; n<=4; n++) NumericLabel<int> num(440, y0-(n*100)/4-5, "%2d", n*20); Label dB(432, y0-120, "[dB]"); for (int n=0; n<=100; n++) { - lcd->SetTextColor(HueScale(n/100.0f)); - lcd->DrawHLine(460, y0-n, 16); + lcd.SetTextColor(HueScale(n/100.0f)); + lcd.DrawHLine(460, y0-n, 16); } } @@ -91,13 +91,13 @@ // スペクトルの表示 void DisplaySpectrum(const Matrix<uint32_t> &x, int x0, int y0, - int hBar, LCD_DISCO_F746NG *lcd) + int hBar, LCD_DISCO_F746NG &lcd) { for (int n=0; n<x.Rows(); n++) for (int k=0; k<x.Cols(); k++) { - lcd->SetTextColor(x[n][k]); - lcd->DrawHLine(x0+n*hBar, y0-k, hBar); + lcd.SetTextColor(x[n][k]); + lcd.DrawHLine(x0+n*hBar, y0-k, hBar); } } }