![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Output the audio signal (*.bin) with filtering by IIR filter in the SD card using onboard CODEC. For *.wav file, F746_SD_WavPlayer and F746_SD_GraphicEqualiser are published on mbed. SD カードのオーディオ信号 (*.bin) を遮断周波数可変の IIR フィルタを通して,ボードに搭載されているCODEC で出力する.*.wav 形式のファイル用には,F746_SD_WavPlayer と F746_SD_GraphicEqualiser を mbed で公開している.
Dependencies: BSP_DISCO_F746NG_patch_fixed F746_GUI LCD_DISCO_F746NG SDFileSystem_Warning_Fixed TS_DISCO_F746NG mbed
MyClasses_Functions/FrquencyResponseDrawer.cpp@4:76aa20fb326a, 2016-04-16 (annotated)
- Committer:
- MikamiUitOpen
- Date:
- Sat Apr 16 13:53:53 2016 +0000
- Revision:
- 4:76aa20fb326a
- Child:
- 5:4a99dabc9180
4
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
MikamiUitOpen | 4:76aa20fb326a | 1 | //----------------------------------------------------------- |
MikamiUitOpen | 4:76aa20fb326a | 2 | // FrqRespDrawer class |
MikamiUitOpen | 4:76aa20fb326a | 3 | // |
MikamiUitOpen | 4:76aa20fb326a | 4 | // 2016/04/16, Copyright (c) 2016 MIKAMI, Naoki |
MikamiUitOpen | 4:76aa20fb326a | 5 | //----------------------------------------------------------- |
MikamiUitOpen | 4:76aa20fb326a | 6 | |
MikamiUitOpen | 4:76aa20fb326a | 7 | #include "FrquencyResponseDrawer.hpp" |
MikamiUitOpen | 4:76aa20fb326a | 8 | #include "NumericLabel.hpp" |
MikamiUitOpen | 4:76aa20fb326a | 9 | |
MikamiUitOpen | 4:76aa20fb326a | 10 | namespace Mikami |
MikamiUitOpen | 4:76aa20fb326a | 11 | { |
MikamiUitOpen | 4:76aa20fb326a | 12 | // 目盛線の描画 |
MikamiUitOpen | 4:76aa20fb326a | 13 | void FrqRespDrawer::DrawAxis() |
MikamiUitOpen | 4:76aa20fb326a | 14 | { |
MikamiUitOpen | 4:76aa20fb326a | 15 | uint16_t height = DB1_*(MAX_DB_ - MIN_DB_); |
MikamiUitOpen | 4:76aa20fb326a | 16 | int logMin = (int)floorf(log10f(MIN_)); |
MikamiUitOpen | 4:76aa20fb326a | 17 | int loop = (int)floorf(log10f(MAX_)) - logMin; |
MikamiUitOpen | 4:76aa20fb326a | 18 | |
MikamiUitOpen | 4:76aa20fb326a | 19 | lcd_->SetTextColor(AXIS_COLOR_); |
MikamiUitOpen | 4:76aa20fb326a | 20 | uint16_t y0 = ORGY_ - height; |
MikamiUitOpen | 4:76aa20fb326a | 21 | lcd_->DrawVLine(X(MIN_), y0, height); // 最小値に対応する線 |
MikamiUitOpen | 4:76aa20fb326a | 22 | |
MikamiUitOpen | 4:76aa20fb326a | 23 | float du = powf(10.0, logMin); // 座標値の増分 |
MikamiUitOpen | 4:76aa20fb326a | 24 | float u1 = (floorf(MIN_/du) + 1.0f)*du; // 最小値に対応する線の次の座標値 |
MikamiUitOpen | 4:76aa20fb326a | 25 | |
MikamiUitOpen | 4:76aa20fb326a | 26 | for (int n=0; n<=loop; n++) |
MikamiUitOpen | 4:76aa20fb326a | 27 | { |
MikamiUitOpen | 4:76aa20fb326a | 28 | float uMax = (10.0f*du < MAX_) ? 10.0f*du : MAX_; |
MikamiUitOpen | 4:76aa20fb326a | 29 | for (float u=u1; u<uMax*0.99f; u+=du) |
MikamiUitOpen | 4:76aa20fb326a | 30 | lcd_->DrawVLine(X(u), y0, height); |
MikamiUitOpen | 4:76aa20fb326a | 31 | |
MikamiUitOpen | 4:76aa20fb326a | 32 | du = uMax; // 値の増分を 10 倍する |
MikamiUitOpen | 4:76aa20fb326a | 33 | u1 = du; // 次の for ループ の最初の値 |
MikamiUitOpen | 4:76aa20fb326a | 34 | } |
MikamiUitOpen | 4:76aa20fb326a | 35 | |
MikamiUitOpen | 4:76aa20fb326a | 36 | lcd_->DrawVLine(X(MAX_), y0, height); // 最大値に対応する線 |
MikamiUitOpen | 4:76aa20fb326a | 37 | |
MikamiUitOpen | 4:76aa20fb326a | 38 | uint16_t width = X(MAX_) - X(MIN_); |
MikamiUitOpen | 4:76aa20fb326a | 39 | for (int n=0; n<= (MAX_DB_ - MIN_DB_)/10; n++) |
MikamiUitOpen | 4:76aa20fb326a | 40 | lcd_->DrawHLine(X(MIN_), ORGY_-DB10_*n, width); |
MikamiUitOpen | 4:76aa20fb326a | 41 | } |
MikamiUitOpen | 4:76aa20fb326a | 42 | |
MikamiUitOpen | 4:76aa20fb326a | 43 | // 縦軸の数値の表示 |
MikamiUitOpen | 4:76aa20fb326a | 44 | void FrqRespDrawer::DrawNumericY(int offsetX, int offsetY, int count, |
MikamiUitOpen | 4:76aa20fb326a | 45 | uint16_t d_dB, const char fmt[], sFONT &fonts, |
MikamiUitOpen | 4:76aa20fb326a | 46 | uint32_t textColor) |
MikamiUitOpen | 4:76aa20fb326a | 47 | { |
MikamiUitOpen | 4:76aa20fb326a | 48 | uint16_t x0 = ORG_ + offsetX; |
MikamiUitOpen | 4:76aa20fb326a | 49 | uint16_t y0 = ORGY_ + offsetY; |
MikamiUitOpen | 4:76aa20fb326a | 50 | for (int n=0; n<count; n++) |
MikamiUitOpen | 4:76aa20fb326a | 51 | new NumericLabel<int>(x0, y0-n*d_dB*DB1_, |
MikamiUitOpen | 4:76aa20fb326a | 52 | fmt, (int)(MIN_DB_+d_dB*n)); |
MikamiUitOpen | 4:76aa20fb326a | 53 | } |
MikamiUitOpen | 4:76aa20fb326a | 54 | |
MikamiUitOpen | 4:76aa20fb326a | 55 | // 周波数特性のグラフの描画 |
MikamiUitOpen | 4:76aa20fb326a | 56 | void FrqRespDrawer::DrawGraph(FrequencyResponse &frqResp) |
MikamiUitOpen | 4:76aa20fb326a | 57 | { |
MikamiUitOpen | 4:76aa20fb326a | 58 | lcd_->SetTextColor(LINE_COLOR_); |
MikamiUitOpen | 4:76aa20fb326a | 59 | uint16_t width = X(MAX_) - X(MIN_); |
MikamiUitOpen | 4:76aa20fb326a | 60 | uint16_t x1 = 0; |
MikamiUitOpen | 4:76aa20fb326a | 61 | uint16_t y1 = 0; |
MikamiUitOpen | 4:76aa20fb326a | 62 | float pi2FsM = -6.283185f/FS_; // -2*PI*Ts |
MikamiUitOpen | 4:76aa20fb326a | 63 | for (int n=0; n<=width; n++) |
MikamiUitOpen | 4:76aa20fb326a | 64 | { |
MikamiUitOpen | 4:76aa20fb326a | 65 | float frq = PosToFrq(n+ORG_); |
MikamiUitOpen | 4:76aa20fb326a | 66 | uint16_t x2 = X(frq); |
MikamiUitOpen | 4:76aa20fb326a | 67 | float absHz = frqResp.AbsH_z(exp(Complex(0, pi2FsM*frq))); |
MikamiUitOpen | 4:76aa20fb326a | 68 | float dB = (absHz > 0.001f) ? 20.0f*log10f(absHz) : MIN_DB_; |
MikamiUitOpen | 4:76aa20fb326a | 69 | uint16_t y2 = ORGY_ - Round((dB - MIN_DB_)*DB1_); |
MikamiUitOpen | 4:76aa20fb326a | 70 | if (y2 > ORGY_) y2 = ORGY_; |
MikamiUitOpen | 4:76aa20fb326a | 71 | |
MikamiUitOpen | 4:76aa20fb326a | 72 | if (n != 0) lcd_->DrawLine(x1, y1, x2, y2); |
MikamiUitOpen | 4:76aa20fb326a | 73 | |
MikamiUitOpen | 4:76aa20fb326a | 74 | x1 = x2; |
MikamiUitOpen | 4:76aa20fb326a | 75 | y1 = y2; |
MikamiUitOpen | 4:76aa20fb326a | 76 | } |
MikamiUitOpen | 4:76aa20fb326a | 77 | lcd_->SetTextColor(AXIS_COLOR_); |
MikamiUitOpen | 4:76aa20fb326a | 78 | lcd_->DrawHLine(X(MIN_), ORGY_, width); |
MikamiUitOpen | 4:76aa20fb326a | 79 | } |
MikamiUitOpen | 4:76aa20fb326a | 80 | |
MikamiUitOpen | 4:76aa20fb326a | 81 | // 消去 |
MikamiUitOpen | 4:76aa20fb326a | 82 | void FrqRespDrawer::Erase() |
MikamiUitOpen | 4:76aa20fb326a | 83 | { |
MikamiUitOpen | 4:76aa20fb326a | 84 | lcd_->SetTextColor(BACK_COLOR_); |
MikamiUitOpen | 4:76aa20fb326a | 85 | uint16_t height = DB1_*(MAX_DB_ - MIN_DB_); |
MikamiUitOpen | 4:76aa20fb326a | 86 | lcd_->FillRect(ORG_, ORGY_- height, X(MAX_)-X(MIN_)+1, height+1); |
MikamiUitOpen | 4:76aa20fb326a | 87 | } |
MikamiUitOpen | 4:76aa20fb326a | 88 | } |