simple LADSPA loader

01/11/2012 § 1 Comment

Ladspa has always interested me. So I just happen to play with Ladspa. I am sharing one the many things I did with it.

               Note that the best guide to Ladspa api is ladspa.h itself.

Following is a sample code to load a Ladspa library and display its Name or whatever attribute you like. You can do that by changing fllowing line in the code below:

                               puts (((*fun)(0))->Name);

Where ‘fun’ is a Ladspa descriptor and and is a Ladspa library.

The following code is for Linux based OS (which you might have inferred by seeing the use of ‘dlopen’).

#include <stdlib.h>
#include <stdio.h>
#include <dlfcn.h>

#include "ladspa.h"

int main(int argc, char **argv)
   void *handle;
   LADSPA_Descriptor* (*fun) (unsigned long Index); 
   char *error; 
   handle = dlopen ("./", RTLD_NOW);

   if (!handle)
      fputs (dlerror(), stderr); exit(1);

   fun = dlsym(handle, "ladspa_descriptor");

   if ((error = dlerror()) != NULL)
      fputs(error, stderr); exit(1);

   puts (((*fun)(0))->Name); 

If you can’t get it to work shout out loud in comments section below. 🙂


Where Am I?

You are currently browsing entries tagged with Mixxx at a tryst with DSP.