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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FrquencyResponseDrawer.cpp Source File

FrquencyResponseDrawer.cpp

00001 //-----------------------------------------------------------
00002 //  周波数が対数スケールの周波数特性を描画するクラス
00003 //  FrqRespDrawer class
00004 //
00005 //  2016/04/17, Copyright (c) 2016 MIKAMI, Naoki
00006 //-----------------------------------------------------------
00007 
00008 #include "FrquencyResponseDrawer.hpp"
00009 
00010 namespace Mikami
00011 {
00012     // 目盛線の描画
00013     void FrqRespDrawer::DrawAxis()
00014     {
00015         uint16_t height = DB1_*(MAX_DB_ - MIN_DB_);
00016         int logMin = (int)floorf(log10f(MIN_));
00017         int loop = (int)floorf(log10f(MAX_)) - logMin;
00018 
00019         lcd_->SetTextColor(AXIS_COLOR_);
00020         uint16_t y0 = ORGY_ - height;
00021         lcd_->DrawVLine(X(MIN_), y0, height);   // 最小値に対応する線
00022 
00023         float du = powf(10.0, logMin);          // 座標値の増分
00024         float u1 = (floorf(MIN_/du) + 1.0f)*du; // 最小値に対応する線の次の座標値
00025 
00026         for (int n=0; n<=loop; n++)
00027         {
00028             float uMax = (10.0f*du < MAX_) ? 10.0f*du : MAX_;
00029             for (float u=u1; u<uMax*0.99f; u+=du)
00030                 lcd_->DrawVLine(X(u), y0, height);
00031 
00032             du = uMax;          // 値の増分を 10 倍する
00033             u1 = du;            // 次の for ループ の最初の値
00034         }
00035 
00036         lcd_->DrawVLine(X(MAX_), y0, height);   // 最大値に対応する線
00037         
00038         uint16_t width = X(MAX_) - X(MIN_);
00039         for (int n=0; n<= (MAX_DB_ - MIN_DB_)/10; n++)
00040             lcd_->DrawHLine(X(MIN_), ORGY_-DB10_*n, width);
00041     }
00042 
00043     // 縦軸の数値の表示
00044     void FrqRespDrawer::DrawNumericY(int offsetX, int offsetY, int count,
00045                                      uint16_t d_dB, const char fmt[], sFONT &fonts,
00046                                      uint32_t textColor)
00047     {
00048         uint16_t x0 = ORG_ + offsetX;
00049         uint16_t y0 = ORGY_ + offsetY;
00050         for (int n=0; n<count; n++)
00051             NumericLabel<int> num(x0, y0-n*d_dB*DB1_,
00052                                   fmt, (int)(MIN_DB_+d_dB*n));
00053     }
00054 
00055     // 周波数特性のグラフの描画
00056     void FrqRespDrawer::DrawGraph(FrequencyResponse &frqResp, uint32_t color)
00057     {
00058         lcd_->SetTextColor(color);
00059         uint16_t width = X(MAX_) - X(MIN_);   
00060         uint16_t x1 = 0;
00061         uint16_t y1 = 0;
00062         float pi2FsM = -6.283185f/FS_;  // -2*PI*Ts
00063         for (int n=0; n<=width; n++)
00064         {
00065             float frq = PosToFrq(n+ORG_);
00066             uint16_t x2 = X(frq);
00067             float absHz = frqResp.AbsH_z(exp(Complex(0, pi2FsM*frq)));
00068             float dB = (absHz > 0.001f) ? 20.0f*log10f(absHz) : MIN_DB_;
00069             uint16_t y2 = ORGY_ - Round((dB - MIN_DB_)*DB1_);
00070             if (y2 > ORGY_) y2 = ORGY_;
00071 
00072             if (n != 0) lcd_->DrawLine(x1, y1, x2, y2);
00073 
00074             x1 = x2;
00075             y1 = y2;
00076         }
00077         lcd_->SetTextColor(AXIS_COLOR_);
00078         lcd_->DrawHLine(X(MIN_), ORGY_, width);
00079     }
00080 
00081     // 消去
00082     void FrqRespDrawer::Erase()
00083     {
00084         lcd_->SetTextColor(BACK_COLOR_);
00085         uint16_t height = DB1_*(MAX_DB_ - MIN_DB_);
00086         lcd_->FillRect(ORG_, ORGY_- height, X(MAX_)-X(MIN_)+1, height+1);
00087     }
00088 }
00089