1 /*
2   ZynAddSubFX - a software synthesizer
3 
4   FormantFilter.h - formant filter
5   Copyright (C) 2002-2005 Nasca Octavian Paul
6   Author: Nasca Octavian Paul
7 
8   This program is free software; you can redistribute it and/or
9   modify it under the terms of the GNU General Public License
10   as published by the Free Software Foundation; either version 2
11   of the License, or (at your option) any later version.
12 */
13 
14 #ifndef FORMANT_FILTER_H
15 #define FORMANT_FILTER_H
16 
17 #include "../globals.h"
18 #include "Filter.h"
19 #include "Value_Smoothing_Filter.h"
20 
21 namespace zyn {
22 
23 class FormantFilter:public Filter
24 {
25     public:
26         FormantFilter(const FilterParams *pars, Allocator *alloc, unsigned int srate, int bufsize);
27         ~FormantFilter();
28         void filterout(float *smp);
29         void setfreq(float frequency);
30         void setfreq_and_q(float frequency, float q_);
31         void setq(float q_);
32         void setgain(float dBgain);
33 
34         void cleanup(void);
35 
36     private:
37         void setpos(float input);
38 
39 
40         class AnalogFilter * formant[FF_MAX_FORMANTS];
41 
42         struct {
43             float freq, amp, q; //frequency,amplitude,Q
44         } formantpar[FF_MAX_VOWELS][FF_MAX_FORMANTS],
45           currentformants[FF_MAX_FORMANTS];
46 
47         struct {
48             unsigned char nvowel;
49         } sequence [FF_MAX_SEQUENCE];
50 
51         int   sequencesize, numformants;
52         bool  firsttime;
53         float oldinput, slowinput;
54         float Qfactor, formantslowness, oldQfactor;
55         float vowelclearness, sequencestretch;
56         Allocator &memory;
57 
58         Value_Smoothing_Filter formant_amp_smoothing[FF_MAX_FORMANTS];
59 };
60 
61 }
62 
63 #endif
64