1 /* 2 ZynAddSubFX - a software synthesizer 3 4 SV Filter.h - Several state-variable filters 5 Copyright (C) 2002-2005 Nasca Octavian Paul 6 Author: Nasca Octavian Paul 7 8 Modified for rakarrack by Josep Andreu 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of version 2 of the GNU General Public License 12 as published by the Free Software Foundation. 13 14 This program is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License (version 2) for more details. 18 19 You should have received a copy of the GNU General Public License (version 2) 20 along with this program; if not, write to the Free Software Foundation, 21 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 23 */ 24 25 #ifndef SV_FILTER_H 26 #define SV_FILTER_H 27 28 #include "global.h" 29 #include "Filter_.h" 30 class SVFilter:public Filter_ 31 { 32 public: 33 SVFilter (unsigned char Ftype, float Ffreq, float Fq, 34 unsigned char Fstages, double sample_rate, float* interpbuf);//interpbuf MUST be an array equal or larger to period 35 ~SVFilter (); 36 void filterout (float * smp, uint32_t period); 37 void setfreq (float frequency); 38 void setfreq_and_q (float frequency, float q_); 39 void setq (float q_); 40 41 void settype (int type_); 42 void setgain (float dBgain); 43 void setstages (int stages_); 44 void cleanup (); 45 46 private: 47 struct fstage { 48 float low, high, band, notch; 49 } st[MAX_FILTER_STAGES + 1]; 50 51 struct parameters { 52 float f, q, q_sqrt; 53 } par, ipar; 54 55 56 void singlefilterout (float * smp, fstage & x, parameters & par, uint32_t period); 57 void computefiltercoefs (); 58 int type; //The type of the filter (LPF1,HPF1,LPF2,HPF2...) 59 unsigned int stages;//how many times the filter is applied (0->1,1->2,etc.) 60 int abovenq; //this is 1 if the frequency is above the nyquist 61 int oldabovenq; 62 int needsinterpolation, firsttime; 63 64 float freq; //Frequency given in Hz 65 float q; //Q factor (resonance or Q factor) 66 float gain; //the gain of the filter (if are shelf/peak) filters 67 float fSAMPLE_RATE; 68 float * ismp; //buffer used if filter interpolates 69 70 }; 71 72 73 #endif 74