Expose all 8 voices
[zyn.git] / sv_filter.h
blob998ecec0f1294ed998c9de1da4eedfe1d2ee97b4
1 /*
2 ZynAddSubFX - a software synthesizer
4 SV Filter.h - Several state-variable filters
5 Copyright (C) 2002-2005 Nasca Octavian Paul
6 Author: Nasca Octavian Paul
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of version 2 of the GNU General Public License
10 as published by the Free Software Foundation.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License (version 2) for more details.
17 You should have received a copy of the GNU General Public License (version 2)
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef SV_FILTER_H
24 #define SV_FILTER_H
26 class SVFilter: public Filter_
28 public:
29 SVFilter() {};
30 ~SVFilter() {};
32 void init(float sample_rate, int type, REALTYPE Ffreq, REALTYPE Fq, unsigned char Fstages, float gain);
33 void filterout(REALTYPE *smp);
34 void setfreq(REALTYPE frequency);
35 void setfreq_and_q(REALTYPE frequency,REALTYPE q_);
36 void setq(REALTYPE q_);
38 void settype(int type_);
39 void setgain(REALTYPE dBgain);
40 void setstages(int stages_);
41 void cleanup();
43 private:
44 float m_sample_rate;
46 struct fstage{
47 REALTYPE low,high,band,notch;
48 } st[MAX_FILTER_STAGES+1];
50 struct parameters{
51 REALTYPE f,q,q_sqrt;
52 }par,ipar;
54 REALTYPE m_ismp[SOUND_BUFFER_SIZE]; // used for interpolation
56 void singlefilterout(REALTYPE *smp,fstage &x,parameters &par);
57 void computefiltercoefs();
58 int m_type; // The type of the filter, one of ZYN_FILTER_SV_TYPE_XXX
59 int stages;//how many times the filter is applied (0->1,1->2,etc.)
60 REALTYPE freq;//Frequency given in Hz
61 REALTYPE q; //Q factor (resonance or Q factor)
62 REALTYPE m_gain;//the gain of the filter (if are shelf/peak) filters
64 int abovenq;//this is 1 if the frequency is above the nyquist
65 int oldabovenq;
66 int needsinterpolation,firsttime;
69 #endif