[linux-audio-dev] +momentary, consolidated (ladspa.h.diff)

Alfons Adriaensen fons.adriaensen at alcatel.be
Tue Mar 9 17:00:24 UTC 2004


On Tue, Mar 09, 2004 at 04:46:58PM +0100, Tim Goetze wrote:

> understood. now please consider the implications for a host: it needs
> to find the offset into the string array where the labels for the
> first ENUMERATED port start. no problem, we use PortCount. then it
> needs to compute how many labels (integer values inside that port's
> range) to find out where the next port's value label enumeration
> starts. and so on for every such port.
> all this code needs to be written in every host, just because you
> don't want to give fool-proof pointers to arrays terminated by a NULL
> element? you must be kidding.

Be reasonable. This is not complicated at all. See code below.


> besides, on the plugin side you end up with a potentially huge array
> of mostly unrelated strings, where index ordering and number is vital.
> a welcome feeding place for bugs here, too.

If you know how to write the PortNames array, adding the label strings
is just the same. They are in the order you'd expect them to be.

> i haven't seen such complicated data structuring practice since the
> days of machine-language coding only. it reminds me more of a binary
> file format spec than of a public API intended for general use.
> i'm also clearly against requiring plugin and host coders to be
> knowledgeable in compiler and binary object format implementation
> and techniques.

This is pure nonsense, and you know it. 


-- 
FA



----------------->8--------------

// Being at work and with no ladspa.h available, there could
// be some errors. Of course this code is incomplete, but its
// only purpose is to show how the label strings are read.


const char * const *N = handle->Portnames;
const LADSPA_PortDescriptor *D = handle->PortDescriptors;
const LADSPA_PortRangeHint  *H = handle->PorRangeHints;
  
int    i, k, h, n;
float  min, max;

k = handle->PortCount; // index of any labels

for (i = 0; i < handle->PortCount; i++)
{
    if (D [i]  & LADSPA_PORT_CONTROL)
    {
        h = H [i].HintDescriptor;
        min = H [i].LowerBound;
        max = H [i].UpperBound;

        if (h & LADPSA_HINT_INTEGER)
        {
 	    if (h & LADSPA_HINT_ENUMERATED)
            {
	        n = (int)(floor (max) - ceil (min)) + 1; // number of labels
                create_widget_with_enums (N [i], min, max, n, N + k);
                k += n; // index of next set of labels
	    }
            else
	    {
                create_widget_no_enums (N [i], min, max);
	    }
	}
        else
        ...
    }
    else
    ...
}


//  So apart from the code that has to be there anyway if the 
//  LADSPA_HINT_ENUMERATED is to be supported, there are 3
//  extra lines:
//
//  k = handle->PortCount; // index of any labels
//  n = (int)(floor (max) - ceil (min)) + 1; // number of labels
//  k += n; // index of next set of labels
//  
//  Go ahead and call this complicated. Or object about the short
//  variable names. Or the indentation style.

----------------->8--------------



More information about the Linux-audio-dev mailing list