This is the first patch from a series of overdrive / distortion effects.
This one uses a non linear “tube” overdrive curve.
3 parameters: input gain (“drive”), offset, and master level.
You can try and change the overdrive curve to see what it does!```
Class OverdrivePatch : public Patch {
public:
OverdrivePatch();
~OverdrivePatch();
void processAudio(AudioInputBuffer &input, AudioOutputBuffer &output){
int size = input.getSize();
float buf[size];
float gain;
getParameterValue(PARAMETER_D, gain); // get output gain value
float drive;
getParameterValue(PARAMETER_A, drive); // get input drive value
drive += 0.03;
drive *= 40;
gain/= 2;
float offset;
getParameterValue(PARAMETER_C, offset); // get offset value
input.getSamples(0, size, buf);
for(int i=0; i<size; i++)
buf[i] = gain*nonLinear((buf[i]+offset/10)*drive); // process each sample
output.setSamples(0, size, buf);
}
float nonLinear(float x){ // Overdrive curve
if (x<-3)
return -1;
else if (x>3)
return 1;
else
return x * ( 27 + x*x ) / ( 27 + 9*x*x );
}
};