-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathWavechild670Processor.cpp
236 lines (236 loc) · 9.45 KB
/
Wavechild670Processor.cpp
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
//==============================================================================
#include "Wavechild670Processor.h"
#include "Wavechild670Editor.h"
//==============================================================================
Wavechild670Processor::Wavechild670Processor ()
: wc670s (new Wavechild670::StereoProcessor<double>()),
isInit (false),
Fs(0)
{
}
//------------------------------------------------------------------------------
Wavechild670Processor::~Wavechild670Processor ()
{
}
//==============================================================================
void Wavechild670Processor::prepareToPlay (double sampleRate, int samplesPerBlock)
{
if (!isInit || sampleRate != Fs)
{
isInit = true;
wc670s->init (sampleRate);
Fs = sampleRate;
}
}
//------------------------------------------------------------------------------
void Wavechild670Processor::releaseResources ()
{
}
//==============================================================================
void Wavechild670Processor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages)
{
int ni = getNumInputChannels();
int no = getNumOutputChannels();
if (ni == 2)
{
float *left = buffer.getSampleData(0, 0);
float *right = buffer.getSampleData(1, 0);
int i=0; int max=buffer.getNumSamples();
for (;i<max;++i)
{
wc670s->process (&left[i], &right[i]);
}
}
int i = ni;
for (; i < no; ++i)
buffer.clear (i, 0, buffer.getNumSamples());
}
//==============================================================================
AudioProcessorEditor* Wavechild670Processor::createEditor()
{
return new Wavechild670Editor (this);
}
//------------------------------------------------------------------------------
bool Wavechild670Processor::hasEditor() const
{
return true;
}
//==============================================================================
const String Wavechild670Processor::getName() const
{
return "Wavechild670";
}
//==============================================================================
int Wavechild670Processor::getNumParameters()
{
return 11;
}
//------------------------------------------------------------------------------
float Wavechild670Processor::getParameter (int index)
{
switch (index)
{
case 0: return (wc670s->levelA); // -20db CCW
case 1: return (wc670s->thresholdA); // 0-10 CW
case 2: return (float(wc670s->tcA) / 10.f); // 6-switch
//----------------------------------------------------------------------
case 3: return (wc670s->levelB); // -20db CCW
case 4: return (wc670s->thresholdB); // 0-10 CW
case 5: return (float(wc670s->tcB) / 10.f); // 6-switch
//----------------------------------------------------------------------
case 6: return (wc670s->feedback) ? 1.0f : 0.0f;
case 7: return (wc670s->midside) ? 1.0f : 0.0f;
case 8: return (wc670s->linked) ? 1.0f : 0.0f;
//----------------------------------------------------------------------
case 9: return (wc670s->gain);
case 10: return (wc670s->hardclipout) ? 1.0f : 0.0f;
//----------------------------------------------------------------------
default: return 0.0f;
};
}
//------------------------------------------------------------------------------
void Wavechild670Processor::setParameter (int index, float newValue)
{
switch (index)
{
case 0: wc670s->levelA = newValue; break;
case 1: wc670s->thresholdA = newValue; break;
case 2: wc670s->parameters (int(newValue * 10.f), wc670s->tcB);
//----------------------------------------------------------------------
case 3: wc670s->levelB = newValue; break;
case 4: wc670s->thresholdB = newValue; break;
case 5: wc670s->parameters (wc670s->tcA, int(newValue * 10.f));
//----------------------------------------------------------------------
case 6: wc670s->feedback = (newValue > 0.5f) ? true : false; break;
case 7: wc670s->midside = (newValue > 0.5f) ? true : false; break;
case 8: wc670s->linked = (newValue > 0.5f) ? true : false; break;
//----------------------------------------------------------------------
case 9: wc670s->gain = newValue; break;
case 10: wc670s->hardclipout = (newValue > 0.5f) ? true : false;
//----------------------------------------------------------------------
default: break;
};
}
//------------------------------------------------------------------------------
const String Wavechild670Processor::getParameterName (int index)
{
switch (index)
{
case 0: return "A|Input Gain";
case 1: return "A|Threshold";
case 2: return "A|Time Constant";
//----------------------------------------------------------------------
case 3: return "B|Input Gain";
case 4: return "B|Threshold";
case 5: return "B|Time Constant";
//----------------------------------------------------------------------
case 6: return "Feedback Topology";
case 7: return "Midside Coupling";
case 8: return "Sidechain Link";
//----------------------------------------------------------------------
case 9: return "Output Gain";
case 10: return "Hardclip Output";
//----------------------------------------------------------------------
default: return "Undefined";
};
}
//------------------------------------------------------------------------------
const String Wavechild670Processor::getParameterText (int index)
{
switch (index)
{
case 0: return "";
case 1: return "";
case 2: return String(wc670s->tcA);
//----------------------------------------------------------------------
case 3: return "";
case 4: return "";
case 5: return String(wc670s->tcB);
//----------------------------------------------------------------------
case 6: return (wc670s->hardclipout) ? "ON" : "OFF";
case 7: return (wc670s->hardclipout) ? "ON" : "OFF";
case 8: return (wc670s->hardclipout) ? "ON" : "OFF";
//----------------------------------------------------------------------
case 9: return ""; // min -50.0 max 10.0 ?
case 10: return (wc670s->hardclipout) ? "ON" : "OFF";
//----------------------------------------------------------------------
default: return "Undefined";
};
}
//==============================================================================
const String Wavechild670Processor::getInputChannelName (int channelIndex) const
{
return String (channelIndex + 1);
}
//------------------------------------------------------------------------------
const String Wavechild670Processor::getOutputChannelName (int channelIndex) const
{
return String (channelIndex + 1);
}
//------------------------------------------------------------------------------
bool Wavechild670Processor::isInputChannelStereoPair (int index) const
{
return true;
}
//------------------------------------------------------------------------------
bool Wavechild670Processor::isOutputChannelStereoPair (int index) const
{
return true;
}
//==============================================================================
bool Wavechild670Processor::acceptsMidi() const
{
return false;
}
//------------------------------------------------------------------------------
bool Wavechild670Processor::producesMidi() const
{
return false;
}
//------------------------------------------------------------------------------
bool Wavechild670Processor::silenceInProducesSilenceOut() const
{
return true;
}
//==============================================================================
double Wavechild670Processor::getTailLengthSeconds() const
{
return 0;
}
//==============================================================================
int Wavechild670Processor::getNumPrograms()
{
return 0;
}
//------------------------------------------------------------------------------
int Wavechild670Processor::getCurrentProgram()
{
return 0;
}
//------------------------------------------------------------------------------
void Wavechild670Processor::setCurrentProgram (int index)
{
}
//------------------------------------------------------------------------------
const String Wavechild670Processor::getProgramName (int index)
{
return String::empty;
}
//------------------------------------------------------------------------------
void Wavechild670Processor::changeProgramName (int index, const String& newName)
{
}
//==============================================================================
void Wavechild670Processor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
}
//----------------------------------------------------------------------
void Wavechild670Processor::setStateInformation (const void* data, int sizeInBytes)
{
// You should use this method to restore your parameters from this memory block,
// whose contents will have been created by the getStateInformation() call.
}
//==============================================================================