/* * host.c * * simple program showing how LADSPA 2 extended port info can be * evaluated. * * (tab size of 2 spaces preferred) */ #include #include #include "ladspa.h" void quit (char * s, int c) { fprintf (c ? stderr : stdout, s); exit (c); } int main (int argc, char ** argv) { void * dlhandle; LADSPA_Descriptor_Function get_descriptor; const LADSPA_Descriptor * d; const LADSPA_PortValueEnum * e; const LADSPA_PortInfo * info; int i; if (argc != 2) quit ("give me a plugin location\n", 1); dlhandle = dlopen (argv[1], RTLD_LAZY); if (!dlhandle) { fprintf (stderr, "dlopen error: %s\n", dlerror()); quit ("can't open shared object\n", 2); } get_descriptor = (LADSPA_Descriptor_Function) dlsym (dlhandle, "ladspa_descriptor"); if (!get_descriptor) quit ("no ladspa_descriptor symbol found\n", 3); d = get_descriptor (0); if (d == 0) quit ("no plugin found\n", 4); printf ("properties: 0x%x\n", d->Properties); if (!LADSPA_HAS_VERSION (d->Properties)) quit ("plugin is not aware of versioning\n", 0); printf ("version: %d.%d\n", d->Version.major, d->Version.minor); if (d->Version.major < 2) quit ("plugin is version 1 or before, quitting\n", 0); printf ("latency: %.1f\n", d->Latency); for (i = 0; i < d->PortCount; ++i) { printf ("--------------------------------------------\n"); printf ("port: %s\n", d->PortNames[i]); info = d->PortInfo + i; printf (" default: %.1f\n", info->Default); printf (" unit: %s\n", info->Unit); if (info->ValueEnum) { e = info->ValueEnum; while (e && e->Label) { printf (" value: %.2f = %s\n", e->Value, e->Label); ++e; } } } return 0; }