1 /*
2   ZynAddSubFX - a software synthesizer
3 
4   APhaser.h - Phaser effect
5   Copyright (C) 2002-2005 Nasca Octavian Paul
6   Author: Nasca Octavian Paul
7 
8   Modified for rakarrack by Josep Andreu and Ryan Billing
9 
10   Further modified for rakarrack by Ryan Billing (Transmogrifox) to model Analog Phaser behavior 2009
11 
12   This program is free software; you can redistribute it and/or modify
13   it under the terms of version 2 of the GNU General Public License
14   as published by the Free Software Foundation.
15 
16   This program is distributed in the hope that it will be useful,
17   but WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   GNU General Public License (version 2) for more details.
20 
21   You should have received a copy of the GNU General Public License (version 2)
22   along with this program; if not, write to the Free Software Foundation,
23   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
24 
25 */
26 
27 #ifndef APHASER_H
28 #define APHASER_H
29 #include "global.h"
30 #include "EffectLFO.h"
31 
32 
33 class Analog_Phaser
34 {
35 public:
36     Analog_Phaser (float * efxoutl_, float * efxoutr_, double sample_rate);
37     ~Analog_Phaser ();
38     void out (float * smpsl, float * smpsr, uint32_t period);
39     void setpreset (int npreset);
40     void changepar (int npar, int value);
41     int getpar (int npar);
42     void cleanup ();
43     int Ppreset;
44     float *efxoutl;
45     float *efxoutr;
46     float outvolume;
47 
48     uint32_t PERIOD;
49 
50 private:
51     //Phaser parameters
52     EffectLFO *lfo;		//Phaser modulator
53     int Pvolume;        //Used in Process.C to set wet/dry mix
54     int Pdistortion;    //Model distortion added by FET element
55     int Pwidth;		//Phaser width (LFO amplitude)
56     int Pfb;		//feedback
57     int Poffset;	//Model mismatch between variable resistors
58     int Pstages;	//Number of first-order All-Pass stages
59     int Poutsub;	//if I wish to subtract the output instead of the adding it
60     int Phyper;		//lfo^2 -- converts tri into hyper-sine
61     int Pdepth;         //Depth of phaser sweep
62     int Pbarber;         //Enable barber pole phasing
63 
64     //Control parameters
65     void setvolume (int Pvolume);
66     void setdistortion (int Pdistortion);
67     void setwidth (int Pwidth);
68     void setfb (int Pfb);
69     void setoffset (int Poffset);
70     void setstages (int Pstages);
71     void setdepth (int Pdepth);
72 
73     //Internal Variables
74     bool barber;			//Barber pole phasing flag
75     float distortion, fb, width, offsetpct, fbl, fbr, depth;
76     float *lxn1, *lyn1,*rxn1, *ryn1, *offset;
77     float oldlgain, oldrgain, rdiff, ldiff, invperiod;
78 
79     float mis;
80     float Rmin;	// 2N5457 typical on resistance at Vgs = 0
81     float Rmax;	// Resistor parallel to FET
82     float Rmx;		// Rmin/Rmax to avoid division in loop
83     float Rconst;      // Handle parallel resistor relationship
84     float C;	        // Capacitor
85     float CFs;		// A constant derived from capacitor and resistor relationships
86     float fPERIOD;
87 
88     class FPreset *Fpre;
89 
90 };
91 
92 #endif
93