/* MIT test fixture; not a redistributed third-party plugin. */ #include #include typedef struct { float *in, *out, *gain; } instance; static unsigned alive, runs; unsigned xtc_fixture_alive(void) { return alive; } unsigned xtc_fixture_runs(void) { return runs; } static LADSPA_Handle create(const LADSPA_Descriptor *d, unsigned long rate) { instance *p; (void)rate; if (d->UniqueID == 900003) return NULL; p = calloc(1,sizeof(*p)); if (p) ++alive; return p; } static void connect(LADSPA_Handle h, unsigned long port, LADSPA_Data *data) { instance *p = h; if (port == 0) p->in = data; else if (port == 1) p->out = data; else p->gain = data; } static void run(LADSPA_Handle h, unsigned long frames) { instance *p = h; unsigned long i; ++runs; for (i = 0; i < frames; ++i) p->out[i] = p->in[i] * *p->gain; } static void source(LADSPA_Handle h, unsigned long frames) { instance *p = h; unsigned long i; ++runs; for (i = 0; i < frames; ++i) p->in[i] = .25f; } static void destroy(LADSPA_Handle h) { if (h) { --alive; free(h); } } static const LADSPA_PortDescriptor ports[] = { LADSPA_PORT_INPUT|LADSPA_PORT_AUDIO, LADSPA_PORT_OUTPUT|LADSPA_PORT_AUDIO, LADSPA_PORT_INPUT|LADSPA_PORT_CONTROL}; static const LADSPA_PortDescriptor source_ports[] = {LADSPA_PORT_OUTPUT|LADSPA_PORT_AUDIO}; static const LADSPA_PortDescriptor stereo_ports[] = { LADSPA_PORT_INPUT|LADSPA_PORT_AUDIO, LADSPA_PORT_INPUT|LADSPA_PORT_AUDIO, LADSPA_PORT_OUTPUT|LADSPA_PORT_AUDIO, LADSPA_PORT_OUTPUT|LADSPA_PORT_AUDIO}; static const char * const names[] = {"Input","Output","Gain","Right output"}; static const LADSPA_PortRangeHint hints[4] = {{0,0,0},{0,0,0}, {LADSPA_HINT_BOUNDED_BELOW|LADSPA_HINT_BOUNDED_ABOVE|LADSPA_HINT_DEFAULT_1,0,2},{0,0,0}}; static const LADSPA_Descriptor descriptors[] = { {.UniqueID=900000,.Label="xtc_test_gain",.Name="Test gain",.PortCount=3,.PortDescriptors=ports, .PortNames=names,.PortRangeHints=hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy}, {.UniqueID=900001,.Label="xtc_test_source",.Name="Test source",.PortCount=1,.PortDescriptors=source_ports, .PortNames=names,.PortRangeHints=hints,.instantiate=create,.connect_port=connect,.run=source,.cleanup=destroy}, {.UniqueID=900002,.Label="xtc_test_stereo",.Name="Unsupported stereo",.PortCount=4,.PortDescriptors=stereo_ports, .PortNames=names,.PortRangeHints=hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy}, {.UniqueID=900003,.Label="xtc_test_fail",.Name="Initialization failure",.PortCount=3,.PortDescriptors=ports, .PortNames=names,.PortRangeHints=hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy} }; const LADSPA_Descriptor *ladspa_descriptor(unsigned long index) { return index < sizeof(descriptors)/sizeof(descriptors[0]) ? descriptors+index : NULL; }