xtc/tests/plugins/vst2_fixture.c

34 lines
1.5 KiB
C
Raw Normal View History

/* Original MIT ABI fixture; not built from or linked to a proprietary SDK. */
#include "../../src/plugin/vst2_abi.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
typedef struct { xtc_v2_effect effect; int open, active, started; } instance;
static intptr_t dispatch(xtc_v2_effect *e, int32_t op, int32_t index, intptr_t value, void *ptr, float option)
{
instance *p = (instance *)e; (void)index; (void)option;
switch (op) {
case 0: assert(!p->open); p->open = 1; break;
case 1: assert(p->open && !p->active && !p->started); free(p); break;
case 12: p->active = value != 0; break;
case 45: strcpy(ptr,"VST2 gain"); return 1;
case 71: assert(p->active); p->started = 1; break;
case 72: p->started = 0; break;
default: break;
}
return 0;
}
static void process(xtc_v2_effect *e, float **input, float **output, int32_t frames)
{ instance *p = (instance *)e; int32_t i; assert(p->started); for (i = 0; i < frames; ++i) output[0][i] = input[0][i]*.5f; }
xtc_v2_effect *VSTPluginMain(xtc_v2_host host);
xtc_v2_effect *VSTPluginMain(xtc_v2_host host)
{
instance *p; assert(host(NULL,1,0,0,NULL,0) == 2400);
p = calloc(1,sizeof(*p)); if (!p) return NULL;
p->effect.magic = XTC_V2_MAGIC; p->effect.dispatch = dispatch;
p->effect.inputs = p->effect.outputs = 1;
if (getenv("XTC_VST2_FIXTURE_LAYOUT")) p->effect.inputs = 2;
p->effect.flags = 16;
p->effect.unique_id = 0x58544332; p->effect.replace = process;
return &p->effect;
}