95 lines
2.0 KiB
C++
95 lines
2.0 KiB
C++
#include <common/StringBuffer.hpp>
|
|
#include <vst/Gain.hpp>
|
|
|
|
Gain::Gain(AudioMasterCallback audioMaster)
|
|
: AudioEffectX(audioMaster,NumPrograms,NumParams)
|
|
{
|
|
mNameValuePairs[GainControl].setNameValue("Gain","db",1);
|
|
setNumInputs(2);
|
|
setNumOutputs(2);
|
|
setUniqueID('Gain');
|
|
canMono();
|
|
canProcessReplacing();
|
|
::strcpy(mProgramName,"Default");
|
|
}
|
|
|
|
Gain::~Gain()
|
|
{
|
|
}
|
|
|
|
void Gain::setProgramName(char *name)
|
|
{
|
|
::strcpy(mProgramName,name);
|
|
}
|
|
|
|
void Gain::getProgramName(char *name)
|
|
{
|
|
::strcpy(name,mProgramName);
|
|
}
|
|
|
|
void Gain::setParameter(long index,float value)
|
|
{
|
|
mNameValuePairs[index].setValue(value);
|
|
}
|
|
|
|
float Gain::getParameter(long index)
|
|
{
|
|
return mNameValuePairs[index].getValue();
|
|
}
|
|
|
|
void Gain::getParameterName(long index,char *label)
|
|
{
|
|
::strcpy(label,mNameValuePairs[index].getName().str());
|
|
}
|
|
|
|
void Gain::getParameterDisplay(long index,char *text)
|
|
{
|
|
float2string(mNameValuePairs[index].getValue(),text);
|
|
}
|
|
|
|
void Gain::getParameterLabel(long index,char *label)
|
|
{
|
|
::strcpy(label,mNameValuePairs[index].getLabel());
|
|
}
|
|
|
|
void Gain::process(float **inputs,float **outputs,long sampleFrames)
|
|
{
|
|
applyGain(inputs,outputs,sampleFrames);
|
|
}
|
|
|
|
void Gain::processReplacing(float **inputs,float **outputs,long sampleFrames)
|
|
{
|
|
applyGain(inputs,outputs,sampleFrames);
|
|
}
|
|
|
|
void Gain::applyGain(float **inputs,float **outputs,long sampleFrames)
|
|
{
|
|
float gain=mNameValuePairs[GainControl].getValue();
|
|
float *in1 = inputs[0];
|
|
float *in2 = inputs[1];
|
|
float *out1 = outputs[0];
|
|
float *out2 = outputs[1];
|
|
|
|
while(--sampleFrames >= 0)
|
|
{
|
|
(*out1++) += (*in1++) * gain; // accumulating
|
|
(*out2++) += (*in2++) * gain;
|
|
}
|
|
}
|
|
|
|
void Gain::createDisplay(float value,char *text)
|
|
{
|
|
StringBuffer stringBuffer;
|
|
String strRep;
|
|
if(value<0)value=0;
|
|
int count=(int)(value*20.00);
|
|
if(count<0)count=0;
|
|
for(int index=0;index<count;index++)stringBuffer.append("|");
|
|
strRep=stringBuffer.toString();
|
|
if(strRep.isNull()||!strRep.length())strRep=" ";
|
|
strcpy(text,stringBuffer.toString().str());
|
|
}
|
|
|
|
|
|
|