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:
- 6:b3885567877c
- Parent:
- 5:c0877670b0ac
diff -r c0877670b0ac -r b3885567877c MySpectrogram/MethodCollection.hpp --- a/MySpectrogram/MethodCollection.hpp Fri Mar 17 02:06:23 2017 +0000 +++ b/MySpectrogram/MethodCollection.hpp Mon Apr 10 13:43:07 2017 +0000 @@ -1,7 +1,7 @@ //-------------------------------------------------------------- -// スペクトログラムで使う大域関数 +// スペクトログラムで使うグローバル関数 // -// 2017/03/17, Copyright (c) 2017 MIKAMI, Naoki +// 2017/04/10, Copyright (c) 2017 MIKAMI, Naoki //-------------------------------------------------------------- #ifndef METHOD_COLLECTION_HPP @@ -14,11 +14,11 @@ namespace Mikami { - // 色相の違いで表示 + // 強度を色相の違いに変換 // 0.0 <= x <= 1.0 uint32_t HueScale(float x) { - if (x >= 1) return LCD_COLOR_WHITE; + if (x > 1) return LCD_COLOR_WHITE; int r = 0; int b = 0; @@ -34,8 +34,9 @@ uint16_t ms100, uint16_t px1kHz, LCD_DISCO_F746NG &lcd) { const uint16_t TICK = 5; // 目盛線の長さ + lcd.SetTextColor(axisColor); + // 横標軸 - 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); @@ -44,9 +45,8 @@ 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); for (int n=0; n<=h0/px1kHz; n++) lcd.DrawHLine(x0-TICK, y0-n*px1kHz, TICK); @@ -66,7 +66,7 @@ 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++) + for (int n=0; n<=101; n++) { lcd.SetTextColor(HueScale(n/100.0f)); lcd.DrawHLine(460, y0-n, 16);