2014-01-29 17:55:11 -08:00
|
|
|
#include <stdio.h>
|
2013-11-17 19:32:45 -08:00
|
|
|
#include "public.sdk/source/vst2.x/audioeffectx.h"
|
|
|
|
|
|
|
|
//#INCLUDE
|
2015-06-07 20:56:06 -07:00
|
|
|
//#REDEFINE
|
2013-11-17 19:32:45 -08:00
|
|
|
|
2014-01-29 17:55:11 -08:00
|
|
|
// VST 2.4 by standard only holds 8 (+ 1 null) length strings,
|
|
|
|
// but this is never the case in practice. I've seen up to 24.
|
|
|
|
#define MAX_PARAM_LEN 24
|
|
|
|
|
2015-06-07 20:56:06 -07:00
|
|
|
struct plugin : public AudioEffectX
|
2013-11-17 19:32:45 -08:00
|
|
|
{
|
|
|
|
plugin(audioMasterCallback audioMaster);
|
|
|
|
~plugin();
|
|
|
|
|
|
|
|
void resume();
|
|
|
|
void suspend();
|
|
|
|
void processReplacing(float **, float **, VstInt32);
|
|
|
|
void processDoubleReplacing(double **, double **, VstInt32);
|
|
|
|
|
|
|
|
bool setProcessPrecision(VstInt32 precision);
|
|
|
|
|
|
|
|
void setSampleRate(float);
|
2014-02-03 15:00:17 -08:00
|
|
|
void setProgramName(char *);
|
|
|
|
void getProgramName(char *);
|
|
|
|
bool getProgramNameIndexed(VstInt32, VstInt32, char *);
|
2013-11-17 19:32:45 -08:00
|
|
|
bool getEffectName(char *);
|
|
|
|
bool getVendorString(char *);
|
|
|
|
bool getProductString(char *);
|
|
|
|
//VstInt32 getVendorVersion();
|
|
|
|
|
2014-01-29 17:55:11 -08:00
|
|
|
void setParameter(VstInt32, float);
|
|
|
|
float getParameter(VstInt32);
|
|
|
|
void getParameterName(VstInt32, char *); // eg. Gain
|
|
|
|
void getParameterDisplay(VstInt32, char *); // eg. -3.3
|
|
|
|
void getParameterLabel(VstInt32, char *); // eg. dB
|
|
|
|
|
2014-02-03 15:00:17 -08:00
|
|
|
char programName[kVstMaxProgNameLen];
|
|
|
|
|
2015-06-07 20:56:06 -07:00
|
|
|
Param params[CrapPlug::parameters];
|
2013-11-17 19:32:45 -08:00
|
|
|
|
2015-06-07 20:56:06 -07:00
|
|
|
CrapPlug crap;
|
2013-11-17 19:32:45 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
AudioEffect *
|
2014-02-05 23:47:16 -08:00
|
|
|
createEffectInstance(audioMasterCallback audioMaster)
|
|
|
|
{
|
2013-11-17 19:32:45 -08:00
|
|
|
return new plugin(audioMaster);
|
|
|
|
}
|
|
|
|
|
|
|
|
plugin::plugin(audioMasterCallback audioMaster)
|
2015-06-07 20:56:06 -07:00
|
|
|
: AudioEffectX(audioMaster, 1, CrapPlug::parameters)
|
2013-11-17 19:32:45 -08:00
|
|
|
{
|
|
|
|
setNumInputs(2);
|
|
|
|
setNumOutputs(2);
|
2015-06-07 20:56:06 -07:00
|
|
|
setUniqueID(CrapPlug::id);
|
2013-11-17 19:32:45 -08:00
|
|
|
canProcessReplacing();
|
2014-02-03 15:00:17 -08:00
|
|
|
canDoubleReplacing();
|
|
|
|
vst_strncpy(programName, "Init", kVstMaxProgNameLen);
|
2015-06-07 20:56:06 -07:00
|
|
|
CrapPlug::construct_params(params);
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
plugin::~plugin()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::resume()
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
crap.resume();
|
2013-11-17 19:32:45 -08:00
|
|
|
AudioEffectX::resume();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::suspend()
|
|
|
|
{
|
2013-11-17 19:32:45 -08:00
|
|
|
AudioEffectX::suspend();
|
2015-06-07 20:56:06 -07:00
|
|
|
crap.pause();
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::processReplacing(
|
|
|
|
float **inputs, float **outputs, VstInt32 count)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
crap.process(
|
2013-11-17 19:32:45 -08:00
|
|
|
inputs[0], inputs[1],
|
|
|
|
outputs[0], outputs[1],
|
|
|
|
count);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::processDoubleReplacing(
|
|
|
|
double **inputs, double **outputs, VstInt32 count)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
crap.process(
|
2013-11-17 19:32:45 -08:00
|
|
|
inputs[0], inputs[1],
|
|
|
|
outputs[0], outputs[1],
|
|
|
|
count);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::setProcessPrecision(VstInt32 precision)
|
|
|
|
{
|
2014-01-29 17:55:11 -08:00
|
|
|
return true;
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::setSampleRate(float fs)
|
|
|
|
{
|
2013-11-17 19:32:45 -08:00
|
|
|
AudioEffectX::setSampleRate(fs);
|
2015-06-07 20:56:06 -07:00
|
|
|
crap.adjust(params, (unsigned long) fs);
|
2013-12-22 16:23:57 -08:00
|
|
|
#ifdef DELAY
|
|
|
|
setInitialDelay(global_delay);
|
|
|
|
#endif
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2014-02-05 23:47:16 -08:00
|
|
|
plugin::getEffectName(char *name)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
vst_strncpy(name, CrapPlug::label, kVstMaxEffectNameLen);
|
2014-01-29 17:55:11 -08:00
|
|
|
return true;
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
plugin::getProductString(char *text)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
vst_strncpy(text, CrapPlug::name, kVstMaxProductStrLen);
|
2014-01-29 17:55:11 -08:00
|
|
|
return true;
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
plugin::getVendorString(char *text)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
vst_strncpy(text, CrapPlug::author, kVstMaxVendorStrLen);
|
2014-01-29 17:55:11 -08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-02-03 15:00:17 -08:00
|
|
|
void
|
|
|
|
plugin::setProgramName (char *text)
|
|
|
|
{
|
|
|
|
vst_strncpy(programName, text, kVstMaxProgNameLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plugin::getProgramName (char *text)
|
|
|
|
{
|
|
|
|
vst_strncpy(text, programName, kVstMaxProgNameLen);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
plugin::getProgramNameIndexed(VstInt32 category, VstInt32 index, char *text)
|
|
|
|
{
|
|
|
|
if (index != 0) return false;
|
|
|
|
vst_strncpy(text, programName, kVstMaxProgNameLen);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-29 17:55:11 -08:00
|
|
|
void
|
|
|
|
plugin::setParameter(VstInt32 index, float value)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
if (index >= CrapPlug::parameters) return;
|
|
|
|
params[index].set(value);
|
|
|
|
crap.adjust_one(params, index);
|
2014-01-29 17:55:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
plugin::getParameter(VstInt32 index)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
if (index >= CrapPlug::parameters) return 0;
|
|
|
|
return params[index].get();
|
2014-01-29 17:55:11 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plugin::getParameterName(VstInt32 index, char *text)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
if (index >= CrapPlug::parameters) return;
|
2014-01-29 17:55:11 -08:00
|
|
|
vst_strncpy(text, params[index].name, MAX_PARAM_LEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plugin::getParameterDisplay(VstInt32 index, char *text)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
if (index >= CrapPlug::parameters) return;
|
2014-01-29 17:55:11 -08:00
|
|
|
|
2015-06-07 20:56:06 -07:00
|
|
|
Param *p = ¶ms[index];
|
2014-01-29 17:55:11 -08:00
|
|
|
char display[MAX_PARAM_LEN];
|
|
|
|
|
|
|
|
switch (p->scale) {
|
|
|
|
case SCALE_FLOAT:
|
|
|
|
case SCALE_LOG:
|
|
|
|
case SCALE_HZ:
|
|
|
|
case SCALE_DB:
|
|
|
|
sprintf(display, "%0.2f", p->value);
|
|
|
|
break;
|
|
|
|
case SCALE_INT:
|
|
|
|
sprintf(display, "%i", (int) p->value);
|
|
|
|
break;
|
|
|
|
case SCALE_TOGGLE:
|
2015-06-07 20:56:06 -07:00
|
|
|
sprintf(display, (p->get() < 0.5) ? "off" : "on");
|
2014-01-29 17:55:11 -08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(display, "error");
|
|
|
|
}
|
|
|
|
|
|
|
|
vst_strncpy(text, display, MAX_PARAM_LEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
plugin::getParameterLabel(VstInt32 index, char *text)
|
|
|
|
{
|
2015-06-07 20:56:06 -07:00
|
|
|
if (index >= CrapPlug::parameters) return;
|
2014-01-29 17:55:11 -08:00
|
|
|
|
2015-06-07 20:56:06 -07:00
|
|
|
Param *p = ¶ms[index];
|
2014-01-29 17:55:11 -08:00
|
|
|
char display[MAX_PARAM_LEN];
|
|
|
|
|
|
|
|
switch (p->scale) {
|
|
|
|
case SCALE_HZ:
|
|
|
|
sprintf(display, "Hz");
|
|
|
|
break;
|
|
|
|
case SCALE_DB:
|
|
|
|
sprintf(display, "dB");
|
|
|
|
break;
|
|
|
|
case SCALE_FLOAT:
|
|
|
|
case SCALE_INT:
|
|
|
|
case SCALE_TOGGLE:
|
|
|
|
case SCALE_LOG:
|
|
|
|
display[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
vst_strncpy(text, display, MAX_PARAM_LEN);
|
2013-11-17 19:32:45 -08:00
|
|
|
}
|