1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
//===========================================================================
//
// simplechorus
//
// Version 0.0.1
//
//
//
//
// Copyright (c) 2006 Nil Geisweiller
//
//
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02111-1301, USA or point your web browser to http://www.gnu.org.
//===========================================================================
#ifndef __SIMPLECHORUSMODEL_H
#define __SIMPLECHORUSMODEL_H
#define MAXBUFFERLENGTH 192000
#define MAXSINUSRESOLUTION 192000
#define MINFREQ 0.05 //in Hz
#define MAXFREQ 5.0 //in Hz
#define EARSDISTANCE 0.12 //in meter
#define MIDSOURCEDISTANCE 2.0 //in meter
#define MAXDEPTH 1.0 //in meter, radius
#define SOUNDSPEED 330.0 //in meter per second
#define MINDELAYSEC 0.01 //in second
#define MAXDELAYSEC 1.0 //in second
#define COEFFILTER 0.97576 //0.26795
#define PANAMP 0.75
//with cutoff = samplerate/256
//following (2-cos(x)) - sqrt((2-cos(x))^2 - 1) with x = 2*pi*cutoff/samplerate
//#define M_PI 3.14159265358979
class SimpleChorusModel {
private :
//parameters
float _pan;
float _LFOFreq;
float _depth;
//parameter state
float _sampleRate;
float _depthAmp;
float _leftAmp;
float _rightAmp;
float _filterCoef1;
float _filterCoef2;
int _leftMidDistance; //distance of the left micro in samples
int _rightMidDistance; //distance of the right micro in samples
//state
float _inct;
float _index; //time at the scale of sampleRate
float _leftBuffer[MAXBUFFERLENGTH];
float _rightBuffer[MAXBUFFERLENGTH];
float _ocsDistance; //in sample, distance of the micro with initial position
int _past_position_left;
int _past_position_right;
int _position;
public :
static int useCount;
static float sinus[MAXSINUSRESOLUTION];
void process_chorus(float leftInput, float rightInput,
float* leftOutput, float* rightOutput);
void setPan(float);
void setLFOFreq(float);
void setDepth(float);
void setSampleRate(float);
float getPan();
float getLFOFreq();
float getDepth();
void setChorus();
SimpleChorusModel(float samplerate);
~SimpleChorusModel();
};
#endif
|