/*----------------------------------------------------------------------------- © 1999, Steinberg Soft und Hardware GmbH, All Rights Reserved -----------------------------------------------------------------------------*/ #include "AGain.hpp" //----------------------------------------------------------------------------- AGain::AGain(audioMasterCallback audioMaster) : AudioEffectX(audioMaster, 1, 1) // 1 program, 1 parameter { fGain = 1.; // default to 0 dB setNumInputs(2); // stereo in setNumOutputs(2); // stereo out setUniqueID('Gain'); // identify canMono(); // makes sense to feed both inputs with the same signal canProcessReplacing(); // supports both accumulating and replacing output strcpy(programName, "Default"); // default program name } //----------------------------------------------------------------------------------------- AGain::~AGain() { // nothing to do here } //----------------------------------------------------------------------------------------- void AGain::setProgramName(char *name) { strcpy(programName, name); } //----------------------------------------------------------------------------------------- void AGain::getProgramName(char *name) { strcpy(name, programName); } //----------------------------------------------------------------------------------------- void AGain::setParameter(long index, float value) { fGain = value; } //----------------------------------------------------------------------------------------- float AGain::getParameter(long index) { return fGain; } //----------------------------------------------------------------------------------------- void AGain::getParameterName(long index, char *label) { strcpy(label, " Gain "); } //----------------------------------------------------------------------------------------- void AGain::getParameterDisplay(long index, char *text) { dB2string(fGain, text); } //----------------------------------------------------------------------------------------- void AGain::getParameterLabel(long index, char *label) { strcpy(label, " dB "); } //----------------------------------------------------------------------------------------- void AGain::process(float **inputs, float **outputs, long sampleFrames) { float *in1 = inputs[0]; float *in2 = inputs[1]; float *out1 = outputs[0]; float *out2 = outputs[1]; static float i=0; static int k=1; static float correccion=0; static int l=0; static int a=1; while(--sampleFrames >= 0) { if (i==8018) { i=0; correccion++; } if (correccion==10) { l=l+k; k=-k; correccion=0; a=l+k; } (*out1++) += (*in1++) * (l*10 + k*correccion) * fGain; // accumulating (*out2++) += (*in2++) * (a*10 - k*correccion) * fGain; i++; } } //----------------------------------------------------------------------------------------- void AGain::processReplacing(float **inputs, float **outputs, long sampleFrames) { float *in1 = inputs[0]; float *in2 = inputs[1]; float *out1 = outputs[0]; float *out2 = outputs[1]; static float i=0; static int k=1; static float correccion=0; static int l=0; static int a=1; while(--sampleFrames >= 0) { if (i==8018) { i=0; correccion++; } if (correccion==10) { l=l+k; k=-k; correccion=0; a=l+k; } (*out1++) = (*in1++) * (l*10 + k*correccion) * fGain; // accumulating (*out2++) = (*in2++) * (a*10 - k*correccion) * fGain; i++; } }