revised version of F746_SD_GraphicEqualizer

Fork of F746_SD_GraphicEqualizer by

Embed: (wiki syntax)

« Back to documentation index

GrEqualizerFrqResp.hpp Source File

# GrEqualizerFrqResp.hpp

```00001 //-----------------------------------------------------------
00002 //  グラフィックイコライザで使う IIR フィルタの周波数応答
00003 //  Frequency response for graphic equalizer
00004 //
00005 //  2016/04/27, Copyright (c) 2016 MIKAMI, Naoki
00006 //-----------------------------------------------------------
00007
00008 #ifndef GRAPHIC_EQUALIZER_FREQUENCY_RESPONSE_HPP
00009 #define GRAPHIC_EQUALIZER_FREQUENCY_RESPONSE_HPP
00010
00011 #include "FrequancyResponseBase.hpp"
00013
00014 namespace Mikami
00015 {
00016     class GrEqualizerFrqResp : public FrequencyResponse
00017     {
00018     public:
00019         GrEqualizerFrqResp(int stages) : STAGES_(stages)
00020         {   ck_ = new BiquadGrEq::Coefs[stages];  }
00021
00022         ~GrEqualizerFrqResp()
00023         {   delete[] ck_; }
00024
00025         // フィルタの係数設定
00027         {   for (int n=0; n<STAGES_; n++) ck_[n] = ck[n]; }
00028
00029         void SetParam(BiquadGrEq::Coefs ck, int n)
00030         {   ck_[n] = ck; }
00031
00032         // 周波数応答の絶対値を返す関数, 引数: z^(-1)
00033         virtual float AbsH_z(Complex u)
00034         {
00035             Complex h = 1;
00036             for (int k=0; k<STAGES_; k++)
00037             h = h*(ck_[k].b0 + (ck_[k].b1 + ck_[k].b2*u)*u)
00038                 /((1.0f - (ck_[k].a1 + ck_[k].a2*u)*u));
00039             return abs(h);
00040         }
00041
00042     private:
00043         const int STAGES_;
00044         float g0_;