[linux-audio-dev] LADSPA needs & wishes

Fraser fraser at arkhostings.com
Sun Jan 28 05:07:54 UTC 2007


Hi Paul,

> however, it and i think all the other issues you raise are all solved by
> LV2 (LADSPA Version 2), which has come about in part from other people's
> difficulties with the same range of problems as you.

ahh, so there is a V2 coming, not too much info about it yet out there
(unless you know where to look)

>From my quick look at the LV2 spec there's something I'd like to see (this
is just my 2c):

The plugin doesn't know when a parameter has changed, so it must calculate
it's internal values from the displayed parameter 'as often as possible' -
once per run() call (doing it in the for loop itself is just too extreme).

ie from http://lv2plug.in/plugins/Amp-example.lv2/amp.c

#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)

static void runAmp(LV2_Handle instance, unsigned long sample_count) {
	Amp *plugin_data = (Amp *)instance;

	const float gain = *(plugin_data->gain);
	const float * const input = plugin_data->input;
	float * const output = plugin_data->output;

	unsigned long pos;
	float coef = DB_CO(gain);   <-----

	for (pos = 0; pos < sample_count; pos++) {
		output[pos] = input[pos] * coef;
	}
}

better (to me anyway) is to get the run loop down to actually processing
audio and do the conversion elsewhere
ie

static void runAmp(LV2_Handle instance, unsigned long sample_count) {
	Amp *plugin_data = (Amp *)instance;

	const float * const input = plugin_data->input;
	float * const output = plugin_data->output;

	unsigned long pos;

	for (pos = 0; pos < sample_count; pos++) {
		output[pos] = input[pos] * plugin_data->MyTranslatedGain;
	}
}

To do that though the plugin needs to be told when a parameter has changed
so it can work out the new internal value.


#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)

static void paramAmp(LV2_Handle instance, unsigned long port) {
	Amp *plugin_data = (Amp *)instance;

	switch (port) {
	case AMP_GAIN:
		plugin_data->MyTranslatedGain = DB_CO(*(plugin_data->gain));
		break;
         }
}

and a new function in the descriptor
	ampDescriptor->param = paramAmp;

This has the following advantages
1) run() just runs (saved a bit of cpu)
2) internal values are only calculated when the parameter they are
associated with changes
3) changes to parameters can be presented to the run() function immediately
4) the plugin knows when a parameter changed and so can smooth jumps in
values itself (rather then hoping to host is doing it)

with 1 param it's not a big deal, but when you have 10 and end up with
half a page of complex maths in your run() just in case a parameter
changed from the last call you begin to wish it was elsewhere...


> i would personally recommend:
>
>    1) do a LADSPA version and just suck up to the nasty display issues
> of showing the user the raw value unless its an SR-related parameter
>
>    2) be ready to take the core of your plugin and release it as an LV2
> plugin once adoption of it by a couple of hosts emerges. it will be very
> easy to do this, and will open up a world of new possibilities.

ok will do,
looking forward to LV2

regards,
Fraser




More information about the Linux-audio-dev mailing list