2 ZynAddSubFX - a software synthesizer
4 Analog Filter.h - Several analog filters (lowpass, highpass...)
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 ANALOG_FILTER_H
24 #define ANALOG_FILTER_H
26 struct analog_filter_stage
32 class AnalogFilter
: public Filter_
38 void init(float sample_rate
, unsigned char type
, float freq
, float q_factor
, unsigned char stages
, float gain
);
39 void filterout(float *smp
);
40 void setfreq(float frequency
);
41 void setfreq_and_q(float frequency
,float q_
);
44 void settype(int type_
);
45 void setgain(float dBgain
);
46 void setstages(int stages_
);
49 // Obtains the response for a given frequency
55 struct analog_filter_stage m_x
[MAX_FILTER_STAGES
+ 1];
56 struct analog_filter_stage m_y
[MAX_FILTER_STAGES
+ 1];
57 struct analog_filter_stage m_x_old
[MAX_FILTER_STAGES
+ 1];
58 struct analog_filter_stage m_y_old
[MAX_FILTER_STAGES
+ 1];
63 struct analog_filter_stage
* x
,
64 struct analog_filter_stage
* y
,
68 void computefiltercoefs();
70 int m_type
; // The type of the filter, one of ZYN_FILTER_ANALOG_TYPE_XXX
71 int m_additional_stages
; // how many times the filter is applied (0->1, 1->2, etc.)
72 float m_frequency
; // Frequency given in Hz
73 float m_q_factor
; // Q factor (resonance or Q factor)
74 float m_gain
; // the gain of the filter (if are shelf/peak) filters
76 int m_order
; // the order of the filter (number of poles)
82 // old coefficients(used only if some filter paremeters changes very fast, and it needs interpolation)
86 bool m_needs_interpolation
;
88 bool m_above_nq
; // whether the frequency is above the nyquist
89 bool m_old_above_nq
; // whether last time was above nyquist (used to see if it needs interpolation)
91 float m_interpolation_buffer
[SOUND_BUFFER_SIZE
];