1
0
Fork 0
forked from hanez/xtc

Phase 25: improve LADSPA discovery, parameter editing and plugin lifecycle

This commit is contained in:
Johannes Findeisen 2026-10-27 16:24:21 +01:00
commit 7bff7b535d
18 changed files with 591 additions and 42 deletions

View file

@ -1,6 +1,7 @@
/* MIT test fixture; not a redistributed third-party plugin. */
#include <ladspa.h>
#include <stdlib.h>
#include <float.h>
typedef struct { float *in, *out, *gain; } instance;
static unsigned alive, runs;
unsigned xtc_fixture_alive(void) { return alive; }
@ -24,6 +25,8 @@ 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 offset(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); } }
@ -37,15 +40,33 @@ static const LADSPA_PortDescriptor stereo_ports[] = {
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_PortRangeHint discrete_hints[3] = {{0,0,0},{0,0,0},
{LADSPA_HINT_BOUNDED_BELOW|LADSPA_HINT_BOUNDED_ABOVE|LADSPA_HINT_INTEGER|LADSPA_HINT_DEFAULT_MIDDLE,0,3}};
static const LADSPA_PortRangeHint toggle_hints[3] = {{0,0,0},{0,0,0},
{LADSPA_HINT_TOGGLED|LADSPA_HINT_DEFAULT_1,0,0}};
static const LADSPA_PortRangeHint scaled_hints[3] = {{0,0,0},{0,0,0},
{LADSPA_HINT_BOUNDED_BELOW|LADSPA_HINT_BOUNDED_ABOVE|LADSPA_HINT_SAMPLE_RATE|LADSPA_HINT_LOGARITHMIC|LADSPA_HINT_DEFAULT_MIDDLE,.001f,.1f}};
static const LADSPA_PortRangeHint overflow_hints[3] = {{0,0,0},{0,0,0},
{LADSPA_HINT_BOUNDED_ABOVE|LADSPA_HINT_SAMPLE_RATE,0,FLT_MAX}};
static const LADSPA_Descriptor descriptors[] = {
{.UniqueID=900000,.Label="xtc_test_gain",.Name="Test gain",.PortCount=3,.PortDescriptors=ports,
{.UniqueID=900000,.Label="xtc_test_gain",.Name="Test gain",.Maker="xtc tests",.Copyright="MIT",.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}
.PortNames=names,.PortRangeHints=hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy},
{.UniqueID=900004,.Label="xtc_test_integer",.Name="Integer gain",.PortCount=3,.PortDescriptors=ports,
.PortNames=names,.PortRangeHints=discrete_hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy},
{.UniqueID=900005,.Label="xtc_test_toggle",.Name="Toggle gain",.PortCount=3,.PortDescriptors=ports,
.PortNames=names,.PortRangeHints=toggle_hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy},
{.UniqueID=900006,.Label="xtc_test_scaled",.Name="Scaled gain",.PortCount=3,.PortDescriptors=ports,
.PortNames=names,.PortRangeHints=scaled_hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy},
{.UniqueID=900007,.Label="xtc_test_overflow",.Name="Overflow hint",.PortCount=3,.PortDescriptors=ports,
.PortNames=names,.PortRangeHints=overflow_hints,.instantiate=create,.connect_port=connect,.run=run,.cleanup=destroy},
{.UniqueID=900008,.Label="xtc_test_offset",.Name="Offset effect",.PortCount=3,.PortDescriptors=ports,
.PortNames=names,.PortRangeHints=hints,.instantiate=create,.connect_port=connect,.run=offset,.cleanup=destroy}
};
const LADSPA_Descriptor *ladspa_descriptor(unsigned long index)
{ return index < sizeof(descriptors)/sizeof(descriptors[0]) ? descriptors+index : NULL; }