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
MyGraphicEqualizer/GrEqualizerFrqResp.hpp
- Committer:
- MikamiUitOpen
- Date:
- 2017-03-28
- Revision:
- 23:878419f8638b
- Parent:
- 20:5c69e664e17c
File content as of revision 23:878419f8638b:
//-----------------------------------------------------------
// グラフィックイコライザで使う IIR フィルタの周波数応答
// Frequency response for graphic equalizer
//
// 2017/03/28, Copyright (c) 2017 MIKAMI, Naoki
//-----------------------------------------------------------
#ifndef GRAPHIC_EQUALIZER_FREQUENCY_RESPONSE_HPP
#define GRAPHIC_EQUALIZER_FREQUENCY_RESPONSE_HPP
#include "FrequancyResponseBase.hpp"
#include "BiquadGrEq.hpp"
#include "Array.hpp"
namespace Mikami
{
class GrEqualizerFrqResp : public FrequencyResponse
{
public:
GrEqualizerFrqResp(int bands)
: BANDS_(bands), ck_(bands) {}
virtual ~GrEqualizerFrqResp() {}
// フィルタの係数設定
void SetParams(BiquadGrEq::Coefs ck[])
{ for (int n=0; n<BANDS_; n++) ck_[n] = ck[n]; }
void SetParam(BiquadGrEq::Coefs ck, int n)
{ ck_[n] = ck; }
// 周波数応答の絶対値を返す関数, 引数: z^(-1)
virtual float AbsH_z(Complex u)
{
Complex h = 1;
for (int k=0; k<BANDS_; k++)
h = h*(ck_[k].b0 + (ck_[k].b1 + ck_[k].b2*u)*u)
/(1.0f - (ck_[k].a1 + ck_[k].a2*u)*u);
return abs(h);
}
private:
const int BANDS_;
Array<BiquadGrEq::Coefs> ck_;
// disallow copy constructor and assignment operator
GrEqualizerFrqResp(const GrEqualizerFrqResp&);
GrEqualizerFrqResp& operator=(const GrEqualizerFrqResp&);
};
}
#endif // GRAPHIC_EQUALIZER_FREQUENCY_RESPONSE_HPP