#ifndef FIRclass_Direct
// FIR フィルタ用クラスの定義部
template<int order> class FIR_Direct
{
private:
const float *const hm; // フィルタの係数に対応するポインタ
float xn[order+1]; // 入力信号用バッファ
public:
FIR_Direct(const float hk[]) : hm(hk) // コンストラクタ
{ for (int k=0; k<=order; k++) xn[k] = 0.0; }
inline float Execute(const float xin); // FIR フィルタ処理の宣言
};
// FIR フィルタ用クラスの実装部
template<int order> inline float FIR_Direct<order>::Execute(const
float xin)
{
float acc = 0.0;
xn[0] = xin;
for (int k=0; k<=order; k++) acc = acc + hm[k]*xn[k]; // 積和の計算
for (int k=order; k>0; k--) xn[k] = xn[k-1]; // 入力信号の移動
return acc;
}
#define FIRclass_Direct
#endif