mirror of
https://github.com/vsariola/sointu.git
synced 2025-07-22 23:14:59 -04:00
retro commit for released version 3.0.1
This commit is contained in:
44
4klang_source/Go4kVSTi/source/common/AEffEditor.hpp
Normal file
44
4klang_source/Go4kVSTi/source/common/AEffEditor.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __AEffEditor__
|
||||
#define __AEffEditor__
|
||||
|
||||
class AudioEffect;
|
||||
|
||||
struct ERect
|
||||
{
|
||||
short top;
|
||||
short left;
|
||||
short bottom;
|
||||
short right;
|
||||
};
|
||||
|
||||
class AEffEditor
|
||||
{
|
||||
public:
|
||||
AEffEditor (AudioEffect *effect) {this->effect = effect; updateFlag = 0; }
|
||||
virtual ~AEffEditor() {}
|
||||
|
||||
virtual long getRect(ERect **rect) {*rect = 0; return 0;}
|
||||
virtual long open(void *ptr) {systemWindow = ptr; return 0;}
|
||||
virtual void close() {}
|
||||
virtual void idle() { if(updateFlag) {updateFlag = 0; update();} }
|
||||
|
||||
#if MAC
|
||||
virtual void draw(ERect *rect) {rect = rect;}
|
||||
virtual long mouse(long x, long y) {x = x; y = y; return 0;}
|
||||
virtual long key(long keyCode) {keyCode = keyCode; return 0;}
|
||||
virtual void top() {}
|
||||
virtual void sleep() {}
|
||||
#endif
|
||||
virtual void update() {}
|
||||
virtual void postUpdate() {updateFlag = 1;}
|
||||
|
||||
protected:
|
||||
AEffEditor () {};
|
||||
|
||||
AudioEffect *effect;
|
||||
void *systemWindow;
|
||||
long updateFlag;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
172
4klang_source/Go4kVSTi/source/common/AEffect.h
Normal file
172
4klang_source/Go4kVSTi/source/common/AEffect.h
Normal file
@ -0,0 +1,172 @@
|
||||
#ifndef __AEffect__
|
||||
#define __AEffect__
|
||||
|
||||
/*
|
||||
to create an Audio Effect for power pc's, create a
|
||||
code resource
|
||||
file type: 'aPcs'
|
||||
resource type: 'aEff'
|
||||
ppc header: none (raw pef)
|
||||
|
||||
for windows, it's a .dll
|
||||
|
||||
the only symbol searched for is:
|
||||
AEffect *main(float (*audioMaster)(AEffect *effect, long opcode, long index,
|
||||
long value, void *ptr, float opt));
|
||||
*/
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED || __MWERKS__
|
||||
#pragma options align=mac68k
|
||||
#elif defined CBUILDER
|
||||
#pragma -a8
|
||||
#elif defined(WIN32) || defined(__FLAT__)
|
||||
#pragma pack(push)
|
||||
#pragma pack(8)
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(__FLAT__) || defined CBUILDER
|
||||
#define VSTCALLBACK __cdecl
|
||||
#else
|
||||
#define VSTCALLBACK
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// misc def's
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct AEffect AEffect;
|
||||
typedef long (VSTCALLBACK *audioMasterCallback)(AEffect *effect, long opcode, long index,
|
||||
long value, void *ptr, float opt);
|
||||
|
||||
// prototype for plug-in main
|
||||
// AEffect *main(audioMasterCallback audioMaster);
|
||||
|
||||
#ifdef CBUILDER
|
||||
#define kEffectMagic 'PtsV'
|
||||
#else
|
||||
#define kEffectMagic 'VstP'
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
struct AEffect
|
||||
{
|
||||
long magic; // must be kEffectMagic ('VstP')
|
||||
long (VSTCALLBACK *dispatcher)(AEffect *effect, long opCode, long index, long value,
|
||||
void *ptr, float opt);
|
||||
void (VSTCALLBACK *process)(AEffect *effect, float **inputs, float **outputs, long sampleframes);
|
||||
void (VSTCALLBACK *setParameter)(AEffect *effect, long index, float parameter);
|
||||
float (VSTCALLBACK *getParameter)(AEffect *effect, long index);
|
||||
|
||||
long numPrograms;
|
||||
long numParams; // all programs are assumed to have numParams parameters
|
||||
long numInputs; //
|
||||
long numOutputs; //
|
||||
long flags; // see constants
|
||||
long resvd1; // reserved, must be 0
|
||||
long resvd2; // reserved, must be 0
|
||||
long initialDelay; // for algorithms which need input in the first place
|
||||
long realQualities; // number of realtime qualities (0: realtime)
|
||||
long offQualities; // number of offline qualities (0: realtime only)
|
||||
float ioRatio; // input samplerate to output samplerate ratio, not used yet
|
||||
void *object; // for class access (see AudioEffect.hpp), MUST be 0 else!
|
||||
void *user; // user access
|
||||
long uniqueID; // pls choose 4 character as unique as possible.
|
||||
// this is used to identify an effect for save+load
|
||||
long version; //
|
||||
void (VSTCALLBACK *processReplacing)(AEffect *effect, float **inputs, float **outputs, long sampleframes);
|
||||
char future[60]; // pls zero
|
||||
};
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// flags bits
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
#define effFlagsHasEditor 1 // if set, is expected to react to editor messages
|
||||
#define effFlagsHasClip 2 // return > 1. in getVu() if clipped
|
||||
#define effFlagsHasVu 4 // return vu value in getVu(); > 1. means clipped
|
||||
#define effFlagsCanMono 8 // if numInputs == 2, makes sense to be used for mono in
|
||||
#define effFlagsCanReplacing 16 // supports in place output (processReplacing() exsists)
|
||||
#define effFlagsProgramChunks 32 // program data are handled in formatless chunks
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// dispatcher opCodes
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
effOpen = 0, // initialise
|
||||
effClose, // exit, release all memory and other resources!
|
||||
|
||||
effSetProgram, // program no in <value>
|
||||
effGetProgram, // return current program no.
|
||||
effSetProgramName, // user changed program name (max 24 char + 0) to as passed in string
|
||||
effGetProgramName, // stuff program name (max 24 char + 0) into string
|
||||
|
||||
effGetParamLabel, // stuff parameter <index> label (max 8 char + 0) into string
|
||||
// (examples: sec, dB, type)
|
||||
effGetParamDisplay, // stuff parameter <index> textual representation into string
|
||||
// (examples: 0.5, -3, PLATE)
|
||||
effGetParamName, // stuff parameter <index> label (max 8 char + 0) into string
|
||||
// (examples: Time, Gain, RoomType)
|
||||
effGetVu, // called if (flags & (effFlagsHasClip | effFlagsHasVu))
|
||||
|
||||
// system
|
||||
|
||||
effSetSampleRate, // in opt (float)
|
||||
effSetBlockSize, // in value
|
||||
effMainsChanged, // the user has switched the 'power on' button to
|
||||
// value (0 off, else on). This only switches audio
|
||||
// processing; you should flush delay buffers etc.
|
||||
// editor
|
||||
|
||||
effEditGetRect, // stuff rect (top, left, bottom, right) into ptr
|
||||
effEditOpen, // system dependant Window pointer in ptr
|
||||
effEditClose, // no arguments
|
||||
effEditDraw, // draw method, ptr points to rect
|
||||
effEditMouse, // index: x, value: y
|
||||
effEditKey, // system keycode in value
|
||||
effEditIdle, // no arguments. Be gentle!
|
||||
effEditTop, // window has topped, no arguments
|
||||
effEditSleep, // window goes to background
|
||||
|
||||
// new
|
||||
|
||||
effIdentify, // returns 'NvEf'
|
||||
effGetChunk, // host requests pointer to chunk into (void**)ptr, byteSize returned
|
||||
effSetChunk, // plug-in receives saved chunk, byteSize passed
|
||||
|
||||
effNumOpcodes
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// audioMaster opCodes
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
audioMasterAutomate = 0, // index, value, returns 0
|
||||
audioMasterVersion, // vst version, currently 2 (0 for older)
|
||||
audioMasterCurrentId, // returns the unique id of a plug that's currently
|
||||
// loading
|
||||
audioMasterIdle, // call application idle routine (this will
|
||||
// call effEditIdle for all open editors too)
|
||||
audioMasterPinConnected // inquire if an input or output is beeing connected;
|
||||
// index enumerates input or output counting from zero,
|
||||
// value is 0 for input and != 0 otherwise. note: the
|
||||
// return value is 0 for <true> such that older versions
|
||||
// will always return true.
|
||||
|
||||
};
|
||||
|
||||
#if PRAGMA_ALIGN_SUPPORTED || __MWERKS__
|
||||
#pragma options align=reset
|
||||
#elif defined(WIN32) || defined(__FLAT__)
|
||||
#pragma pack(pop)
|
||||
#elif defined CBUILDER
|
||||
#pragma -a-
|
||||
#endif
|
||||
|
||||
#endif // __AEffect__
|
382
4klang_source/Go4kVSTi/source/common/AudioEffect.cpp
Normal file
382
4klang_source/Go4kVSTi/source/common/AudioEffect.cpp
Normal file
@ -0,0 +1,382 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "AudioEffect.hpp"
|
||||
#include "AEffEditor.hpp"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
long dispatchEffectClass (AEffect *e, long opCode,
|
||||
long index, long value, void *ptr, float opt)
|
||||
{
|
||||
AudioEffect *ae = (AudioEffect *)(e->object);
|
||||
|
||||
if(opCode == effClose)
|
||||
{
|
||||
ae->dispatcher(opCode, index, value, ptr, opt);
|
||||
delete ae;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return ae->dispatcher(opCode, index, value, ptr, opt);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
float getParameterClass(AEffect *e, long index)
|
||||
{
|
||||
AudioEffect *ae = (AudioEffect *)(e->object);
|
||||
return ae->getParameter(index);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void setParameterClass(AEffect *e, long index, float value)
|
||||
{
|
||||
AudioEffect *ae = (AudioEffect *)(e->object);
|
||||
ae->setParameter(index, value);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void processClass(AEffect *e, float **inputs, float **outputs, long sampleFrames)
|
||||
{
|
||||
AudioEffect *ae = (AudioEffect *)(e->object);
|
||||
ae->process(inputs, outputs, sampleFrames);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void processClassReplacing(AEffect *e, float **inputs, float **outputs, long sampleFrames)
|
||||
{
|
||||
AudioEffect *ae = (AudioEffect *)(e->object);
|
||||
ae->processReplacing(inputs, outputs, sampleFrames);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
AudioEffect::AudioEffect(audioMasterCallback audioMaster, long numPrograms, long numParams)
|
||||
{
|
||||
this->audioMaster = audioMaster;
|
||||
editor = 0;
|
||||
this->numPrograms = numPrograms;
|
||||
this->numParams = numParams;
|
||||
curProgram = 0;
|
||||
|
||||
memset(&cEffect, 0, sizeof(cEffect));
|
||||
cEffect.magic = kEffectMagic;
|
||||
cEffect.dispatcher = dispatchEffectClass;
|
||||
cEffect.process = processClass;
|
||||
cEffect.setParameter = setParameterClass;
|
||||
cEffect.getParameter = getParameterClass;
|
||||
cEffect.numPrograms = numPrograms;
|
||||
cEffect.numParams = numParams;
|
||||
cEffect.numInputs = 1;
|
||||
cEffect.numOutputs = 2;
|
||||
cEffect.flags = 0;
|
||||
cEffect.resvd1 = 0;
|
||||
cEffect.resvd2 = 0;
|
||||
cEffect.initialDelay = 0;
|
||||
cEffect.realQualities = 0;
|
||||
cEffect.offQualities = 0;
|
||||
cEffect.ioRatio = 1.f;
|
||||
cEffect.object = this;
|
||||
cEffect.user = 0;
|
||||
cEffect.uniqueID = 'NoEf'; // you must set this!
|
||||
cEffect.version = 1;
|
||||
cEffect.processReplacing = processClassReplacing;
|
||||
|
||||
sampleRate = 44100.f;
|
||||
blockSize = 1024L;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
AudioEffect::~AudioEffect()
|
||||
{
|
||||
if(editor)
|
||||
delete editor;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
long AudioEffect::dispatcher(long opCode, long index, long value, void *ptr, float opt)
|
||||
{
|
||||
long v = 0;
|
||||
|
||||
switch(opCode)
|
||||
{
|
||||
case effOpen: open(); break;
|
||||
case effClose: close(); break;
|
||||
case effSetProgram: if(value < numPrograms) setProgram(value); break;
|
||||
case effGetProgram: v = getProgram(); break;
|
||||
case effSetProgramName: setProgramName((char *)ptr); break;
|
||||
case effGetProgramName: getProgramName((char *)ptr); break;
|
||||
case effGetParamLabel: getParameterLabel(index, (char *)ptr); break;
|
||||
case effGetParamDisplay: getParameterDisplay(index, (char *)ptr); break;
|
||||
case effGetParamName: getParameterName(index, (char *)ptr); break;
|
||||
|
||||
case effSetSampleRate: setSampleRate(opt); break;
|
||||
case effSetBlockSize: setBlockSize(value); break;
|
||||
case effMainsChanged: if(!value) suspend(); else resume(); break;
|
||||
case effGetVu: v = (long)(getVu() * 32767.); break;
|
||||
|
||||
// editor
|
||||
|
||||
case effEditGetRect: if(editor) v = editor->getRect((ERect **)ptr); break;
|
||||
case effEditOpen: if(editor) v = editor->open(ptr); break;
|
||||
case effEditClose: if(editor) editor->close(); break;
|
||||
case effEditIdle: if(editor) editor->idle(); break;
|
||||
|
||||
#if MAC
|
||||
case effEditDraw: if(editor) editor->draw((ERect *)ptr); break;
|
||||
case effEditMouse: if(editor) v = editor->mouse(index, value); break;
|
||||
case effEditKey: if(editor) v = editor->key(value); break;
|
||||
case effEditTop: if(editor) editor->top(); break;
|
||||
case effEditSleep: if(editor) editor->sleep(); break;
|
||||
#endif
|
||||
|
||||
// new
|
||||
|
||||
case effIdentify: v = 'NvEf'; break;
|
||||
case effGetChunk: v = getChunk((void**)ptr, index ? true : false); break;
|
||||
case effSetChunk: v = setChunk(ptr, value, index ? true : false); break;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
long AudioEffect::getMasterVersion()
|
||||
{
|
||||
long version = 1;
|
||||
if(audioMaster)
|
||||
{
|
||||
version = audioMaster(&cEffect, audioMasterVersion, 0, 0, 0, 0);
|
||||
if(!version) // old
|
||||
version = 1;
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
long AudioEffect::getCurrentUniqueId()
|
||||
{
|
||||
long id = 0;
|
||||
if(audioMaster)
|
||||
id = audioMaster(&cEffect, audioMasterCurrentId, 0, 0, 0, 0);
|
||||
return id;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::masterIdle()
|
||||
{
|
||||
if(audioMaster)
|
||||
audioMaster(&cEffect, audioMasterIdle, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool AudioEffect::isInputConnected(long input)
|
||||
{
|
||||
long ret = 0;
|
||||
if(audioMaster)
|
||||
ret = audioMaster(&cEffect, audioMasterPinConnected, input, 0, 0, 0);
|
||||
return ret ? false : true; // return value is 0 for true
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool AudioEffect::isOutputConnected(long output)
|
||||
{
|
||||
long ret = 0;
|
||||
if(audioMaster)
|
||||
ret = audioMaster(&cEffect, audioMasterPinConnected, output, 1, 0, 0);
|
||||
return ret ? false : true; // return value is 0 for true
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// flags
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::hasVu(bool state)
|
||||
{
|
||||
if(state)
|
||||
cEffect.flags |= effFlagsHasVu;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsHasVu;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::hasClip(bool state)
|
||||
{
|
||||
if(state)
|
||||
cEffect.flags |= effFlagsHasClip;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsHasClip;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::canMono(bool state)
|
||||
{
|
||||
if(state)
|
||||
cEffect.flags |= effFlagsCanMono;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsCanMono;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::canProcessReplacing(bool state)
|
||||
{
|
||||
if(state)
|
||||
cEffect.flags |= effFlagsCanReplacing;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsCanReplacing;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::programsAreChunks(bool state)
|
||||
{
|
||||
if(state)
|
||||
cEffect.flags |= effFlagsProgramChunks;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsProgramChunks;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::setRealtimeQualities(long qualities)
|
||||
{
|
||||
cEffect.realQualities = qualities;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::setOfflineQualities(long qualities)
|
||||
{
|
||||
cEffect.offQualities = qualities;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::setInitialDelay(long delay)
|
||||
{
|
||||
cEffect.initialDelay = delay;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// string
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::dB2string(float value, char *text)
|
||||
{
|
||||
if(value <= 0)
|
||||
#if MAC
|
||||
strcpy(text, " -<2D> ");
|
||||
#else
|
||||
strcpy(text, " -oo ");
|
||||
#endif
|
||||
else
|
||||
float2string((float)(20. * log10(value)), text);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::Hz2string(float samples, char *text)
|
||||
{
|
||||
float sampleRate = getSampleRate();
|
||||
if(!samples)
|
||||
float2string(0, text);
|
||||
else
|
||||
float2string(sampleRate / samples, text);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::ms2string(float samples, char *text)
|
||||
{
|
||||
float2string((float)(samples * 1000. / getSampleRate()), text);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::float2string(float value, char *text)
|
||||
{
|
||||
long c = 0, neg = 0;
|
||||
char string[32];
|
||||
char *s;
|
||||
double v, integ, i10, mantissa, m10, ten = 10.;
|
||||
|
||||
v = (double)value;
|
||||
if(v < 0)
|
||||
{
|
||||
neg = 1;
|
||||
value = -value;
|
||||
v = -v;
|
||||
c++;
|
||||
if(v > 9999999.)
|
||||
{
|
||||
strcpy(string, " Huge! ");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(v > 99999999.)
|
||||
{
|
||||
strcpy(string, " Huge! ");
|
||||
return;
|
||||
}
|
||||
|
||||
s = string + 31;
|
||||
*s-- = 0;
|
||||
*s-- = '.';
|
||||
c++;
|
||||
|
||||
integ = floor(v);
|
||||
i10 = fmod(integ, ten);
|
||||
*s-- = (long)i10 + '0';
|
||||
integ /= ten;
|
||||
c++;
|
||||
while(integ >= 1. && c < 8)
|
||||
{
|
||||
i10 = fmod(integ, ten);
|
||||
*s-- = (long)i10 + '0';
|
||||
integ /= ten;
|
||||
c++;
|
||||
}
|
||||
if(neg)
|
||||
*s-- = '-';
|
||||
strcpy(text, s + 1);
|
||||
if(c >= 8)
|
||||
return;
|
||||
|
||||
s = string + 31;
|
||||
*s-- = 0;
|
||||
mantissa = fmod(v, 1.);
|
||||
mantissa *= pow(ten, (double)(8 - c));
|
||||
while(c < 8)
|
||||
{
|
||||
if(mantissa <= 0)
|
||||
*s-- = '0';
|
||||
else
|
||||
{
|
||||
m10 = fmod(mantissa, ten);
|
||||
*s-- = (long)m10 + '0';
|
||||
mantissa /= 10.;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
strcat(text, s + 1);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::long2string(long value, char *text)
|
||||
{
|
||||
char string[32];
|
||||
|
||||
if(value >= 100000000)
|
||||
{
|
||||
strcpy(text, " Huge! ");
|
||||
return;
|
||||
}
|
||||
sprintf(string, "%7d", value);
|
||||
string[8] = 0;
|
||||
strcpy(text, (char *)string);
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void AudioEffect::setParameterAutomated(long index, float value)
|
||||
{
|
||||
setParameter(index, value);
|
||||
if(audioMaster)
|
||||
audioMaster(&cEffect, audioMasterAutomate, index, 0, 0, value); // value is in opt
|
||||
}
|
||||
|
109
4klang_source/Go4kVSTi/source/common/AudioEffect.hpp
Normal file
109
4klang_source/Go4kVSTi/source/common/AudioEffect.hpp
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef __AudioEffect__
|
||||
#define __AudioEffect__
|
||||
|
||||
#include "AEffect.h" // "c" interface
|
||||
#include <string.h>
|
||||
|
||||
class AEffEditor;
|
||||
class AudioEffect;
|
||||
|
||||
// Needs to be defined by the audio effect and is
|
||||
// called to create the audio effect object instance.
|
||||
AudioEffect* createEffectInstance (audioMasterCallback audioMaster);
|
||||
|
||||
long dispatchEffectClass(AEffect *e,
|
||||
long opCode, long index, long value, void *ptr, float opt);
|
||||
float getParameterClass(long index);
|
||||
void setParameterClass(long index, float value);
|
||||
void processClass(AEffect *e, float **inputs, float **outputs, long sampleFrames);
|
||||
void processClassReplacing(AEffect *e, float **inputs, float **outputs, long sampleFrames);
|
||||
|
||||
class AudioEffect
|
||||
{
|
||||
friend class AEffEditor;
|
||||
friend long dispatchEffectClass(AEffect *e, long opCode, long index, long value, void *ptr, float opt);
|
||||
friend float getParameterClass(AEffect *e, long index);
|
||||
friend void setParameterClass(AEffect *e, long index, float value);
|
||||
friend void processClass(AEffect *e, float **inputs, float **outputs, long sampleFrames);
|
||||
friend void processClassReplacing(AEffect *e, float **inputs, float **outputs, long sampleFrames);
|
||||
|
||||
public:
|
||||
AudioEffect(audioMasterCallback audioMaster, long numPrograms, long numParams);
|
||||
virtual ~AudioEffect();
|
||||
|
||||
virtual void setParameter(long index, float value) {index = index; value = value;}
|
||||
virtual float getParameter(long index) {index = index; return 0;}
|
||||
virtual void setParameterAutomated(long index, float value);
|
||||
|
||||
AEffect *getAeffect() {return &cEffect;}
|
||||
void setEditor(AEffEditor *editor)
|
||||
{ this->editor = editor;
|
||||
if(editor) cEffect.flags |= effFlagsHasEditor;
|
||||
else cEffect.flags &= ~effFlagsHasEditor;}
|
||||
|
||||
// called from audio master
|
||||
virtual void process(float **inputs, float **outputs, long sampleFrames) = 0;
|
||||
virtual void processReplacing(float **inputs, float **outputs, long sampleFrames)
|
||||
{inputs = inputs; outputs = outputs; sampleFrames = sampleFrames;}
|
||||
virtual long dispatcher(long opCode, long index, long value, void *ptr, float opt);
|
||||
virtual void open() {}
|
||||
virtual void close() {}
|
||||
virtual long getProgram() {return curProgram;}
|
||||
virtual void setProgram(long program) {curProgram = program;} // don't forget to set curProgram
|
||||
virtual void setProgramName(char *name) {*name = 0;} // all following refer to curProgram
|
||||
virtual void getProgramName(char *name) {*name = 0;}
|
||||
virtual void getParameterLabel(long index, char *label) {index = index; *label = 0;}
|
||||
virtual void getParameterDisplay(long index, char *text) {index = index; *text = 0;}
|
||||
virtual void getParameterName(long index, char *text) {index = index; *text = 0;}
|
||||
virtual float getVu() {return 0;}
|
||||
virtual long getChunk(void** data, bool isPreset = false) {return 0;} // returns byteSize
|
||||
virtual long setChunk(void* data, long byteSize, bool isPreset = false) {return 0;}
|
||||
virtual void setSampleRate(float sampleRate) {this->sampleRate = sampleRate;}
|
||||
virtual void setBlockSize(long blockSize) {this->blockSize = blockSize;}
|
||||
virtual void suspend() {}
|
||||
virtual void resume() {}
|
||||
|
||||
// setup
|
||||
virtual void setUniqueID(long iD) {cEffect.uniqueID = iD;} // must call this!
|
||||
virtual void setNumInputs(long inputs) {cEffect.numInputs = inputs;}
|
||||
virtual void setNumOutputs(long outputs) {cEffect.numOutputs = outputs;}
|
||||
virtual void hasVu(bool state = true);
|
||||
virtual void hasClip(bool state = true);
|
||||
virtual void canMono(bool state = true);
|
||||
virtual void canProcessReplacing(bool state = true);
|
||||
virtual void programsAreChunks(bool state = true);
|
||||
virtual void setRealtimeQualities(long qualities);
|
||||
virtual void setOfflineQualities(long qualities);
|
||||
virtual void setInitialDelay(long delay);
|
||||
|
||||
// inquiry
|
||||
virtual float getSampleRate() {return sampleRate;}
|
||||
virtual long getBlockSize() {return blockSize;}
|
||||
|
||||
// host communication
|
||||
virtual long getMasterVersion();
|
||||
virtual long getCurrentUniqueId();
|
||||
virtual void masterIdle();
|
||||
virtual bool isInputConnected(long input);
|
||||
virtual bool isOutputConnected(long output);
|
||||
|
||||
// tools
|
||||
virtual void dB2string(float value, char *text);
|
||||
virtual void Hz2string(float samples, char *text);
|
||||
virtual void ms2string(float samples, char *text);
|
||||
virtual void float2string(float value, char *string);
|
||||
virtual void long2string(long value, char *text);
|
||||
|
||||
protected:
|
||||
// members
|
||||
float sampleRate;
|
||||
AEffEditor *editor;
|
||||
audioMasterCallback audioMaster;
|
||||
long numPrograms;
|
||||
long numParams;
|
||||
long curProgram;
|
||||
long blockSize;
|
||||
AEffect cEffect;
|
||||
};
|
||||
|
||||
#endif
|
534
4klang_source/Go4kVSTi/source/common/aeffectx.h
Normal file
534
4klang_source/Go4kVSTi/source/common/aeffectx.h
Normal file
@ -0,0 +1,534 @@
|
||||
#ifndef __aeffectx__
|
||||
#define __aeffectx__
|
||||
|
||||
#ifndef __AEffect__
|
||||
#include "AEffect.h"
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// VST Plug-Ins SDK
|
||||
// version 2.0 extension
|
||||
// (c)1999 Steinberg Soft+Hardware GmbH
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// VstEvent
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct VstEvent VstEvent;
|
||||
typedef struct VstMidiEvent VstMidiEvent;
|
||||
typedef struct VstEvents VstEvents;
|
||||
|
||||
struct VstEvent // a generic timestamped event
|
||||
{
|
||||
long type; // see enum below
|
||||
long byteSize; // of this event, excl. type and byteSize
|
||||
long deltaFrames; // sample frames related to the current block start sample position
|
||||
long flags; // generic flags, none defined yet (0)
|
||||
|
||||
char data[16]; // size may vary but is usually 16
|
||||
};
|
||||
|
||||
enum // VstEvent types
|
||||
{
|
||||
kVstMidiType = 1, // midi event, can be cast as VstMidiEvent (see below)
|
||||
kVstAudioType, // audio
|
||||
kVstVideoType, // video
|
||||
kVstParameterType, // parameter
|
||||
kVstTriggerType // trigger
|
||||
// ...etc
|
||||
};
|
||||
|
||||
struct VstMidiEvent // to be casted from a VstEvent
|
||||
{
|
||||
long type; // kVstMidiType
|
||||
long byteSize; // 24
|
||||
long deltaFrames; // sample frames related to the current block start sample position
|
||||
long flags; // none defined yet
|
||||
|
||||
long noteLength; // (in sample frames) of entire note, if available, else 0
|
||||
long noteOffset; // offset into note from note start if available, else 0
|
||||
|
||||
char midiData[4]; // 1 thru 3 midi bytes; midiData[3] is reserved (zero)
|
||||
char detune; // -64 to +63 cents; for scales other than 'well-tempered' ('microtuning')
|
||||
char noteOffVelocity;
|
||||
char reserved1; // zero
|
||||
char reserved2; // zero
|
||||
};
|
||||
|
||||
struct VstEvents // a block of events for the current audio block
|
||||
{
|
||||
long numEvents;
|
||||
long reserved; // zero
|
||||
VstEvent* events[2]; // variable
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// VstTimeInfo
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct VstTimeInfo VstTimeInfo;
|
||||
|
||||
// VstTimeInfo as requested via audioMasterGetTime (getTimeInfo())
|
||||
// refers to the current time slice. note the new slice is
|
||||
// already started when processEvents() is called
|
||||
|
||||
struct VstTimeInfo
|
||||
{
|
||||
double samplePos; // current location
|
||||
double sampleRate;
|
||||
double nanoSeconds; // system time
|
||||
double ppqPos; // 1 ppq
|
||||
double tempo; // in bpm
|
||||
double barStartPos; // last bar start, in 1 ppq
|
||||
double cycleStartPos; // 1 ppq
|
||||
double cycleEndPos; // 1 ppq
|
||||
long timeSigNumerator; // time signature
|
||||
long timeSigDenominator;
|
||||
long smpteOffset;
|
||||
long smpteFrameRate; // 0:24, 1:25, 2:29.97, 3:30, 4:29.97 df, 5:30 df
|
||||
long samplesToNextClock; // midi clock resolution (24 ppq), can be negative
|
||||
long flags; // see below
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
kVstTransportChanged = 1,
|
||||
kVstTransportPlaying = 1 << 1,
|
||||
kVstTransportCycleActive = 1 << 2,
|
||||
|
||||
kVstAutomationWriting = 1 << 6,
|
||||
kVstAutomationReading = 1 << 7,
|
||||
|
||||
// flags which indicate which of the fields in this VstTimeInfo
|
||||
// are valid; samplePos and sampleRate are always valid
|
||||
kVstNanosValid = 1 << 8,
|
||||
kVstPpqPosValid = 1 << 9,
|
||||
kVstTempoValid = 1 << 10,
|
||||
kVstBarsValid = 1 << 11,
|
||||
kVstCyclePosValid = 1 << 12, // start and end
|
||||
kVstTimeSigValid = 1 << 13,
|
||||
kVstSmpteValid = 1 << 14,
|
||||
kVstClockValid = 1 << 15
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// VarIo
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct VstVariableIo VstVariableIo;
|
||||
|
||||
struct VstVariableIo
|
||||
{
|
||||
float **inputs;
|
||||
float **outputs;
|
||||
long numSamplesInput;
|
||||
long numSamplesOutput;
|
||||
long *numSamplesInputProcessed;
|
||||
long *numSamplesOutputProcessed;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// new audioMaster opCodes
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
// VstEvents + VstTimeInfo
|
||||
audioMasterWantMidi = audioMasterPinConnected + 2, // <value> is a filter which is currently ignored
|
||||
audioMasterGetTime, // returns const VstTimeInfo* (or 0 if not supported)
|
||||
// <value> should contain a mask indicating which fields are required
|
||||
// (see valid masks above), as some items may require extensive
|
||||
// conversions
|
||||
audioMasterProcessEvents, // VstEvents* in <ptr>
|
||||
audioMasterSetTime, // VstTimenfo* in <ptr>, filter in <value>, not supported
|
||||
audioMasterTempoAt, // returns tempo (in bpm * 10000) at sample frame location passed in <value>
|
||||
|
||||
// parameters
|
||||
audioMasterGetNumAutomatableParameters,
|
||||
audioMasterGetParameterQuantization, // returns the integer value for +1.0 representation,
|
||||
// or 1 if full single float precision is maintained
|
||||
// in automation. parameter index in <value> (-1: all, any)
|
||||
// connections, configuration
|
||||
audioMasterIOChanged, // numInputs and/or numOutputs has changed
|
||||
audioMasterNeedIdle, // plug needs idle calls (outside its editor window)
|
||||
audioMasterSizeWindow, // index: width, value: height
|
||||
audioMasterGetSampleRate,
|
||||
audioMasterGetBlockSize,
|
||||
audioMasterGetInputLatency,
|
||||
audioMasterGetOutputLatency,
|
||||
audioMasterGetPreviousPlug, // input pin in <value> (-1: first to come), returns cEffect*
|
||||
audioMasterGetNextPlug, // output pin in <value> (-1: first to come), returns cEffect*
|
||||
|
||||
// realtime info
|
||||
audioMasterWillReplaceOrAccumulate, // returns: 0: not supported, 1: replace, 2: accumulate
|
||||
audioMasterGetCurrentProcessLevel, // returns: 0: not supported,
|
||||
// 1: currently in user thread (gui)
|
||||
// 2: currently in audio thread (where process is called)
|
||||
// 3: currently in 'sequencer' thread (midi, timer etc)
|
||||
// 4: currently offline processing and thus in user thread
|
||||
// other: not defined, but probably pre-empting user thread.
|
||||
audioMasterGetAutomationState, // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write
|
||||
|
||||
// offline
|
||||
audioMasterOfflineStart,
|
||||
audioMasterOfflineRead, // ptr points to offline structure, see below. return 0: error, 1 ok
|
||||
audioMasterOfflineWrite, // same as read
|
||||
audioMasterOfflineGetCurrentPass,
|
||||
audioMasterOfflineGetCurrentMetaPass,
|
||||
|
||||
// other
|
||||
audioMasterSetOutputSampleRate, // for variable i/o, sample rate in <opt>
|
||||
audioMasterGetSpeakerArrangement, // (long)input in <value>, output in <ptr>
|
||||
audioMasterGetVendorString, // fills <ptr> with a string identifying the vendor (max 64 char)
|
||||
audioMasterGetProductString, // fills <ptr> with a string with product name (max 64 char)
|
||||
audioMasterGetVendorVersion, // returns vendor-specific version
|
||||
audioMasterVendorSpecific, // no definition, vendor specific handling
|
||||
audioMasterSetIcon, // void* in <ptr>, format not defined yet
|
||||
audioMasterCanDo, // string in ptr, see below
|
||||
audioMasterGetLanguage, // see enum
|
||||
audioMasterOpenWindow, // returns platform specific ptr
|
||||
audioMasterCloseWindow, // close window, platform specific handle in <ptr>
|
||||
audioMasterGetDirectory, // get plug directory, FSSpec on MAC, else char*
|
||||
audioMasterUpdateDisplay // something has changed, update 'multi-fx' display
|
||||
};
|
||||
|
||||
enum VstHostLanguage
|
||||
{
|
||||
kVstLangEnglish = 1,
|
||||
kVstLangGerman,
|
||||
kVstLangFrench,
|
||||
kVstLangItalian,
|
||||
kVstLangSpanish,
|
||||
kVstLangJapanese
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// dispatcher opCodes
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
// VstEvents
|
||||
effProcessEvents = effSetChunk + 1, // VstEvents* in <ptr>
|
||||
|
||||
// parameters and programs
|
||||
effCanBeAutomated, // parameter index in <index>
|
||||
effString2Parameter, // parameter index in <index>, string in <ptr>
|
||||
effGetNumProgramCategories, // no arguments. this is for dividing programs into groups (like GM)
|
||||
effGetProgramNameIndexed, // get program name of category <value>, program <index> into <ptr>.
|
||||
// category (that is, <value>) may be -1, in which case program indices
|
||||
// are enumerated linearily (as usual); otherwise, each category starts
|
||||
// over with index 0.
|
||||
effCopyProgram, // copy current program to destination <index>
|
||||
// note: implies setParameter
|
||||
// connections, configuration
|
||||
effConnectInput, // input at <index> has been (dis-)connected;
|
||||
// <value> == 0: disconnected, else connected
|
||||
effConnectOutput, // same as input
|
||||
effGetInputProperties, // <index>, VstPinProperties* in ptr, return != 0 => true
|
||||
effGetOutputProperties, // dto
|
||||
effGetPlugCategory, // no parameter, return value is category
|
||||
|
||||
// realtime
|
||||
effGetCurrentPosition, // for external dsp, see flag bits below
|
||||
effGetDestinationBuffer, // for external dsp, see flag bits below. returns float*
|
||||
|
||||
// offline
|
||||
effOfflineNotify, // ptr = VstAudioFile array, value = count, index = start flag
|
||||
effOfflinePrepare, // ptr = VstOfflineTask array, value = count
|
||||
effOfflineRun, // dto
|
||||
|
||||
// other
|
||||
effProcessVarIo, // VstVariableIo* in <ptr>
|
||||
effSetSpeakerArrangement, // VstSpeakerArrangement* pluginInput in <value>
|
||||
// VstSpeakerArrangement* pluginOutput in <ptr>
|
||||
effSetBlockSizeAndSampleRate, // block size in <value>, sampleRate in <opt>
|
||||
effSetBypass, // onOff in <value> (0 = off)
|
||||
effGetEffectName, // char* name (max 32 bytes) in <ptr>
|
||||
effGetErrorText, // char* text (max 256 bytes) in <ptr>
|
||||
effGetVendorString, // fills <ptr> with a string identifying the vendor (max 64 char)
|
||||
effGetProductString, // fills <ptr> with a string with product name (max 64 char)
|
||||
effGetVendorVersion, // returns vendor-specific version
|
||||
effVendorSpecific, // no definition, vendor specific handling
|
||||
effCanDo, // <ptr>
|
||||
effGetTailSize, // returns tail size; 0 is default (return 1 for 'no tail')
|
||||
effIdle, // idle call in response to audioMasterneedIdle. must
|
||||
// return 1 to keep idle calls beeing issued
|
||||
|
||||
// gui
|
||||
effGetIcon, // void* in <ptr>, not yet defined
|
||||
effSetViewPosition, // set view position (in window) to x <index> y <value>
|
||||
|
||||
// and...
|
||||
effGetParameterProperties, // of param <index>, VstParameterProperties* in <ptr>
|
||||
effKeysRequired, // returns 0: needs keys (default for 1.0 plugs), 1: don't need
|
||||
effGetVstVersion, // returns 2; older versions return 0
|
||||
|
||||
effNumV2Opcodes
|
||||
// note that effNumOpcodes doesn't apply anymore
|
||||
};
|
||||
|
||||
typedef struct VstParameterProperties VstParameterProperties;
|
||||
typedef struct VstPinProperties VstPinProperties;
|
||||
|
||||
struct VstParameterProperties
|
||||
{
|
||||
float stepFloat;
|
||||
float smallStepFloat;
|
||||
float largeStepFloat;
|
||||
char label[64];
|
||||
long flags;
|
||||
long minInteger;
|
||||
long maxInteger;
|
||||
long stepInteger;
|
||||
long largeStepInteger;
|
||||
char shortLabel[8]; // recommended: 6 + delimiter
|
||||
char future[48];
|
||||
};
|
||||
|
||||
// parameter properties flags
|
||||
enum
|
||||
{
|
||||
kVstParameterIsSwitch = 1 << 0,
|
||||
kVstParameterUsesIntegerMinMax = 1 << 1,
|
||||
kVstParameterUsesFloatStep = 1 << 2,
|
||||
kVstParameterUsesIntStep = 1 << 3
|
||||
};
|
||||
|
||||
struct VstPinProperties
|
||||
{
|
||||
char label[64];
|
||||
long flags;
|
||||
long reserved;
|
||||
char shortLabel[8]; // recommended: 6 + delimiter
|
||||
char future[48];
|
||||
};
|
||||
|
||||
// pin properties flags
|
||||
enum
|
||||
{
|
||||
kVstPinIsActive = 1 << 0,
|
||||
kVstPinIsStereo = 1 << 1
|
||||
};
|
||||
|
||||
// category
|
||||
enum VstPlugCategory
|
||||
{
|
||||
kPlugCategUnknown = 0,
|
||||
kPlugCategEffect,
|
||||
kPlugCategSynth,
|
||||
kPlugCategAnalysis,
|
||||
kPlugCategMastering,
|
||||
kPlugCategSpacializer, // 'panners'
|
||||
kPlugCategRoomFx, // delays and reverbs
|
||||
kPlugSurroundFx // dedicated surround processor
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// flags bits
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
effFlagsIsSynth = 1 << 8, // host may assign mixer channels for its outputs
|
||||
effFlagsNoSoundInStop = 1 << 9, // does not produce sound when input is all silence
|
||||
effFlagsExtIsAsync = 1 << 10, // for external dsp; plug returns immedeately from process()
|
||||
// host polls plug position (current block) via effGetCurrentPosition
|
||||
effFlagsExtHasBuffer = 1 << 11 // external dsp, may have their own output buffe (32 bit float)
|
||||
// host then requests this via effGetDestinationBuffer
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// surround setup
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct VstSpeakerProperties VstSpeakerProperties;
|
||||
typedef struct VstSpeakerArrangement VstSpeakerArrangement;
|
||||
|
||||
struct VstSpeakerProperties
|
||||
{ // units: range: except:
|
||||
float azimuth; // rad -PI...PI 10.f for LFE channel
|
||||
float elevation; // rad -PI/2...PI/2 10.f for LFE channel
|
||||
float radius; // meter 0.f for LFE channel
|
||||
float reserved; // 0.
|
||||
char name[64]; // for new setups, new names should be given (L/R/C... won't do)
|
||||
char future[32];
|
||||
};
|
||||
|
||||
// note: the origin for azimuth is right (as by math conventions dealing with radians);
|
||||
// the elevation origin is also right, visualizing a rotation of a circle across the
|
||||
// -pi/pi axis of the horizontal circle. thus, an elevation of -pi/2 corresponds
|
||||
// to bottom, and a speaker standing on the left, and 'beaming' upwards would have
|
||||
// an azimuth of -pi, and an elevation of pi/2.
|
||||
// for user interface representation, grads are more likely to be used, and the
|
||||
// origins will obviously 'shift' accordingly.
|
||||
|
||||
struct VstSpeakerArrangement
|
||||
{
|
||||
float lfeGain; // LFE channel gain is adjusted [dB] higher than other channels
|
||||
long numChannels; // number of channels in this speaker arrangement
|
||||
VstSpeakerProperties speakers[8]; // variable
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// offline
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
typedef struct VstOfflineTask VstOfflineTask;
|
||||
typedef struct VstAudioFile VstAudioFile;
|
||||
typedef struct VstAudioFileMarker VstAudioFileMarker;
|
||||
|
||||
struct VstOfflineTask
|
||||
{
|
||||
char processName[96]; // set by plug
|
||||
|
||||
// audio access
|
||||
double readPosition; // set by plug/host
|
||||
double writePosition; // set by plug/host
|
||||
long readCount; // set by plug/host
|
||||
long writeCount; // set by plug
|
||||
long sizeInputBuffer; // set by host
|
||||
long sizeOutputBuffer; // set by host
|
||||
void* inputBuffer; // set by host
|
||||
void* outputBuffer; // set by host
|
||||
double positionToProcessFrom; // set by host
|
||||
double numFramesToProcess; // set by host
|
||||
double maxFramesToWrite; // set by plug
|
||||
|
||||
// other data access
|
||||
void* extraBuffer; // set by plug
|
||||
long value; // set by host or plug
|
||||
long index; // set by host or plug
|
||||
|
||||
// file attributes
|
||||
double numFramesInSourceFile; // set by host
|
||||
double sourceSampleRate; // set by host or plug
|
||||
double destinationSampleRate; // set by host or plug
|
||||
long numSourceChannels; // set by host or plug
|
||||
long numDestinationChannels; // set by host or plug
|
||||
long sourceFormat; // set by host
|
||||
long destinationFormat; // set by plug
|
||||
char outputText[512]; // set by plug or host
|
||||
|
||||
// progress notification
|
||||
double progress; // set by plug
|
||||
long progressMode; // reserved for future
|
||||
char progressText[100]; // set by plug
|
||||
|
||||
long flags; // set by host and plug; see VstOfflineTaskFlags
|
||||
long returnValue; // reserved for future
|
||||
void* hostOwned; // set by host
|
||||
void* plugOwned; // set by plug
|
||||
|
||||
char future[1024];
|
||||
};
|
||||
|
||||
enum VstOfflineTaskFlags
|
||||
{
|
||||
// set by host
|
||||
kVstOfflineUnvalidParameter = 1 << 0,
|
||||
kVstOfflineNewFile = 1 << 1,
|
||||
|
||||
// set by plug
|
||||
kVstOfflinePlugError = 1 << 10,
|
||||
kVstOfflineInterleavedAudio = 1 << 11,
|
||||
kVstOfflineTempOutputFile = 1 << 12,
|
||||
kVstOfflineFloatOutputFile = 1 << 13,
|
||||
kVstOfflineRandomWrite = 1 << 14,
|
||||
kVstOfflineStretch = 1 << 15,
|
||||
kVstOfflineNoThread = 1 << 16
|
||||
};
|
||||
|
||||
// option passed to offlineRead/offlineWrite
|
||||
|
||||
enum VstOfflineOption
|
||||
{
|
||||
kVstOfflineAudio, // reading/writing audio samples
|
||||
kVstOfflinePeaks, // reading graphic representation
|
||||
kVstOfflineParameter, // reading/writing parameters
|
||||
kVstOfflineMarker, // reading/writing marker
|
||||
kVstOfflineCursor, // reading/moving edit cursor
|
||||
kVstOfflineSelection, // reading/changing selection
|
||||
kVstOfflineQueryFiles // to request the host to call asynchronously offlineNotify
|
||||
};
|
||||
|
||||
// structure passed to offlineNotify and offlineStart
|
||||
|
||||
struct VstAudioFile
|
||||
{
|
||||
long flags; // see enum VstAudioFileFlags
|
||||
void* hostOwned; // any data private to host
|
||||
void* plugOwned; // any data private to plugin
|
||||
char name[100]; // file title
|
||||
long uniqueId; // uniquely identify a file during a session
|
||||
double sampleRate; // file sample rate
|
||||
long numChannels; // number of channels (1 for mono, 2 for stereo...)
|
||||
double numFrames; // number of frames in the audio file
|
||||
long format; // reserved for future
|
||||
double editCursorPosition; // -1 if no such cursor
|
||||
double selectionStart; // frame index of first selected frame, or -1
|
||||
double selectionSize; // number of frames in selection, or 0
|
||||
long selectedChannelsMask; // 1 bit per channel
|
||||
long numMarkers; // number of markers in the file
|
||||
long timeRulerUnit; // see doc for possible values
|
||||
double timeRulerOffset; // offset in time ruler (positive or negative)
|
||||
double tempo; // as bpm
|
||||
long timeSigNumerator; // time signature numerator
|
||||
long timeSigDenominator; // time signature denominator
|
||||
long ticksPerBlackNote; // resolution
|
||||
long smpteFrameRate; // smpte rate (set as in VstTimeInfo)
|
||||
|
||||
char future[64];
|
||||
};
|
||||
|
||||
enum VstAudioFileFlags
|
||||
{
|
||||
// set by host (in call offlineNotify)
|
||||
kVstOfflineReadOnly = 1 << 0,
|
||||
kVstOfflineNoRateConversion = 1 << 1,
|
||||
kVstOfflineNoChannelChange = 1 << 2,
|
||||
|
||||
// Set by plug (in function offlineStart)
|
||||
kVstOfflineCanProcessSelection = 1 << 10,
|
||||
kVstOfflineNoCrossfade = 1 << 11,
|
||||
kVstOfflineWantRead = 1 << 12,
|
||||
kVstOfflineWantWrite = 1 << 13,
|
||||
kVstOfflineWantWriteMarker = 1 << 14,
|
||||
kVstOfflineWantMoveCursor = 1 << 15,
|
||||
kVstOfflineWantSelect = 1 << 16
|
||||
};
|
||||
|
||||
struct VstAudioFileMarker
|
||||
{
|
||||
double position;
|
||||
char name[32];
|
||||
long type;
|
||||
long id;
|
||||
long reserved;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// others
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
// structure passed to openWindow and closeWindow
|
||||
|
||||
struct VstWindow
|
||||
{
|
||||
char title[128]; // title
|
||||
short xPos; // position and size
|
||||
short yPos;
|
||||
short width;
|
||||
short height;
|
||||
long style; // 0: with title, 1: without title
|
||||
|
||||
void *parent; // parent of this window
|
||||
void *userHandle; // reserved
|
||||
void *winHandle; // reserved
|
||||
|
||||
char future[104];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
558
4klang_source/Go4kVSTi/source/common/audioeffectx.cpp
Normal file
558
4klang_source/Go4kVSTi/source/common/audioeffectx.cpp
Normal file
@ -0,0 +1,558 @@
|
||||
#ifndef __audioeffectx__
|
||||
#include "audioeffectx.h"
|
||||
#endif
|
||||
|
||||
// *** steinberg developers: this is a public file, *do not edit!*
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// VST Plug-Ins SDK
|
||||
// version 2.0 extension
|
||||
// (c)1999 Steinberg Soft+Hardware GmbH
|
||||
//
|
||||
// you should not have to edit this file
|
||||
// use override methods instead, as suggested in the class declaration (audioeffectx.h)
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
// 'canDo' strings. note other 'canDos' can be evaluated by calling the according
|
||||
// function, for instance if getSampleRate returns 0, you
|
||||
// will certainly want to assume that this selector is not supported.
|
||||
//---------------------------------------------------------------------------------------------
|
||||
|
||||
const char* hostCanDos [] =
|
||||
{
|
||||
"sendVstEvents",
|
||||
"sendVstMidiEvent",
|
||||
"sendVstTimeInfo",
|
||||
"receiveVstEvents",
|
||||
"receiveVstMidiEvent",
|
||||
"receiveVstTimeInfo",
|
||||
|
||||
"reportConnectionChanges",
|
||||
"acceptIOChanges",
|
||||
"sizeWindow",
|
||||
|
||||
"asyncProcessing",
|
||||
"offline",
|
||||
"supplyIdle",
|
||||
"supportShell" // 'shell' handling via uniqueID as suggested by Waves
|
||||
};
|
||||
|
||||
const char* plugCanDos [] =
|
||||
{
|
||||
"sendVstEvents",
|
||||
"sendVstMidiEvent",
|
||||
"sendVstTimeInfo",
|
||||
"receiveVstEvents",
|
||||
"receiveVstMidiEvent",
|
||||
"receiveVstTimeInfo",
|
||||
"offline",
|
||||
"plugAsChannelInsert",
|
||||
"plugAsSend",
|
||||
"mixDryWet",
|
||||
"noRealTime",
|
||||
"multipass",
|
||||
"metapass",
|
||||
"1in1out",
|
||||
"1in2out",
|
||||
"2in1out",
|
||||
"2in2out",
|
||||
"2in4out",
|
||||
"4in2out",
|
||||
"4in4out",
|
||||
"4in8out", // 4:2 matrix to surround bus
|
||||
"8in4out", // surround bus to 4:2 matrix
|
||||
"8in8out"
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// AudioEffectX extends AudioEffect with the new features. so you should derive
|
||||
// your plug from AudioEffectX
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// VstEvents + VstTimeInfo
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
AudioEffectX::AudioEffectX (audioMasterCallback audioMaster, long numPrograms, long numParams)
|
||||
: AudioEffect (audioMaster, numPrograms, numParams)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
AudioEffectX::~AudioEffectX ()
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::dispatcher (long opCode, long index, long value, void *ptr, float opt)
|
||||
{
|
||||
long v = 0;
|
||||
switch(opCode)
|
||||
{
|
||||
// VstEvents
|
||||
case effProcessEvents:
|
||||
v = processEvents ((VstEvents*)ptr);
|
||||
break;
|
||||
|
||||
// parameters and programs
|
||||
case effCanBeAutomated:
|
||||
v = canParameterBeAutomated (index) ? 1 : 0;
|
||||
break;
|
||||
case effString2Parameter:
|
||||
v = string2parameter (index, (char*)ptr) ? 1 : 0;
|
||||
break;
|
||||
|
||||
case effGetNumProgramCategories:
|
||||
v = getNumCategories ();
|
||||
break;
|
||||
case effGetProgramNameIndexed:
|
||||
v = getProgramNameIndexed (value, index, (char*)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effCopyProgram:
|
||||
v = copyProgram (index) ? 1 : 0;
|
||||
break;
|
||||
|
||||
// connections, configuration
|
||||
case effConnectInput:
|
||||
inputConnected (index, value ? true : false);
|
||||
v = 1;
|
||||
break;
|
||||
case effConnectOutput:
|
||||
outputConnected (index, value ? true : false);
|
||||
v = 1;
|
||||
break;
|
||||
case effGetInputProperties:
|
||||
v = getInputProperties (index, (VstPinProperties*)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effGetOutputProperties:
|
||||
v = getOutputProperties (index, (VstPinProperties*)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effGetPlugCategory:
|
||||
v = (long)getPlugCategory ();
|
||||
break;
|
||||
|
||||
// realtime
|
||||
case effGetCurrentPosition:
|
||||
v = reportCurrentPosition ();
|
||||
break;
|
||||
|
||||
case effGetDestinationBuffer:
|
||||
v = (long)reportDestinationBuffer ();
|
||||
break;
|
||||
|
||||
// offline
|
||||
case effOfflineNotify:
|
||||
v = offlineNotify ((VstAudioFile*)ptr, value, index != 0);
|
||||
break;
|
||||
case effOfflinePrepare:
|
||||
v = offlinePrepare ((VstOfflineTask*)ptr, value);
|
||||
break;
|
||||
case effOfflineRun:
|
||||
v = offlineRun ((VstOfflineTask*)ptr, value);
|
||||
break;
|
||||
|
||||
// other
|
||||
case effSetSpeakerArrangement:
|
||||
v = setSpeakerArrangement ((VstSpeakerArrangement*)value, (VstSpeakerArrangement*)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effProcessVarIo:
|
||||
v = processVariableIo ((VstVariableIo*)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effSetBlockSizeAndSampleRate:
|
||||
setBlockSizeAndSampleRate (value, opt);
|
||||
v = 1;
|
||||
break;
|
||||
case effSetBypass:
|
||||
v = setBypass (value ? true : false) ? 1 : 0;
|
||||
break;
|
||||
case effGetEffectName:
|
||||
v = getEffectName ((char *)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effGetErrorText:
|
||||
v = getErrorText ((char *)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effGetVendorString:
|
||||
v = getVendorString ((char *)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effGetProductString:
|
||||
v = getProductString ((char *)ptr) ? 1 : 0;
|
||||
break;
|
||||
case effGetVendorVersion:
|
||||
v = getVendorVersion ();
|
||||
break;
|
||||
case effVendorSpecific:
|
||||
v = vendorSpecific (index, value, ptr, opt);
|
||||
break;
|
||||
case effCanDo:
|
||||
v = canDo ((char*)ptr);
|
||||
break;
|
||||
case effGetIcon:
|
||||
v = (long)getIcon ();
|
||||
break;
|
||||
case effSetViewPosition:
|
||||
v = setViewPosition (index, value) ? 1 : 0;
|
||||
break;
|
||||
case effGetTailSize:
|
||||
v = getGetTailSize ();
|
||||
break;
|
||||
case effIdle:
|
||||
v = fxIdle ();
|
||||
break;
|
||||
|
||||
case effGetParameterProperties:
|
||||
v = getParameterProperties (index, (VstParameterProperties*)ptr) ? 1 : 0;
|
||||
break;
|
||||
|
||||
case effKeysRequired:
|
||||
v = (keysRequired () ? 0 : 1); // reversed to keep v1 compatibility
|
||||
break;
|
||||
case effGetVstVersion:
|
||||
v = getVstVersion ();
|
||||
break;
|
||||
|
||||
// version 1.0 or unknown
|
||||
default:
|
||||
v = AudioEffect::dispatcher (opCode, index, value, ptr, opt);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void AudioEffectX::wantEvents (long filter)
|
||||
{
|
||||
if (audioMaster)
|
||||
audioMaster (&cEffect, audioMasterWantMidi, 0, filter, 0, 0);
|
||||
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
VstTimeInfo* AudioEffectX::getTimeInfo (long filter)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (VstTimeInfo*) audioMaster (&cEffect, audioMasterGetTime, 0, filter, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::tempoAt (long pos)
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterTempoAt, 0, pos, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::sendVstEventsToHost (VstEvents* events)
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterProcessEvents, 0, 0, events, 0) == 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// parameters
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getNumAutomatableParameters ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetNumAutomatableParameters, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getParameterQuantization ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetParameterQuantization, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// configuration
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::ioChanged ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterIOChanged, 0, 0, 0, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::needIdle ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterNeedIdle, 0, 0, 0, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::sizeWindow (long width, long height)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterSizeWindow, width, height, 0, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
double AudioEffectX::updateSampleRate ()
|
||||
{
|
||||
if (audioMaster)
|
||||
audioMaster (&cEffect, audioMasterGetSampleRate, 0, 0, 0, 0); // calls setSampleRate if implemented
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::updateBlockSize ()
|
||||
{
|
||||
if (audioMaster)
|
||||
audioMaster (&cEffect, audioMasterGetBlockSize, 0, 0, 0, 0); // calls setBlockSize if implemented
|
||||
return blockSize;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getInputLatency ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetInputLatency, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getOutputLatency ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetOutputLatency, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
AEffect* AudioEffectX::getPreviousPlug (long input)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (AEffect*) audioMaster (&cEffect, audioMasterGetPreviousPlug, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
AEffect* AudioEffectX::getNextPlug (long output)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (AEffect*) audioMaster (&cEffect, audioMasterGetNextPlug, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// configuration
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::willProcessReplacing ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterWillReplaceOrAccumulate, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getCurrentProcessLevel ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetCurrentProcessLevel, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getAutomationState ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetAutomationState, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void AudioEffectX::wantAsyncOperation (bool state)
|
||||
{
|
||||
if (state)
|
||||
cEffect.flags |= effFlagsExtIsAsync;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsExtIsAsync;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void AudioEffectX::hasExternalBuffer (bool state)
|
||||
{
|
||||
if (state)
|
||||
cEffect.flags |= effFlagsExtHasBuffer;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsExtHasBuffer;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// offline
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::offlineRead (VstOfflineTask* offline, VstOfflineOption option, bool readSource)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterOfflineRead, readSource, option, offline, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::offlineWrite (VstOfflineTask* offline, VstOfflineOption option)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterOfflineWrite, 0, option, offline, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::offlineStart (VstAudioFile* audioFiles, long numAudioFiles, long numNewAudioFiles)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterOfflineStart, numNewAudioFiles, numAudioFiles, audioFiles, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::offlineGetCurrentPass ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterOfflineGetCurrentPass, 0, 0, 0, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::offlineGetCurrentMetaPass ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterOfflineGetCurrentMetaPass, 0, 0, 0, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
// other
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void AudioEffectX::setOutputSamplerate (float sampleRate)
|
||||
{
|
||||
if (audioMaster)
|
||||
audioMaster (&cEffect, audioMasterSetOutputSampleRate, 0, 0, 0, sampleRate);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::getSpeakerArrangement (VstSpeakerArrangement* pluginInput, VstSpeakerArrangement* pluginOutput)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterGetSpeakerArrangement, 0, (long)pluginInput, pluginOutput, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::getHostVendorString (char* text)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterGetVendorString, 0, 0, text, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::getHostProductString (char* text)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterGetProductString, 0, 0, text, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getHostVendorVersion ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetVendorVersion, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::hostVendorSpecific (long lArg1, long lArg2, void* ptrArg, float floatArg)
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterVendorSpecific, lArg1, lArg2, ptrArg, floatArg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::canHostDo (char* text)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterCanDo, 0, 0, text, 0) != 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void AudioEffectX::isSynth (bool state)
|
||||
{
|
||||
if (state)
|
||||
cEffect.flags |= effFlagsIsSynth;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsIsSynth;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void AudioEffectX::noTail (bool state)
|
||||
{
|
||||
if (state)
|
||||
cEffect.flags |= effFlagsNoSoundInStop;
|
||||
else
|
||||
cEffect.flags &= ~effFlagsNoSoundInStop;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
long AudioEffectX::getHostLanguage ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return audioMaster (&cEffect, audioMasterGetLanguage, 0, 0, 0, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void* AudioEffectX::openWindow (VstWindow* window)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (void*)audioMaster (&cEffect, audioMasterOpenWindow, 0, 0, window, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::closeWindow (VstWindow* window)
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterCloseWindow, 0, 0, window, 0) != 0);
|
||||
return false;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
void* AudioEffectX::getDirectory ()
|
||||
{
|
||||
if (audioMaster)
|
||||
return (void*)(audioMaster (&cEffect, audioMasterGetDirectory, 0, 0, 0, 0));
|
||||
return 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------------
|
||||
bool AudioEffectX::updateDisplay()
|
||||
{
|
||||
if (audioMaster)
|
||||
return (audioMaster (&cEffect, audioMasterUpdateDisplay, 0, 0, 0, 0)) ? true : false;
|
||||
return 0;
|
||||
}
|
185
4klang_source/Go4kVSTi/source/common/audioeffectx.h
Normal file
185
4klang_source/Go4kVSTi/source/common/audioeffectx.h
Normal file
@ -0,0 +1,185 @@
|
||||
#ifndef __audioeffectx__
|
||||
#define __audioeffectx__
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// VST Plug-Ins SDK
|
||||
// version 2.0 extension
|
||||
// (c)1999 Steinberg Soft+Hardware GmbH
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
#ifndef __AudioEffect__
|
||||
#include "AudioEffect.hpp" // version 1.0 base class AudioEffect
|
||||
#endif
|
||||
|
||||
#ifndef __aeffectx__
|
||||
#include "aeffectx.h" // version 2.0 'C' extensions and structures
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// AudioEffectX extends AudioEffect with the new features. so you should derive
|
||||
// your plug from AudioEffectX
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
class AudioEffectX : public AudioEffect
|
||||
{
|
||||
public:
|
||||
AudioEffectX (audioMasterCallback audioMaster, long numPrograms, long numParams);
|
||||
virtual ~AudioEffectX ();
|
||||
|
||||
virtual long dispatcher (long opCode, long index, long value, void *ptr, float opt);
|
||||
|
||||
// 'host' are methods which go from plug to host, and are usually not overridden
|
||||
// 'plug' are methods which you may override to implement the according functionality (to host)
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// events + time
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// host
|
||||
virtual void wantEvents (long filter = 1); // filter is currently ignored, midi channel data only (default)
|
||||
virtual VstTimeInfo* getTimeInfo (long filter);
|
||||
// returns const VstTimeInfo* (or 0 if not supported)
|
||||
// filter should contain a mask indicating which fields are requested
|
||||
// (see valid masks in aeffectx.h), as some items may require extensive
|
||||
// conversions
|
||||
virtual long tempoAt (long pos); // returns tempo (in bpm * 10000) at sample frame location <pos>
|
||||
bool sendVstEventsToHost (VstEvents* events); // true:success
|
||||
|
||||
// plug
|
||||
virtual long processEvents (VstEvents* events) {return 0;} // wants no more...else return 1!
|
||||
// VstEvents and VstMidiEvents are declared in aeffectx.h
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// parameters and programs
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// host
|
||||
virtual long getNumAutomatableParameters ();
|
||||
virtual long getParameterQuantization (); // returns the integer value for +1.0 representation,
|
||||
// or 1 if full single float precision is maintained
|
||||
// in automation. parameter index in <value> (-1: all, any)
|
||||
// plug
|
||||
virtual bool canParameterBeAutomated (long index) { return true; }
|
||||
virtual bool string2parameter (long index, char* text) {return false;} // note: implies setParameter. text==0 is to be
|
||||
// expected to check the capability (returns true).
|
||||
virtual float getChannelParameter (long channel, long index) {return 0;}
|
||||
virtual long getNumCategories () {return 1L;}
|
||||
virtual bool getProgramNameIndexed (long category, long index, char* text) {return false;}
|
||||
virtual bool copyProgram (long destination) {return false;}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// connections, configuration
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// host
|
||||
virtual bool ioChanged (); // tell host numInputs and/or numOutputs and/or numParameters has changed
|
||||
virtual bool needIdle (); // plug needs idle calls (outside its editor window)
|
||||
virtual bool sizeWindow (long width, long height);
|
||||
virtual double updateSampleRate (); // gets and returns sample rate from host (may issue setSampleRate() )
|
||||
virtual long updateBlockSize (); // same for block size
|
||||
virtual long getInputLatency ();
|
||||
virtual long getOutputLatency ();
|
||||
virtual AEffect* getPreviousPlug (long input); // input can be -1 in which case the first found is returned
|
||||
virtual AEffect* getNextPlug (long output); // output can be -1 in which case the first found is returned
|
||||
|
||||
// plug
|
||||
virtual void inputConnected (long index, bool state) {} // input at <index> has been (dis-)connected,
|
||||
virtual void outputConnected (long index, bool state) {} // same as input; state == true: connected
|
||||
virtual bool getInputProperties (long index, VstPinProperties* properties) {return false;}
|
||||
virtual bool getOutputProperties (long index, VstPinProperties* properties) {return false;}
|
||||
virtual VstPlugCategory getPlugCategory()
|
||||
{ if (cEffect.flags & effFlagsIsSynth) return kPlugCategSynth; return kPlugCategUnknown; }
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// realtime
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// host
|
||||
virtual long willProcessReplacing (); // returns 0: not implemented, 1: replacing, 2: accumulating
|
||||
virtual long getCurrentProcessLevel (); // returns: 0: not supported,
|
||||
// 1: currently in user thread (gui)
|
||||
// 2: currently in audio thread or irq (where process is called)
|
||||
// 3: currently in 'sequencer' thread or irq (midi, timer etc)
|
||||
// 4: currently offline processing and thus in user thread
|
||||
// other: not defined, but probably pre-empting user thread.
|
||||
virtual long getAutomationState (); // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write
|
||||
virtual void wantAsyncOperation (bool state = true); // notify host that we want to operate asynchronously.
|
||||
// process() will return immedeately; host will poll getCurrentPosition
|
||||
// to see if data are available in time.
|
||||
virtual void hasExternalBuffer (bool state = true); // external dsp, may have their own output buffe (32 bit float)
|
||||
// host then requests this via effGetDestinationBuffer
|
||||
|
||||
// plug
|
||||
virtual long reportCurrentPosition () {return 0;} // for external dsp, see wantAsyncOperation ()
|
||||
virtual float* reportDestinationBuffer () {return 0;} // for external dsp (dma option)
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// offline
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// host
|
||||
virtual bool offlineRead (VstOfflineTask* offline, VstOfflineOption option, bool readSource = true);
|
||||
virtual bool offlineWrite (VstOfflineTask* offline, VstOfflineOption option);
|
||||
virtual bool offlineStart (VstAudioFile* ptr, long numAudioFiles, long numNewAudioFiles);
|
||||
virtual long offlineGetCurrentPass ();
|
||||
virtual long offlineGetCurrentMetaPass ();
|
||||
|
||||
// plug
|
||||
virtual bool offlineNotify (VstAudioFile* ptr, long numAudioFiles, bool start) { return false; }
|
||||
virtual bool offlinePrepare (VstOfflineTask* offline, long count) {return false;}
|
||||
virtual bool offlineRun (VstOfflineTask* offline, long count) {return false;}
|
||||
|
||||
virtual long offlineGetNumPasses () {return 0;}
|
||||
virtual long offlineGetNumMetaPasses () {return 0;}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
// other
|
||||
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// host
|
||||
virtual void setOutputSamplerate (float samplerate);
|
||||
virtual bool getSpeakerArrangement (VstSpeakerArrangement* pluginInput, VstSpeakerArrangement* pluginOutput);
|
||||
virtual bool getHostVendorString (char* text); // fills <text> with a string identifying the vendor (max 64 char)
|
||||
virtual bool getHostProductString (char* text); // fills <text> with a string with product name (max 64 char)
|
||||
virtual long getHostVendorVersion (); // returns vendor-specific version
|
||||
virtual long hostVendorSpecific (long lArg1, long lArg2, void* ptrArg, float floatArg); // no definition
|
||||
virtual long canHostDo (char* text); // see 'hostCanDos' in audioeffectx.cpp
|
||||
// returns 0: don't know (default), 1: yes, -1: no
|
||||
virtual void isSynth (bool state = true); // will call wantEvents if true
|
||||
virtual void noTail (bool state = true); // true: tells host we produce no output when silence comes in
|
||||
// enables host to omit process() when no data are present
|
||||
// on any one input.
|
||||
virtual long getHostLanguage (); // returns VstHostLanguage
|
||||
virtual void* openWindow (VstWindow*); // create new window
|
||||
virtual bool closeWindow (VstWindow*); // close a newly created window
|
||||
virtual void* getDirectory (); // get the plug's directory, FSSpec on mac, else char*
|
||||
virtual bool updateDisplay(); // something has changed, update 'multi-fx' display
|
||||
// returns true if supported
|
||||
|
||||
// plug
|
||||
virtual bool processVariableIo (VstVariableIo* varIo) {return false;}
|
||||
virtual bool setSpeakerArrangement (VstSpeakerArrangement* pluginInput, VstSpeakerArrangement* pluginOutput) {return false;}
|
||||
virtual void setBlockSizeAndSampleRate (long blockSize, float sampleRate)
|
||||
{this->blockSize = blockSize; this->sampleRate = sampleRate;}
|
||||
virtual bool setBypass(bool onOff) {return false;} // for 'soft-bypass; process() still called
|
||||
virtual bool getEffectName (char* name) {return false;} // name max 32 char
|
||||
virtual bool getErrorText (char* text) {return false;} // max 256 char
|
||||
virtual bool getVendorString (char* text) {return false;} // fill text with a string identifying the vendor (max 64 char)
|
||||
virtual bool getProductString (char* text) {return false;} // fill text with a string identifying the product name (max 64 char) // fills <ptr> with a string with product name (max 64 char)
|
||||
virtual long getVendorVersion () {return 0;} // return vendor-specific version
|
||||
virtual long vendorSpecific (long lArg, long lArg2, void* ptrArg, float floatArg) {return 0;}
|
||||
// no definition, vendor specific handling
|
||||
virtual long canDo (char* text) {return 0;} // see 'plugCanDos' in audioeffectx.cpp. return values:
|
||||
// 0: don't know (default), 1: yes, -1: no
|
||||
virtual void* getIcon () {return 0;} // not yet defined
|
||||
virtual bool setViewPosition (long x, long y) {return false;}
|
||||
virtual long getGetTailSize () {return 0; }
|
||||
virtual long fxIdle () {return 0;}
|
||||
virtual bool getParameterProperties (long index, VstParameterProperties* p) {return false;}
|
||||
virtual bool keysRequired () {return false;} // version 1 plugs will return true
|
||||
virtual long getVstVersion () {return 2;}
|
||||
};
|
||||
|
||||
#endif
|
628
4klang_source/Go4kVSTi/source/common/vstcontrols.h
Normal file
628
4klang_source/Go4kVSTi/source/common/vstcontrols.h
Normal file
@ -0,0 +1,628 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// VST Plug-Ins SDK
|
||||
// Simple user interface framework for VST plugins
|
||||
// Standard control objects
|
||||
//
|
||||
// Version 1.0
|
||||
//
|
||||
// First version : Wolfgang Kundrus
|
||||
// Added new objects : Michael Schmidt 08.97
|
||||
// Added new objects : Yvan Grabit 01.98
|
||||
//
|
||||
// (c)1999 Steinberg Soft+Hardware GmbH
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __vstcontrols__
|
||||
#define __vstcontrols__
|
||||
|
||||
#ifndef __vstgui__
|
||||
#include "vstgui.h"
|
||||
#endif
|
||||
|
||||
//------------------
|
||||
// defines
|
||||
//------------------
|
||||
#ifndef kPI
|
||||
#define kPI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifndef k2PI
|
||||
#define k2PI 6.28318530717958647692
|
||||
#endif
|
||||
|
||||
#ifndef kPI_2
|
||||
#define kPI_2 1.57079632679489661923f
|
||||
#endif
|
||||
#ifndef kPI_4
|
||||
#define kPI_4 0.78539816339744830962
|
||||
#endif
|
||||
|
||||
#ifndef kE
|
||||
#define kE 2.7182818284590452354
|
||||
#endif
|
||||
|
||||
#ifndef kLN2
|
||||
#define kLN2 0.69314718055994530942
|
||||
#endif
|
||||
|
||||
|
||||
//------------------
|
||||
// CControlEnum type
|
||||
//------------------
|
||||
enum CControlEnum
|
||||
{
|
||||
kHorizontal = 1 << 0,
|
||||
kVertical = 1 << 1,
|
||||
kShadowText = 1 << 2,
|
||||
kLeft = 1 << 3,
|
||||
kRight = 1 << 4,
|
||||
kTop = 1 << 5,
|
||||
kBottom = 1 << 6,
|
||||
k3DIn = 1 << 7,
|
||||
k3DOut = 1 << 8,
|
||||
kPopupStyle = 1 << 9,
|
||||
kCheckStyle = 1 << 10
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CControlListener
|
||||
{
|
||||
public:
|
||||
virtual void valueChanged (CDrawContext *context, CControl *control) = 0;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CControl : public CView
|
||||
{
|
||||
public:
|
||||
CControl (CRect &size, CControlListener *listener, int tag);
|
||||
virtual ~CControl ();
|
||||
|
||||
virtual void draw (CDrawContext *context) = 0;
|
||||
virtual void update (CDrawContext *context);
|
||||
virtual void doIdleStuff () { if (parent) parent->doIdleStuff (); }
|
||||
|
||||
virtual void setValue (float val) { value = val; }
|
||||
virtual float getValue () { return value; };
|
||||
|
||||
virtual void setMin (float val) { vmin = val; }
|
||||
virtual float getMin () { return vmin; }
|
||||
virtual void setMax (float val) { vmax = val; }
|
||||
virtual float getMax () { return vmax; }
|
||||
|
||||
virtual void setOldValue (float val) { oldValue = val; }
|
||||
virtual float getOldValue (void) { return oldValue; }
|
||||
virtual void setDefaultValue (float val) { defaultValue = val; }
|
||||
virtual float getDefaultValue (void) { return defaultValue; }
|
||||
|
||||
inline int getTag () { return tag; }
|
||||
|
||||
virtual void setMouseEnabled (bool bEnable = true) { bMouseEnabled = bEnable; }
|
||||
virtual bool getMouseEnabled () { return bMouseEnabled; }
|
||||
|
||||
protected:
|
||||
CControlListener *listener;
|
||||
long tag;
|
||||
bool dirty;
|
||||
bool bMouseEnabled;
|
||||
float oldValue;
|
||||
float defaultValue;
|
||||
float value;
|
||||
float vmin;
|
||||
float vmax;
|
||||
float step;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class COnOffButton : public CControl
|
||||
{
|
||||
public:
|
||||
COnOffButton (CRect &size, CControlListener *listener, int tag,
|
||||
CBitmap *handle);
|
||||
virtual ~COnOffButton ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CParamDisplay : public CControl
|
||||
{
|
||||
public:
|
||||
CParamDisplay (CRect &size, CBitmap *background = 0, int style = 0);
|
||||
virtual ~CParamDisplay ();
|
||||
|
||||
virtual void setFont (CFont fontID);
|
||||
virtual void setFontColor (CColor color);
|
||||
virtual void setBackColor (CColor color);
|
||||
virtual void setFrameColor (CColor color);
|
||||
virtual void setShadowColor (CColor color);
|
||||
|
||||
virtual void setHoriAlign (CHoriTxtAlign hAlign);
|
||||
virtual void setBackOffset (CPoint &offset);
|
||||
virtual void setStringConvert (void (*stringConvert) (float value, char *string));
|
||||
|
||||
virtual void draw (CDrawContext *context);
|
||||
|
||||
protected:
|
||||
void drawText (CDrawContext *context, char *string, CBitmap *newBack = 0);
|
||||
|
||||
CHoriTxtAlign horiTxtAlign;
|
||||
int style;
|
||||
|
||||
CFont fontID;
|
||||
CColor fontColor;
|
||||
CColor backColor;
|
||||
CColor frameColor;
|
||||
CColor shadowColor;
|
||||
CPoint offset;
|
||||
|
||||
CBitmap *background;
|
||||
|
||||
private:
|
||||
void (*stringConvert) (float value, char *string);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTextEdit : public CParamDisplay
|
||||
{
|
||||
public:
|
||||
CTextEdit (CRect &size, CControlListener *listener, int tag, const char *txt = 0,
|
||||
CBitmap *background = 0,
|
||||
int style = 0);
|
||||
~CTextEdit ();
|
||||
|
||||
virtual void setText (char *txt);
|
||||
virtual void getText (char *txt);
|
||||
|
||||
virtual void draw (CDrawContext *context);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
virtual void setTextEditConvert (void (*stringConvert) (char *input, char *string));
|
||||
|
||||
virtual void takeFocus ();
|
||||
virtual void looseFocus ();
|
||||
|
||||
protected:
|
||||
void *platformControl;
|
||||
void *platformFont;
|
||||
char text[256];
|
||||
|
||||
private:
|
||||
void (*stringConvert) (char *input, char *string);
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MAX_ENTRY 128
|
||||
class COptionMenu : public CParamDisplay
|
||||
{
|
||||
public:
|
||||
COptionMenu (CRect &size, CControlListener *listener, int tag,
|
||||
CBitmap *background = 0, CBitmap *bgWhenClick = 0,
|
||||
int style = 0);
|
||||
~COptionMenu ();
|
||||
|
||||
virtual bool addEntry (char *txt, int index = -1);
|
||||
virtual int getCurrent (char *txt = 0);
|
||||
virtual bool setCurrent (int index);
|
||||
virtual bool getEntry (int index, char *txt);
|
||||
virtual bool removeEntry (int index);
|
||||
virtual bool removeAllEntry ();
|
||||
virtual int getNbEntries () { return nbEntries; }
|
||||
|
||||
virtual void draw (CDrawContext *context);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
virtual void takeFocus ();
|
||||
virtual void looseFocus ();
|
||||
|
||||
#if MOTIF
|
||||
void setCurrentSelected (void *itemSelected);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void *platformControl;
|
||||
char *entry[MAX_ENTRY];
|
||||
|
||||
#if MOTIF
|
||||
void *itemWidget[MAX_ENTRY];
|
||||
#endif
|
||||
|
||||
int nbEntries;
|
||||
int currentIndex;
|
||||
CBitmap *bgWhenClick;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CKnob : public CControl
|
||||
{
|
||||
public:
|
||||
CKnob (CRect &size, CControlListener *listener, int tag,
|
||||
CBitmap *background,
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CKnob ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
virtual void valueToPoint (CPoint &point);
|
||||
virtual float valueFromPoint (CPoint &point);
|
||||
|
||||
virtual void setBackground (CBitmap* background);
|
||||
virtual CBitmap *getBackground () { return background; }
|
||||
|
||||
protected:
|
||||
int inset;
|
||||
CBitmap *background;
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CAnimKnob : public CKnob
|
||||
{
|
||||
public:
|
||||
CAnimKnob (CRect &size, CControlListener *listener, int tag,
|
||||
int subPixmaps, // number of subPixmaps
|
||||
int heightOfOneImage, // pixel
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CAnimKnob ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
|
||||
protected:
|
||||
int subPixmaps; // number of subPixmaps
|
||||
int heightOfOneImage;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CVerticalSwitch : public CControl
|
||||
{
|
||||
public:
|
||||
CVerticalSwitch (CRect &size, CControlListener *listener, int tag,
|
||||
int subPixmaps, // number of subPixmaps
|
||||
int heightOfOneImage, // pixel
|
||||
int iMaxPositions,
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CVerticalSwitch ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
int subPixmaps; // number of subPixmaps
|
||||
int heightOfOneImage;
|
||||
int iMaxPositions;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CHorizontalSwitch : public CControl
|
||||
{
|
||||
public:
|
||||
CHorizontalSwitch (CRect &size, CControlListener *listener, int tag,
|
||||
int subPixmaps, // number of subPixmaps
|
||||
int heightOfOneImage, // pixel
|
||||
int iMaxPositions,
|
||||
CBitmap *handle,
|
||||
CPoint &offset);
|
||||
virtual ~CHorizontalSwitch ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
int subPixmaps; // number of subPixmaps
|
||||
int heightOfOneImage;
|
||||
int iMaxPositions;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CRockerSwitch : public CControl
|
||||
{
|
||||
public:
|
||||
CRockerSwitch (CRect &size, CControlListener *listener, int tag,
|
||||
int heightOfOneImage, // pixel
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CRockerSwitch ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
int heightOfOneImage;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMovieBitmap : public CControl
|
||||
{
|
||||
public:
|
||||
CMovieBitmap (CRect &size, CControlListener *listener, int tag,
|
||||
int subPixmaps, // number of subPixmaps
|
||||
int heightOfOneImage, // pixel
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CMovieBitmap ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
int subPixmaps; // number of subPixmaps
|
||||
int heightOfOneImage;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMovieButton : public CControl
|
||||
{
|
||||
public:
|
||||
CMovieButton (CRect &size, CControlListener *listener, int tag,
|
||||
int heightOfOneImage, // pixel
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CMovieButton ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
int heightOfOneImage;
|
||||
float buttonState;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// displays bitmaps within a (child-) window
|
||||
class CAutoAnimation : public CControl
|
||||
{
|
||||
public:
|
||||
CAutoAnimation (CRect &size, CControlListener *listener, int tag,
|
||||
int subPixmaps, // number of subPixmaps...
|
||||
int heightOfOneImage, // pixel
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CAutoAnimation ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
virtual void openWindow (void);
|
||||
virtual void closeWindow (void);
|
||||
|
||||
virtual void nextPixmap (void);
|
||||
virtual void previousPixmap (void);
|
||||
|
||||
bool isWindowOpened () { return windowOpened; }
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
|
||||
int subPixmaps;
|
||||
int heightOfOneImage;
|
||||
|
||||
bool windowOpened;
|
||||
int totalHeightOfBitmap;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// Vertical Slider
|
||||
class CVerticalSlider : public CControl
|
||||
{
|
||||
public:
|
||||
CVerticalSlider (CRect &size, CControlListener *listener, int tag,
|
||||
int iMinYPos, // min Y position in pixel
|
||||
int iMaxYPos, // max Y position in pixel
|
||||
CBitmap *handle, // bitmap slider
|
||||
CBitmap *background, // bitmap background
|
||||
CPoint &offset,
|
||||
int style = kBottom); // style (kBottom, kTop))
|
||||
|
||||
virtual ~CVerticalSlider ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
virtual void setDrawTransparentHandle (bool val) { drawTransparentEnabled = val; }
|
||||
virtual void setOffsetHandle (CPoint &val) { offsetHandle = val; }
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CBitmap *background;
|
||||
|
||||
int widthOfSlider; // size of the handle-slider
|
||||
int heightOfSlider;
|
||||
|
||||
CPoint offset;
|
||||
CPoint offsetHandle;
|
||||
|
||||
int iMinYPos; // min Y position in pixel
|
||||
int iMaxYPos; // max Y position in pixel
|
||||
int style;
|
||||
|
||||
int actualYPos;
|
||||
bool drawTransparentEnabled;
|
||||
|
||||
int minTmp;
|
||||
int maxTmp;
|
||||
int widthControl;
|
||||
int heightControl;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// Horizontal Slider
|
||||
class CHorizontalSlider : public CControl
|
||||
{
|
||||
public:
|
||||
CHorizontalSlider (CRect &size, CControlListener *listener, int tag,
|
||||
int iMinXPos, // min X position in pixel
|
||||
int iMaxXPos, // max X position in pixel
|
||||
CBitmap *handle, // bitmap slider
|
||||
CBitmap *background, // bitmap background
|
||||
CPoint &offset,
|
||||
int style = kRight); // style (kRight, kLeft));
|
||||
|
||||
virtual ~CHorizontalSlider ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
virtual void setDrawTransparentHandle (bool val) { drawTransparentEnabled = val; }
|
||||
virtual void setOffsetHandle (CPoint &val) { offsetHandle = val; }
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CBitmap *background;
|
||||
|
||||
int widthOfSlider; // size of the handle-slider
|
||||
int heightOfSlider;
|
||||
|
||||
CPoint offset;
|
||||
CPoint offsetHandle;
|
||||
|
||||
int iMinXPos; // min X position in pixel
|
||||
int iMaxXPos; // max X position in pixel
|
||||
int style;
|
||||
|
||||
int actualXPos;
|
||||
bool drawTransparentEnabled;
|
||||
|
||||
int minTmp;
|
||||
int maxTmp;
|
||||
int widthControl;
|
||||
int heightControl;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
// special display with custom numbers (0...9)
|
||||
class CSpecialDigit : public CControl
|
||||
{
|
||||
public:
|
||||
CSpecialDigit (CRect &size, CControlListener *listener, int tag, // tag identifier
|
||||
long dwPos, // actual value
|
||||
int iNumbers, // amount of numbers (max 7)
|
||||
int *xpos, // array of all XPOS
|
||||
int *ypos, // array of all YPOS
|
||||
int width, // width of ONE number
|
||||
int height, // height of ONE number
|
||||
CBitmap *handle); // bitmap numbers
|
||||
virtual ~CSpecialDigit ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
|
||||
virtual float getNormValue (void);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
int iNumbers; // amount of numbers
|
||||
int xpos[7]; // array of all XPOS, max 7 possible
|
||||
int ypos[7]; // array of all YPOS, max 7 possible
|
||||
int width; // width of ONE number
|
||||
int height; // height of ONE number
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CKickButton : public CControl
|
||||
{
|
||||
public:
|
||||
CKickButton (CRect &size, CControlListener *listener, int tag,
|
||||
int heightOfOneImage, // pixel
|
||||
CBitmap *handle, CPoint &offset);
|
||||
virtual ~CKickButton ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
int heightOfOneImage;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CSplashScreen : public CControl
|
||||
{
|
||||
public:
|
||||
CSplashScreen (CRect &size, CControlListener *listener, int tag,
|
||||
CBitmap *handle,
|
||||
CRect &toDisplay,
|
||||
CPoint &offset);
|
||||
virtual ~CSplashScreen ();
|
||||
|
||||
virtual void draw (CDrawContext*);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
protected:
|
||||
CRect toDisplay;
|
||||
CRect keepSize;
|
||||
CBitmap *handle;
|
||||
CPoint offset;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
class CVuMeter : public CControl
|
||||
{
|
||||
public:
|
||||
CVuMeter (CRect& size, CBitmap *onBitmap, CBitmap *offBitmap,
|
||||
int nbLed, const int style = kVertical);
|
||||
virtual ~CVuMeter ();
|
||||
|
||||
virtual void setDecreaseStepValue (float value) { decreaseValue = value; }
|
||||
|
||||
virtual void draw (CDrawContext *context);
|
||||
|
||||
protected:
|
||||
CBitmap *onBitmap;
|
||||
CBitmap *offBitmap;
|
||||
int nbLed;
|
||||
int style;
|
||||
float decreaseValue;
|
||||
|
||||
CRect rectOn;
|
||||
CRect rectOff;
|
||||
};
|
||||
|
||||
#endif
|
621
4klang_source/Go4kVSTi/source/common/vstgui.h
Normal file
621
4klang_source/Go4kVSTi/source/common/vstgui.h
Normal file
@ -0,0 +1,621 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// VST Plug-Ins SDK
|
||||
// User interface framework for VST plugins
|
||||
//
|
||||
// Version 1.0
|
||||
//
|
||||
// First version : Wolfgang Kundrus
|
||||
// Added Motif/Windows version : Yvan Grabit 01.98
|
||||
// Added Mac version : Charlie Steinberg 02.98
|
||||
// Added BeOS version : Georges-Edouard Berenger 05.99
|
||||
//
|
||||
// (c)1999 Steinberg Soft+Hardware GmbH
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef __vstgui__
|
||||
#define __vstgui__
|
||||
|
||||
// define global defines
|
||||
#if WIN32
|
||||
#define WINDOWS 1
|
||||
#elif SGI | SUN
|
||||
#define MOTIF 1
|
||||
#elif __MWERKS__
|
||||
#define MAC 1
|
||||
#endif
|
||||
|
||||
#ifndef __AEffEditor__
|
||||
#include "AEffEditor.hpp"
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------
|
||||
#if WINDOWS
|
||||
#include <windows.h>
|
||||
|
||||
//----------------------------------------------------
|
||||
#elif MOTIF
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#ifdef NOBOOL
|
||||
#ifndef bool
|
||||
typedef short bool;
|
||||
#endif
|
||||
#ifndef false
|
||||
static const bool false = 0;
|
||||
#endif
|
||||
#ifndef true
|
||||
static const bool true = 1;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// definition of struct for XPixmap resources
|
||||
struct CResTableEntry {
|
||||
int id;
|
||||
char **xpm;
|
||||
};
|
||||
|
||||
typedef CResTableEntry CResTable[];
|
||||
extern CResTable xpmResources;
|
||||
|
||||
//----------------------------------------------------
|
||||
#elif MAC
|
||||
#include <Quickdraw.h>
|
||||
class CCashedPict;
|
||||
|
||||
//----------------------------------------------------
|
||||
#elif BEOS
|
||||
#include <View.h>
|
||||
class PlugView;
|
||||
class BBitmap;
|
||||
class BResources;
|
||||
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------
|
||||
//----------------------------------------------------
|
||||
class CFrame;
|
||||
class CDrawContext;
|
||||
class COffscreenContext;
|
||||
class CControl;
|
||||
class CBitmap;
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// AEffGUIEditor Declaration
|
||||
//-----------------------------------------------------------------------------
|
||||
class AEffGUIEditor : public AEffEditor
|
||||
{
|
||||
public :
|
||||
|
||||
AEffGUIEditor (AudioEffect *effect);
|
||||
|
||||
virtual ~AEffGUIEditor ();
|
||||
|
||||
virtual void setParameter (long index, float value) { postUpdate (); }
|
||||
virtual long getRect (ERect **rect);
|
||||
virtual long open (void *ptr);
|
||||
virtual void idle ();
|
||||
virtual void draw (ERect *rect);
|
||||
#if MAC
|
||||
virtual long mouse (long x, long y);
|
||||
#endif
|
||||
|
||||
// get the current time (in ms)
|
||||
long getTicks ();
|
||||
|
||||
// feedback to appli.
|
||||
void doIdleStuff ();
|
||||
|
||||
// get the effect attached to this editor
|
||||
AudioEffect *getEffect () { return effect; }
|
||||
|
||||
//---------------------------------------
|
||||
protected:
|
||||
ERect rect;
|
||||
CFrame *frame;
|
||||
|
||||
unsigned long lLastTicks;
|
||||
|
||||
private:
|
||||
short sInControlLoop;
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structure CRect
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CRect
|
||||
{
|
||||
CRect (long left = 0, long top = 0, long right = 0, long bottom = 0)
|
||||
: left (left), top (top), right (right), bottom (bottom) {}
|
||||
CRect (const CRect& r)
|
||||
: left (r.left), top (r.top), right (r.right), bottom (r.bottom) {}
|
||||
CRect& operator () (long left, long top, long right, long bottom)
|
||||
{
|
||||
if (left < right)
|
||||
this->left = left, this->right = right;
|
||||
else
|
||||
this->left = right, this->right = left;
|
||||
if (top < bottom)
|
||||
this->top = top, this->bottom = bottom;
|
||||
else
|
||||
this->top = bottom, this->bottom = top;
|
||||
return *this;
|
||||
}
|
||||
|
||||
long left;
|
||||
long top;
|
||||
long right;
|
||||
long bottom;
|
||||
inline long width () { return right - left; }
|
||||
inline long height () { return bottom - top; }
|
||||
|
||||
void offset (long x, long y) { left += x; right += x;
|
||||
top += y; bottom += y; }
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structure CPoint
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CPoint
|
||||
{
|
||||
CPoint (long h = 0, long v = 0) : h (h), v (v) {}
|
||||
CPoint& operator () (long h, long v)
|
||||
{ this->h = h; this->v = v;
|
||||
return *this; }
|
||||
|
||||
bool isInside (CRect& r)
|
||||
{ return h >= r.left && h <= r.right && v >= r.top && v <= r.bottom; }
|
||||
|
||||
long h;
|
||||
long v;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Structure CColor
|
||||
//-----------------------------------------------------------------------------
|
||||
struct CColor
|
||||
{
|
||||
CColor& operator () (unsigned char red,
|
||||
unsigned char green,
|
||||
unsigned char blue,
|
||||
unsigned char unused)
|
||||
{
|
||||
this->red = red;
|
||||
this->green = green;
|
||||
this->blue = blue;
|
||||
this->unused = unused;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CColor& operator = (CColor newColor)
|
||||
{
|
||||
red = newColor.red;
|
||||
green = newColor.green;
|
||||
blue = newColor.blue;
|
||||
unused = newColor.unused;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator != (CColor newColor)
|
||||
{
|
||||
return (red != newColor.red ||
|
||||
green != newColor.green ||
|
||||
blue != newColor.blue);
|
||||
}
|
||||
|
||||
bool operator == (CColor newColor)
|
||||
{
|
||||
return (red == newColor.red &&
|
||||
green == newColor.green &&
|
||||
blue == newColor.blue);
|
||||
}
|
||||
|
||||
unsigned char red;
|
||||
unsigned char green;
|
||||
unsigned char blue;
|
||||
unsigned char unused;
|
||||
};
|
||||
|
||||
// define some basic colors
|
||||
static CColor kTransparentCColor = {255, 255, 255, 0};
|
||||
static CColor kBlackCColor = {0, 0, 0, 0};
|
||||
static CColor kWhiteCColor = {255, 255, 255, 0};
|
||||
static CColor kGreyCColor = {127, 127, 127, 0};
|
||||
static CColor kRedCColor = {255, 0, 0, 0};
|
||||
static CColor kGreenCColor = {0 , 255, 0, 0};
|
||||
static CColor kBlueCColor = {0 , 0, 255, 0};
|
||||
static CColor kYellowCColor = {255, 255, 0, 0};
|
||||
static CColor kCyanCColor = {255, 0, 255, 0};
|
||||
static CColor kMagentaCColor= {0 , 255, 255, 0};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------
|
||||
// Font type
|
||||
//-----------
|
||||
enum CFont
|
||||
{
|
||||
kSystemFont = 0,
|
||||
kNormalFontVeryBig,
|
||||
kNormalFontBig,
|
||||
kNormalFont,
|
||||
kNormalFontSmall,
|
||||
kNormalFontVerySmall,
|
||||
kSymbolFont,
|
||||
|
||||
kNumStandardFonts
|
||||
};
|
||||
|
||||
//-----------
|
||||
// Line style
|
||||
//-----------
|
||||
enum CLineStyle
|
||||
{
|
||||
kLineSolid = 0,
|
||||
kLineOnOffDash
|
||||
};
|
||||
|
||||
//----------------------------
|
||||
// Text alignment (Horizontal)
|
||||
//----------------------------
|
||||
enum CHoriTxtAlign
|
||||
{
|
||||
kLeftText = 0,
|
||||
kCenterText,
|
||||
kRightText
|
||||
};
|
||||
|
||||
//----------------------------
|
||||
// Buttons Type (+modifiers)
|
||||
//----------------------------
|
||||
enum CButton
|
||||
{
|
||||
kLButton = 1,
|
||||
kMButton = 2,
|
||||
kRButton = 4,
|
||||
kShift = 8,
|
||||
kControl = 16,
|
||||
kAlt = 32,
|
||||
kApple = 64
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CDrawContext Declaration
|
||||
//-----------------------------------------------------------------------------
|
||||
class CDrawContext
|
||||
{
|
||||
public:
|
||||
CDrawContext (CFrame *frame, void *systemContext, void *window = 0);
|
||||
virtual ~CDrawContext ();
|
||||
|
||||
void moveTo (CPoint &point);
|
||||
void lineTo (CPoint &point);
|
||||
|
||||
void polyLine (CPoint *point, int numberOfPoints);
|
||||
void fillPolygon (CPoint *point, int numberOfPoints);
|
||||
|
||||
void drawRect (CRect &rect);
|
||||
void fillRect (CRect &rect);
|
||||
|
||||
void drawArc (CRect &rect, CPoint &point1, CPoint &point2);
|
||||
void fillArc (CRect &rect, CPoint &point1, CPoint &point2);
|
||||
|
||||
void drawEllipse (CRect &rect);
|
||||
void fillEllipse (CRect &rect);
|
||||
|
||||
void drawPoint (CPoint &point, CColor color);
|
||||
|
||||
void setLineStyle (CLineStyle style);
|
||||
CLineStyle getLineStyle () { return lineStyle; }
|
||||
|
||||
void setLineWidth (int width);
|
||||
int getLineWidth () { return frameWidth; }
|
||||
|
||||
void setFillColor (CColor color);
|
||||
CColor getFillColor () { return fillColor; }
|
||||
|
||||
void setFrameColor (CColor color);
|
||||
CColor getFrameColor () { return frameColor; }
|
||||
|
||||
void setFontColor (CColor color);
|
||||
CColor getFontColor () { return fontColor; }
|
||||
void setFont (CFont fontID, const int size = 0);
|
||||
|
||||
void drawString (const char *string, CRect &rect, const short opaque = false,
|
||||
const CHoriTxtAlign hAlign = kCenterText);
|
||||
|
||||
int getMouseButtons ();
|
||||
void getMouseLocation (CPoint &point);
|
||||
|
||||
#if MOTIF
|
||||
int getIndexColor (CColor color);
|
||||
Colormap getColormap ();
|
||||
Visual *getVisual ();
|
||||
unsigned int getDepth ();
|
||||
|
||||
static int nbNewColor;
|
||||
#endif
|
||||
|
||||
void *getWindow () { return window; }
|
||||
void setWindow (void *ptr) { window = ptr; }
|
||||
void getLoc (CPoint &where) { where = penLoc; }
|
||||
|
||||
//-------------------------------------------
|
||||
protected:
|
||||
|
||||
friend class CBitmap;
|
||||
friend class COffscreenContext;
|
||||
|
||||
void *getSystemContext () { return systemContext; }
|
||||
|
||||
void *systemContext;
|
||||
void *window;
|
||||
CFrame *frame;
|
||||
|
||||
int fontSize;
|
||||
CColor fontColor;
|
||||
CPoint penLoc;
|
||||
|
||||
int frameWidth;
|
||||
CColor frameColor;
|
||||
CColor fillColor;
|
||||
CLineStyle lineStyle;
|
||||
|
||||
#if WINDOWS
|
||||
void *brush;
|
||||
void *pen;
|
||||
void *font;
|
||||
void *oldbrush;
|
||||
void *oldpen;
|
||||
void *oldfont;
|
||||
int iPenStyle;
|
||||
|
||||
#elif MAC
|
||||
FontInfo fontInfoStruct;
|
||||
Pattern fillPattern;
|
||||
|
||||
#elif MOTIF
|
||||
Display *display;
|
||||
|
||||
XFontStruct *fontInfoStruct;
|
||||
CFont fontInfoId;
|
||||
|
||||
#elif BEOS
|
||||
BView* plugView;
|
||||
BFont font;
|
||||
void lineFromTo (CPoint& cstart, CPoint& cend);
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// COffscreenContext Declaration
|
||||
//-----------------------------------------------------------------------------
|
||||
class COffscreenContext : public CDrawContext
|
||||
{
|
||||
public:
|
||||
COffscreenContext (CDrawContext *context, CBitmap *bitmap);
|
||||
COffscreenContext (CFrame *frame, long width, long height, const CColor backgroundColor = kBlackCColor);
|
||||
|
||||
virtual ~COffscreenContext ();
|
||||
|
||||
void transfert (CDrawContext *context, CRect destRect, CPoint srcOffset = CPoint (0, 0));
|
||||
inline int getWidth () { return width; }
|
||||
inline int getHeight () { return height; }
|
||||
|
||||
//-------------------------------------------
|
||||
protected:
|
||||
bool destroyPixmap;
|
||||
CBitmap *bitmap;
|
||||
|
||||
long height;
|
||||
long width;
|
||||
|
||||
CColor backgroundColor;
|
||||
|
||||
#if MOTIF
|
||||
Display *xdisplay;
|
||||
|
||||
#elif BEOS
|
||||
BBitmap *offscreenBitmap;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CBitmap Declaration
|
||||
//-----------------------------------------------------------------------------
|
||||
class CBitmap
|
||||
{
|
||||
public:
|
||||
CBitmap (int resourceID);
|
||||
CBitmap (CFrame &frame, int width, int height);
|
||||
~CBitmap ();
|
||||
|
||||
void draw (CDrawContext*, CRect &rect, const CPoint &offset = CPoint (0, 0));
|
||||
void drawTransparent (CDrawContext *context, CRect &rect, const CPoint &offset = CPoint (0, 0));
|
||||
|
||||
inline int getWidth () { return width; }
|
||||
inline int getHeight () { return height; }
|
||||
|
||||
void forget ();
|
||||
void remember ();
|
||||
|
||||
void *getHandle () { return handle; }
|
||||
|
||||
#if BEOS
|
||||
static void closeResource ();
|
||||
#endif
|
||||
|
||||
//-------------------------------------------
|
||||
protected:
|
||||
int resourceID;
|
||||
void *handle;
|
||||
void *mask;
|
||||
int width;
|
||||
int height;
|
||||
|
||||
int nbReference;
|
||||
|
||||
#if MOTIF
|
||||
void *createPixmapFromXpm (CDrawContext *context);
|
||||
|
||||
char **dataXpm;
|
||||
Display *xdisplay;
|
||||
|
||||
#elif MAC
|
||||
CCashedPict *pPict;
|
||||
|
||||
#elif BEOS
|
||||
static BResources *resourceFile;
|
||||
BBitmap *bbitmap;
|
||||
bool transparencySet;
|
||||
#endif
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CView Declaration
|
||||
//-----------------------------------------------------------------------------
|
||||
class CView
|
||||
{
|
||||
public:
|
||||
CView (CRect &size);
|
||||
virtual ~CView ();
|
||||
|
||||
void redraw ();
|
||||
virtual void draw (CDrawContext *context);
|
||||
virtual void mouse (CDrawContext *context, CPoint &where);
|
||||
virtual void update (CDrawContext *context);
|
||||
|
||||
virtual void looseFocus ();
|
||||
virtual void takeFocus ();
|
||||
|
||||
virtual void setTempOffscreen (COffscreenContext *tempOffscr);
|
||||
|
||||
int getHeight () { return size.height (); }
|
||||
int getWidth () { return size.width (); }
|
||||
|
||||
CFrame *getParent () { return parent; }
|
||||
|
||||
//-------------------------------------------
|
||||
protected:
|
||||
friend class CControl;
|
||||
friend class CFrame;
|
||||
CRect size;
|
||||
CFrame *parent;
|
||||
COffscreenContext *tempOffscreen;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// CFrame Declaration
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFrame : public CView
|
||||
{
|
||||
public:
|
||||
CFrame (CRect &size, void *systemWindow, AEffGUIEditor *editor);
|
||||
CFrame (CRect &size, char *title, AEffGUIEditor *editor, const int style = 0);
|
||||
|
||||
~CFrame ();
|
||||
|
||||
bool open (CPoint *point = 0);
|
||||
bool close ();
|
||||
bool isOpen () { return openFlag; }
|
||||
|
||||
void draw (CDrawContext *context);
|
||||
void draw (CView *view = 0);
|
||||
void mouse (CDrawContext *context, CPoint &where);
|
||||
|
||||
void update (CDrawContext *context);
|
||||
void idle ();
|
||||
void doIdleStuff () { if (editor) editor->doIdleStuff (); }
|
||||
|
||||
bool getPosition (int &x, int &y);
|
||||
bool setSize (int width, int height);
|
||||
bool getSize (CRect *size);
|
||||
|
||||
void setBackground (CBitmap *background);
|
||||
CBitmap *getBackground () { return background; }
|
||||
|
||||
virtual bool addView (CView *view);
|
||||
virtual bool removeView (CView *view);
|
||||
|
||||
int setModalView (CView *view);
|
||||
|
||||
#if WINDOWS
|
||||
void *getSystemWindow () { return hwnd;}
|
||||
#elif BEOS
|
||||
void *getSystemWindow () { return plugView;}
|
||||
#else
|
||||
void *getSystemWindow () { return systemWindow;}
|
||||
#endif
|
||||
|
||||
AEffGUIEditor *getEditor () { return editor; }
|
||||
|
||||
void setEditView (CView *view) { editView = view; }
|
||||
CView *getEditView () { return editView; }
|
||||
|
||||
#if MOTIF
|
||||
Colormap getColormap () { return colormap; }
|
||||
Visual *getVisual () { return visual; }
|
||||
unsigned int getDepth () { return depth; }
|
||||
Display *getDisplay () { return display; }
|
||||
Window getWindow () { return window; }
|
||||
void freeGc ();
|
||||
|
||||
Region region;
|
||||
|
||||
GC gc;
|
||||
GC getGC () { return gc; }
|
||||
#else
|
||||
void *getGC () { return 0; }
|
||||
#endif
|
||||
|
||||
//-------------------------------------------
|
||||
protected:
|
||||
bool initFrame (void *systemWin);
|
||||
|
||||
AEffGUIEditor *editor;
|
||||
|
||||
void *systemWindow;
|
||||
CBitmap *background;
|
||||
int viewCount;
|
||||
int maxViews;
|
||||
CView **views;
|
||||
CView *modalView;
|
||||
CView *editView;
|
||||
|
||||
bool firstDraw;
|
||||
bool openFlag;
|
||||
|
||||
#if WINDOWS
|
||||
void *hwnd;
|
||||
friend LONG WINAPI WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
#elif MOTIF
|
||||
Colormap colormap;
|
||||
Display *display;
|
||||
Visual *visual;
|
||||
Window window;
|
||||
unsigned int depth;
|
||||
|
||||
friend void _destroyCallback (Widget, XtPointer, XtPointer);
|
||||
|
||||
#elif BEOS
|
||||
PlugView *plugView;
|
||||
#endif
|
||||
|
||||
//-------------------------------------------
|
||||
private:
|
||||
bool addedWindow;
|
||||
void *vstWindow;
|
||||
};
|
||||
|
||||
|
||||
// include the control object
|
||||
#ifndef __vstcontrols__
|
||||
#include "vstcontrols.h"
|
||||
#endif
|
||||
|
||||
|
||||
//-End--------------------------------------
|
||||
#endif
|
Reference in New Issue
Block a user