Phase 25: improve LADSPA discovery, parameter editing and plugin lifecycle
This commit is contained in:
parent
2fd7724065
commit
7bff7b535d
18 changed files with 591 additions and 42 deletions
|
|
@ -116,6 +116,9 @@ static xtc_result inspect(const LADSPA_Descriptor *d, double rate, xtc_plugin_sp
|
|||
const LADSPA_PortRangeHint *h = d->PortRangeHints+i;
|
||||
if ((LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) && !isfinite(h->LowerBound)) ||
|
||||
(LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) && !isfinite(h->UpperBound)) ||
|
||||
(LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor) &&
|
||||
((LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) && fabs((double)h->LowerBound*rate) > FLT_MAX) ||
|
||||
(LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) && fabs((double)h->UpperBound*rate) > FLT_MAX))) ||
|
||||
(LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) && LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) &&
|
||||
h->LowerBound > h->UpperBound)) return XTC_ERR_UNSUPPORTED;
|
||||
}
|
||||
|
|
@ -135,10 +138,10 @@ xtc_result xtc_plugin_probe(const char *path, unsigned int index, double rate, x
|
|||
if (r == XTC_OK) { strcpy(s.path,path); s.index = index; *out = s; }
|
||||
dlclose(module); return r;
|
||||
}
|
||||
xtc_result xtc_plugin_parameters(const xtc_plugin_spec *s, double rate, xtc_parameter_info out[XTC_PLUGIN_CONTROLS])
|
||||
xtc_result xtc_plugin_describe(const xtc_plugin_spec *s, double rate, xtc_plugin_details *out)
|
||||
{
|
||||
void *module = NULL; const LADSPA_Descriptor *d; xtc_plugin_spec actual = {0};
|
||||
xtc_result r; size_t i;
|
||||
xtc_result r; size_t i; xtc_plugin_details details = {0};
|
||||
if (!out || xtc_plugin_spec_validate(s) != XTC_OK || !isfinite(rate) || rate < 1 || rate > 768000)
|
||||
return XTC_ERR_INVALID_ARGUMENT;
|
||||
r = load(s->path,s->index,&module,&d); if (r != XTC_OK) return r;
|
||||
|
|
@ -153,7 +156,20 @@ xtc_result xtc_plugin_parameters(const xtc_plugin_spec *s, double rate, xtc_para
|
|||
snprintf(p.name,sizeof(p.name),"%s",d->PortNames && d->PortNames[p.id] ? d->PortNames[p.id] : "Control");
|
||||
p.minimum = LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) ? (float)(h->LowerBound*scale) : -FLT_MAX;
|
||||
p.maximum = LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) ? (float)(h->UpperBound*scale) : FLT_MAX;
|
||||
p.default_value = actual.values[i]; out[i] = p;
|
||||
p.default_value = actual.values[i]; details.parameters[i] = p;
|
||||
details.flags[i] = (LADSPA_IS_HINT_INTEGER(h->HintDescriptor) ? XTC_PLUGIN_INTEGER : 0U) |
|
||||
(LADSPA_IS_HINT_TOGGLED(h->HintDescriptor) ? XTC_PLUGIN_TOGGLED : 0U) |
|
||||
(LADSPA_IS_HINT_LOGARITHMIC(h->HintDescriptor) ? XTC_PLUGIN_LOGARITHMIC : 0U) |
|
||||
(LADSPA_IS_HINT_SAMPLE_RATE(h->HintDescriptor) ? XTC_PLUGIN_SAMPLE_RATE : 0U) |
|
||||
(LADSPA_IS_HINT_BOUNDED_BELOW(h->HintDescriptor) ? XTC_PLUGIN_BOUNDED_BELOW : 0U) |
|
||||
(LADSPA_IS_HINT_BOUNDED_ABOVE(h->HintDescriptor) ? XTC_PLUGIN_BOUNDED_ABOVE : 0U);
|
||||
}
|
||||
if (r == XTC_OK) {
|
||||
snprintf(details.name,sizeof(details.name),"%s",d->Name ? d->Name : d->Label);
|
||||
snprintf(details.maker,sizeof(details.maker),"%s",d->Maker ? d->Maker : "Unknown");
|
||||
snprintf(details.copyright,sizeof(details.copyright),"%s",d->Copyright ? d->Copyright : "Unspecified");
|
||||
details.hard_realtime = LADSPA_IS_HARD_RT_CAPABLE(d->Properties) ? 1U : 0U;
|
||||
*out = details;
|
||||
}
|
||||
dlclose(module); return r;
|
||||
}
|
||||
|
|
@ -254,7 +270,7 @@ xtc_result xtc_plugin_process(xtc_plugin *p, const float *input, float *output,
|
|||
{ return xtc_plugin_process_at(p,input,output,frames,p ? p->next : 0); }
|
||||
|
||||
#else
|
||||
xtc_result xtc_plugin_parameters(const xtc_plugin_spec *s, double r, xtc_parameter_info out[XTC_PLUGIN_CONTROLS])
|
||||
xtc_result xtc_plugin_describe(const xtc_plugin_spec *s, double r, xtc_plugin_details *out)
|
||||
{ (void)s; (void)r; (void)out; return XTC_ERR_UNSUPPORTED; }
|
||||
xtc_result xtc_plugin_probe(const char *p, unsigned int i, double r, xtc_plugin_spec *s)
|
||||
{ (void)p; (void)i; (void)r; (void)s; return XTC_ERR_UNSUPPORTED; }
|
||||
|
|
@ -266,3 +282,33 @@ xtc_result xtc_plugin_process_at(xtc_plugin *p, const float *i, float *o, size_t
|
|||
xtc_result xtc_plugin_process(xtc_plugin *p, const float *i, float *o, size_t f)
|
||||
{ (void)p; (void)i; (void)o; (void)f; return XTC_ERR_UNSUPPORTED; }
|
||||
#endif
|
||||
|
||||
xtc_result xtc_plugin_parameters(const xtc_plugin_spec *s, double rate, xtc_parameter_info out[XTC_PLUGIN_CONTROLS])
|
||||
{
|
||||
xtc_plugin_details details;
|
||||
xtc_result r;
|
||||
if (!out) return XTC_ERR_INVALID_ARGUMENT;
|
||||
r = xtc_plugin_describe(s,rate,&details);
|
||||
if (r == XTC_OK) memcpy(out,details.parameters,sizeof(details.parameters));
|
||||
return r;
|
||||
}
|
||||
xtc_result xtc_plugin_reset(xtc_plugin_spec *s, double rate, unsigned int port)
|
||||
{
|
||||
xtc_plugin_details details;
|
||||
xtc_plugin_spec candidate;
|
||||
size_t i, count = 0;
|
||||
int found = port == UINT32_MAX;
|
||||
xtc_result r = xtc_plugin_describe(s,rate,&details);
|
||||
if (r != XTC_OK) return r;
|
||||
candidate = *s;
|
||||
for (i = 0; i < s->control_count; ++i) if (port == UINT32_MAX || s->ports[i] == port) {
|
||||
candidate.values[i] = details.parameters[i].default_value;
|
||||
found = 1;
|
||||
}
|
||||
if (!found) return XTC_ERR_NOT_FOUND;
|
||||
for (i = 0; i < s->point_count; ++i)
|
||||
if (port != UINT32_MAX && s->points[i].port != port) candidate.points[count++] = s->points[i];
|
||||
candidate.point_count = (unsigned int)count;
|
||||
*s = candidate;
|
||||
return XTC_OK;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue