1 /*
2   ZynAddSubFX - a software synthesizer
3 
4   Echo.h - Echo Effect
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 modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2 of the License, or
11   (at your option) any later version.
12 
13   This program is distributed in the hope that it will be useful,
14   but WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   GNU General Public License (version 2 or later) for more details.
17 
18   You should have received a copy of the GNU General Public License (version 2)
19   along with this program; if not, write to the Free Software Foundation,
20   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
21 
22 */
23 
24 #ifndef ECHO_H
25 #define ECHO_H
26 
27 #include "Effect.h"
28 #include "../Misc/Stereo.h"
29 
30 /**Echo Effect*/
31 class Echo:public Effect
32 {
33     public:
34         Echo(bool insertion_, float *efxoutl_, float *efxoutr_, unsigned int srate, int bufsize);
35         ~Echo();
36 
37         void out(const Stereo<float *> &input);
38         void setpreset(unsigned char npreset);
39         /**
40          * Sets the value of the chosen variable
41          *
42          * The possible parameters are:
43          *   -# Volume
44          *   -# Panning
45          *   -# Delay
46          *   -# L/R Delay
47          *   -# L/R Crossover
48          *   -# Feedback
49          *   -# Dampening
50          * @param npar number of chosen parameter
51          * @param value the new value
52          */
53         void changepar(int npar, unsigned char value);
54 
55         /**
56          * Gets the specified parameter
57          *
58          * The possible parameters are
59          *   -# Volume
60          *   -# Panning
61          *   -# Delay
62          *   -# L/R Delay
63          *   -# L/R Crossover
64          *   -# Feedback
65          *   -# Dampening
66          * @param npar number of chosen parameter
67          * @return value of parameter
68          */
69         unsigned char getpar(int npar) const;
70         int getnumparams(void);
71         void cleanup(void);
72     private:
73 		int samplerate;
74 
75         //Parameters
76         unsigned char Pvolume;  /**<#1 Volume or Dry/Wetness*/
77         unsigned char Pdelay;   /**<#3 Delay of the Echo*/
78         unsigned char Plrdelay; /**<#4 L/R delay difference*/
79         unsigned char Pfb;      /**<#6Feedback*/
80         unsigned char Phidamp;  /**<#7Dampening of the Echo*/
81 
82         void setvolume(unsigned char _Pvolume);
83         void setdelay(unsigned char _Pdelay);
84         void setlrdelay(unsigned char _Plrdelay);
85         void setfb(unsigned char _Pfb);
86         void sethidamp(unsigned char _Phidamp);
87 
88         //Real Parameters
89         float fb, hidamp;
90         //Left/Right delay lengths
91         Stereo<int> delayTime;
92         float       lrdelay;
93         float       avgDelay;
94 
95         void initdelays(void);
96         //2 channel ring buffer
97         Stereo<float *> delay;
98         Stereo<float>   old;
99 
100         //position of reading/writing from delaysample
101         Stereo<int> pos;
102         //step size for delay buffer
103         Stereo<int> delta;
104         Stereo<int> ndelta;
105 };
106 
107 #endif
108