/* Original MIT ABI fixture; not built from or linked to a proprietary SDK. */ #include "../../src/plugin/vst2_abi.h" #include #include #include typedef struct { xtc_v2_effect effect; int open, active, started; float level; xtc_v2_midi events[256]; int count; } 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 25: { xtc_v2_events *events = ptr; int i; assert(events->count <= 256); p->count = events->count; for (i = 0; i < p->count; ++i) p->events[i] = *events->events[i]; 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, j = 0; assert(p->started && !input); for (i = 0; i < frames; ++i) { while (j < p->count && p->events[j].offset == i) { unsigned char *m = p->events[j++].data; if ((m[0]&240) == 144) p->level = (float)m[2]/127; else if ((m[0]&240) == 128 || ((m[0]&240) == 176 && m[1] == 120)) p->level = 0; } output[0][i] = p->level; } p->count = 0; } 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 = 0; p->effect.outputs = 1; if (getenv("XTC_VST2_FIXTURE_LAYOUT")) p->effect.inputs = 2; p->effect.flags = 16|256; p->effect.unique_id = 0x58544332; p->effect.replace = process; return &p->effect; }