Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: F746_GUI F746_SAI_IO SD_PlayerSkeleton FrequencyResponseDrawer
GrEqDesignerDrawer.cpp
00001 //------------------------------------------------------------------------------ 00002 // イコライザ用フィルタのパラメータを設定し,その周波数特性を描画するためのクラス 00003 // 00004 // 2017/04/10, Copyright (c) 2017 MIKAMI, Naoki 00005 //------------------------------------------------------------------------------ 00006 00007 #include "GrEqDesignerDrawer.hpp" 00008 00009 namespace Mikami 00010 { 00011 // Constructor 00012 GrEqDesignerDrawer::GrEqDesignerDrawer(uint16_t x0, uint16_t y0, float db1, 00013 int bands, float f0, int fs) 00014 : X0_(x0), Y0_(y0), BANDS_(bands), Q_VAL_(1.0f/sqrtf(2.0f)), 00015 f0_(bands), ck_(bands), 00016 calculator_(bands, fs), frqResp_(bands), 00017 drawerObj_(x0, 50.0f, 20000.0f, 128, y0, -18, 18, db1, 6, fs) 00018 { 00019 for (int n=0; n<bands; n++) f0_[n] = f0*powf(2, n); 00020 00021 for (int n=0; n<bands; n++) 00022 ck_[n] = calculator_.Execute(n, f0_[n], 0, Q_VAL_); 00023 frqResp_.SetParams(ck_); 00024 } 00025 00026 // 周波数特性の描画 00027 void GrEqDesignerDrawer::DrawResponse() 00028 { 00029 drawerObj_.DrawAxis(); // 目盛線の描画 00030 FrqRespDrawer::AxisX_Char numX[] = // 横軸の目盛値を描画する際に使う構造体の配列 00031 {{ 50, "50"}, { 100, "100"}, { 200, "200"}, { 500, "500"}, { 1000, "1k"}, 00032 { 2000, "2k"}, { 5000, "5k"}, {10000, "10k"}, {20000, "20k"}}; 00033 00034 drawerObj_.DrawNumericX(numX, 9, 6, "Frequency [Hz]"); // 横軸の目盛 00035 drawerObj_.DrawNumericY(-24, -6, 6, "%3d"); // 縦軸の目盛値は 6 dB 間隔 00036 drawerObj_.DrawGraph(frqResp_); // 周波数特性のカーブの描画 00037 } 00038 00039 // 周波数特性の平坦化と描画 00040 void GrEqDesignerDrawer::DrawFlat() 00041 { 00042 for (int n=0; n<BANDS_; n++) 00043 ck_[n] = calculator_.Execute(n, f0_[n], 0, Q_VAL_); 00044 frqResp_.SetParams(ck_); 00045 00046 drawerObj_.Erase(); 00047 drawerObj_.DrawAxis(); // 目盛線の描画 00048 drawerObj_.DrawGraph(frqResp_); // 周波数特性のグラフのカーブを描画する 00049 } 00050 00051 // 特定のバンドのイコライザ用フィルタのパラメータの設定と周波数特性の再描画 00052 void GrEqDesignerDrawer::DesignAndRedraw(float gainDb, int n) 00053 { 00054 ck_[n] = calculator_.Execute(n, f0_[n], gainDb, Q_VAL_); 00055 frqResp_.SetParam(ck_[n], n); 00056 00057 drawerObj_.Erase(); 00058 drawerObj_.DrawAxis(); // 目盛線の描画 00059 drawerObj_.DrawGraph(frqResp_); // 周波数特性のグラフのカーブを描画する 00060 } 00061 }
Generated on Tue Jul 12 2022 22:59:37 by
1.7.2