Jamoma API  0.6.0.a19
BlueSaturation.cpp
1 #include "BlueSaturation.h"
2 
3 
4 AudioEffect* createEffectInstance(audioMasterCallback audioMaster)
5 {
6  return new BlueSaturation(audioMaster);
7 }
8 
9 
10 /***************************************************************************/
11 
12 BlueSaturation::BlueSaturation(audioMasterCallback audioMaster) :
13  AudioEffectX(audioMaster, kNumPresets, kNumParameters),
14  mNumChannels(2),
15  mOverdrive(NULL),
16  mInput(NULL),
17  mOutput(NULL)
18 {
19  TTDSPInit();
20 
21  setNumInputs(2); // stereo in
22  setNumOutputs(2); // stereo out
23  setUniqueID('TTOv'); // identify
24  canProcessReplacing(); // supports replacing output
25  canDoubleReplacing(); // supports double precision processing
26 
27  TTObjectInstantiate(TT("overdrive"), &mOverdrive, mNumChannels);
28  TTObjectInstantiate(kTTSym_audiosignal, &mInput, mNumChannels);
29  TTObjectInstantiate(kTTSym_audiosignal, &mOutput, mNumChannels);
30 
31  mParameterList = new BlueParameter[kNumParameters];
32 
33  strncpy(mParameterList[kParameterDrive].name, "drive", 256);
34  mParameterList[kParameterDrive].scaling = 9.0;
35  mParameterList[kParameterDrive].offset = 1.0;
36 
37  strncpy(mParameterList[kParameterPreamp].name, "preamp", 256);
38  mParameterList[kParameterPreamp].scaling = 96.0;
39  mParameterList[kParameterPreamp].offset = -78.0;
40 
41  strncpy(mParameterList[kParameterMode].name, "mode", 256);
42  mParameterList[kParameterMode].scaling = 2.0; // just round this one
43  mParameterList[kParameterMode].offset = 0.5;
44 
45  strncpy(mParameterList[kParameterBlockDC].name, "dcblocker", 256);
46  mParameterList[kParameterBlockDC].scaling = 1.0; // just round this one
47  mParameterList[kParameterBlockDC].offset = 0.5;
48 
49  vst_strncpy(programName, "Default", kVstMaxProgNameLen); // default program name
50 }
51 
52 BlueSaturation::~BlueSaturation()
53 {
54  TTObjectRelease(&mOverdrive);
55  TTObjectRelease(&mInput);
56  TTObjectRelease(&mOutput);
57 }
58 
59 
60 
61 void BlueSaturation::setProgramName(char* name)
62 {
63  vst_strncpy(programName, name, kVstMaxProgNameLen);
64 }
65 
66 
67 void BlueSaturation::getProgramName(char* name)
68 {
69  vst_strncpy(name, programName, kVstMaxProgNameLen);
70 }
71 
72 
73 void BlueSaturation::setParameter(VstInt32 index, float value)
74 {
75  int i;
76  TTFloat32 temp;
77 
78  switch (index) {
79  case kParameterDrive:
80  temp = value * mParameterList[index].scaling;
81  temp += mParameterList[index].offset;
82  mOverdrive->setAttributeValue(TT("drive"), temp);
83  break;
84  case kParameterPreamp:
85  temp = value * mParameterList[index].scaling;
86  temp += mParameterList[index].offset;
87  mOverdrive->setAttributeValue(TT("preamp"), temp);
88  break;
89  case kParameterMode:
90  temp = value * mParameterList[index].scaling;
91  temp += mParameterList[index].offset;
92  i = temp;
93  mOverdrive->setAttributeValue(TT("mode"), i);
94  break;
95  case kParameterBlockDC:
96  temp = value * mParameterList[index].scaling;
97  temp += mParameterList[index].offset;
98  i = temp;
99  mOverdrive->setAttributeValue(TT("dcBlocker"), i);
100  break;
101  default:
102  break;
103  }
104 }
105 
106 
107 float BlueSaturation::getParameter(VstInt32 index)
108 {
109  float value = 0;
110 
111  switch (index) {
112  case kParameterDrive:
113  mOverdrive->getAttributeValue(TT("drive"), value);
114  value -= mParameterList[index].offset;
115  value /= mParameterList[index].scaling;
116  break;
117  case kParameterPreamp:
118  mOverdrive->getAttributeValue(TT("preamp"), value);
119  value -= mParameterList[index].offset;
120  value /= mParameterList[index].scaling;
121  break;
122  case kParameterMode:
123  mOverdrive->getAttributeValue(TT("mode"), value);
124  break;
125  case kParameterBlockDC:
126  mOverdrive->getAttributeValue(TT("dcBlocker"), value);
127  break;
128  default:
129  break;
130  }
131  return value;
132 }
133 
134 
135 void BlueSaturation::getParameterName(VstInt32 index, char* label)
136 {
137  strncpy(label, mParameterList[index].name, kVstMaxParamStrLen);
138 }
139 
140 
141 void BlueSaturation::getParameterDisplay(VstInt32 index, char* text)
142 {
143  //dB2string (fGain, text, kVstMaxParamStrLen);
144 }
145 
146 
147 void BlueSaturation::getParameterLabel(VstInt32 index, char* label)
148 {
149  if(index == kParameterPreamp)
150  vst_strncpy(label, "dB", kVstMaxParamStrLen);
151 }
152 
153 
154 bool BlueSaturation::getEffectName(char* name)
155 {
156  vst_strncpy(name, "BlueSaturation", kVstMaxEffectNameLen);
157  return true;
158 }
159 
160 
161 bool BlueSaturation::getProductString(char* text)
162 {
163  vst_strncpy(text, "BlueSaturation", kVstMaxProductStrLen);
164  return true;
165 }
166 
167 
168 bool BlueSaturation::getVendorString(char* text)
169 {
170  vst_strncpy(text, "Jamoma (jamoma.org)", kVstMaxVendorStrLen);
171  return true;
172 }
173 
174 
175 VstInt32 BlueSaturation::getVendorVersion()
176 {
177  return 1000;
178 }
179 
180 
181 
182 void BlueSaturation::processReplacing(float** inputs, float** outputs, VstInt32 sampleFrames)
183 {
184  mInput->setVector(0, sampleFrames, (TTFloat32*)inputs[0]);
185  mInput->setVector(1, sampleFrames, (TTFloat32*)inputs[1]);
186  mOutput->setVectorSizeWithInt(sampleFrames);
187  mOutput->alloc();
188 
189  mOverdrive->process(mInput, mOutput);
190 
191  mOutput->getVector(0, sampleFrames, (TTFloat32*)outputs[0]);
192  mOutput->getVector(1, sampleFrames, (TTFloat32*)outputs[1]);
193 }
194 
195 
196 void BlueSaturation::processDoubleReplacing(double** inputs, double** outputs, VstInt32 sampleFrames)
197 {
198  mInput->setVector(0, sampleFrames, (TTFloat64*)inputs[0]);
199  mInput->setVector(1, sampleFrames, (TTFloat64*)inputs[1]);
200  mOutput->setVectorSizeWithInt(sampleFrames);
201  mOutput->alloc();
202 
203  mOverdrive->process(mInput, mOutput);
204 
205  mOutput->getVector(0, sampleFrames, (TTFloat64*)outputs[0]);
206  mOutput->getVector(1, sampleFrames, (TTFloat64*)outputs[1]);
207 }
208 
double TTFloat64
64 bit floating point number
Definition: TTBase.h:188
#define TT
This macro is defined as a shortcut for doing a lookup in the symbol table.
Definition: TTSymbol.h:155
float TTFloat32
32 bit floating point number
Definition: TTBase.h:187
TTSymbol name
Name of this unit.
void TTDSP_EXPORT TTDSPInit(const char *pathToBinaries=NULL)
Initialise the Jamoma DSP library, as well as Jamoma Foundation foundation if needed.
Definition: TTDSP.cpp:30