1 /* B.Angr 2 * Dynamic distorted bandpass filter plugin 3 * 4 * Copyright (C) 2021 by Sven Jähnichen 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 3, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software Foundation, 18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 */ 20 21 #ifndef BUTTERWORTHHIGHPASSFILTER_HPP_ 22 #define BUTTERWORTHHIGHPASSFILTER_HPP_ 23 24 #include "ButterworthFilter.hpp" 25 26 class ButterworthHighPassFilter : public ButterworthFilter 27 { 28 public: ButterworthHighPassFilter(const double rate,const double cutoff,const int order)29 ButterworthHighPassFilter (const double rate, const double cutoff, const int order) : 30 ButterworthFilter (order) 31 32 { 33 set (rate, cutoff, order); 34 } 35 set(const double rate,const double cutoff,const int order)36 void set (const double rate, const double cutoff, const int order) 37 { 38 39 this->order = order; 40 o2 = order / 2; 41 f1 = -2; 42 const double a = tan (M_PI * cutoff / rate); 43 const double a2 = a * a; 44 45 for (int i = 0; i < o2; ++i) 46 { 47 const double r = sin (M_PI * (2.0 * double (i) + 1.0) / (2.0 * double (order))); 48 const double s = a2 + 2.0 * a * r + 1.0; 49 coeff0[i] = 1.0 / s; 50 coeff1[i] = 2.0 * (1.0 - a2) / s; 51 coeff2[i] = -(a2 - 2.0 * a * r + 1.0) / s; 52 } 53 } 54 }; 55 56 #endif /* BUTTERWORTHHIGHPASSFILTER_HPP_ */ 57