convfilter.hpp

来自「Adaptive digital Filters in C++」· HPP 代码 · 共 61 行

HPP
61
字号
// convfilter.hpp	A convolution filter class, this is an abstract base class

//                      (c) Copyright 1995, Everett F. Carter Jr.
//                      Permission is granted by the author to use
//			this software for any application provided this
//			copyright notice is preserved.

// rcsid: @(#)convfilter.hpp	1.6 16:35:51 5/16/95   EFC

#ifndef CONV_FILTER_HPP_
#define CONV_FILTER_HPP_ 1.6

/*		filters the desired input according to

		y[t] = alpha * x[t..t-nx-1] - beta * y[t-1..t-ny]

		where * is a convolution, if the filter is a FIR filter
		then beta is zero

*/

#include <math.h>
#include <complex.h>

#include <dfilter.hpp>

class ConvolutionFilter : public DigitalFilter
{

	protected:
           float *alpha, *x;
           int nx, nm1;
	   float *beta, *y;
	   int ny, mm1;

	   void free_x_space();
	   void free_y_space();
	   void allocate_x_space(const int wx);
	   void allocate_y_space(const int wy);
           void shift(float*, const int);
	   float convolve();

          ConvolutionFilter() : nx(0), alpha(NULL), x(NULL),
				ny(0), beta(NULL),  y(NULL) {}

        public:

          
         virtual ~ConvolutionFilter() { free_x_space(); free_y_space(); }

	  // The transfer function for calculation of filter characteristics
	  virtual complex h(const float w, const int inv = 1);

	  // print the coefficients
	  ostream& coefs(ostream& os) const;

};

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?