Phase 25: improve LADSPA discovery, parameter editing and plugin lifecycle

This commit is contained in:
Johannes Findeisen 2026-10-27 16:24:21 +01:00
commit 7bff7b535d
18 changed files with 591 additions and 42 deletions

View file

@ -597,6 +597,18 @@ xtc_result xtc_graph_set_plugin(xtc_graph *g, size_t id, const xtc_plugin_spec *
g->nodes[i].plugin = *s; return XTC_OK;
}
xtc_result xtc_graph_replace_plugin(xtc_graph *g, size_t id, const xtc_plugin_spec *s)
{
size_t i;
if (!g || xtc_plugin_spec_validate(s) != XTC_OK) return XTC_ERR_INVALID_ARGUMENT;
i = node_index(g,id);
if (i == SIZE_MAX) return XTC_ERR_NOT_FOUND;
if (g->nodes[i].type != XTC_NODE_PLUGIN) return XTC_ERR_INVALID_ARGUMENT;
if (g->nodes[i].plugin.inputs != s->inputs) return XTC_ERR_UNSUPPORTED;
g->nodes[i].plugin = *s;
return XTC_OK;
}
xtc_result xtc_graph_analyze(const xtc_graph *graph, xtc_routing_info *items, size_t capacity, size_t *count)
{
xtc_routing_info info[XTC_MAX_NODES] = {{0}};

View file

@ -81,6 +81,7 @@ class GraphWidget : public Fl_Widget {
*/
xtc_result add_node(xtc_node_type type);
xtc_result insert_gain();
bool selected_connection(xtc_connection_info &out) const { if (!edge_selected_) return false; out = selected_edge_; return true; }
bool auto_layout(); // Presentation only, no engine publication or undo step.
bool routing(size_t id, xtc_routing_info &info) const;

View file

@ -3,6 +3,7 @@
#include "sequencer_widget.hpp"
#include "piano_roll.hpp"
#include "mixer_widget.hpp"
#include "plugin_dialog.hpp"
#include <FL/Fl_Native_File_Chooser.H>
#include "xtc/xtc_version.h"
@ -76,6 +77,9 @@ MainWindow::MainWindow(bool prompt_unsaved)
menu->add("View/Piano roll", FL_CTRL + '4', piano_callback, this);
menu->add("Audio/Record WAV", FL_SHIFT + FL_F + 5, audio_file_callback, this);
menu->add("File/Load LADSPA plugin", 0, plugin_callback, this);
menu->add("Edit/Replace selected plugin", 0, plugin_callback, this);
menu->add("Edit/Insert LADSPA on selected wire", 0, plugin_callback, this);
menu->add("Edit/Reset selected plugin", 0, plugin_callback, this);
menu->add("Edit/Selected plugin automation", 0, plugin_callback, this);
menu->add("Edit/Selected plugin control", 0, plugin_callback, this);
menu->add("File/Quit", FL_CTRL + 'q', close_callback, this);
@ -1383,11 +1387,58 @@ xtc_result MainWindow::add_plugin(const char *path, unsigned int index, size_t *
xtc_graph *graph = nullptr; size_t added = SIZE_MAX;
if (r == XTC_OK) r = xtc_graph_clone(xtc_project_graph(project_.get()),&graph);
if (r == XTC_OK) r = xtc_graph_add_plugin(graph,&spec,&added);
xtc_plan *check = nullptr;
if (r == XTC_OK) r = xtc_graph_compile(graph,rate,256,&check);
xtc_plan_destroy(check);
if (r == XTC_OK) r = install_plugin_graph(graph);
xtc_graph_destroy(graph);
if (r == XTC_OK) graph_widget_->select_node(added);
if (r == XTC_OK && id) *id = added;
return r;
}
xtc_result MainWindow::replace_plugin(size_t id, const char *path, unsigned int index)
{
if (recorder_) return XTC_ERR_INVALID_STATE;
double rate = 48000; xtc_backend_status status{};
if (ready_ && xtc_backend_get_status(backend_,&status) == XTC_OK) rate = status.sample_rate;
xtc_plugin_spec spec{};
xtc_result r = xtc_plugin_probe(path,index,rate,&spec);
if (r == XTC_OK) r = apply_plugin_spec(id,spec,true);
if (r == XTC_OK) graph_widget_->select_node(id);
return r;
}
xtc_result MainWindow::reset_plugin(size_t id, unsigned int port)
{
if (recorder_) return XTC_ERR_INVALID_STATE;
double rate = 48000; xtc_backend_status status{};
if (ready_ && xtc_backend_get_status(backend_,&status) == XTC_OK) rate = status.sample_rate;
xtc_plugin_spec spec{};
xtc_result r = xtc_graph_get_plugin(xtc_project_graph(project_.get()),id,&spec);
if (r == XTC_OK) r = xtc_plugin_reset(&spec,rate,port);
return r == XTC_OK ? apply_plugin_spec(id,spec) : r;
}
xtc_result MainWindow::insert_plugin(const xtc_connection_info &wire, const char *path, unsigned int index, size_t *id)
{
if (recorder_) return XTC_ERR_INVALID_STATE;
double rate = 48000; xtc_backend_status status{};
if (ready_ && xtc_backend_get_status(backend_,&status) == XTC_OK) rate = status.sample_rate;
xtc_plugin_spec spec{};
xtc_result r = xtc_plugin_probe(path,index,rate,&spec);
if (r == XTC_OK && !spec.inputs) r = XTC_ERR_UNSUPPORTED;
xtc_graph *graph = nullptr; size_t added = SIZE_MAX;
xtc_graph_edit edit{}; edit.kind = XTC_EDIT_DISCONNECT; edit.data.connection = wire;
if (r == XTC_OK) r = xtc_graph_apply_edit(xtc_project_graph(project_.get()),&edit,&graph,nullptr);
if (r == XTC_OK) r = xtc_graph_add_plugin(graph,&spec,&added);
if (r == XTC_OK) r = xtc_graph_connect_ports(graph,wire.source_node,wire.source_port,added,0);
if (r == XTC_OK) r = xtc_graph_connect_ports(graph,added,1,wire.destination_node,wire.destination_port);
xtc_plan *check = nullptr;
if (r == XTC_OK) r = xtc_graph_compile(graph,rate,256,&check);
xtc_plan_destroy(check);
if (r == XTC_OK) r = install_plugin_graph(graph);
xtc_graph_destroy(graph);
if (r == XTC_OK) { graph_widget_->select_node(added); if (id) *id = added; }
return r;
}
xtc_result MainWindow::set_plugin_control(size_t id, unsigned int port, float value)
{
if (recorder_) return XTC_ERR_INVALID_STATE;
@ -1419,11 +1470,11 @@ xtc_result MainWindow::set_plugin_automation(size_t id, const xtc_plugin_point &
}
return apply_plugin_spec(id,spec);
}
xtc_result MainWindow::apply_plugin_spec(size_t id, const xtc_plugin_spec &spec)
xtc_result MainWindow::apply_plugin_spec(size_t id, const xtc_plugin_spec &spec, bool replace)
{
xtc_graph *graph = nullptr;
xtc_result r = xtc_graph_clone(xtc_project_graph(project_.get()),&graph);
if (r == XTC_OK) r = xtc_graph_set_plugin(graph,id,&spec);
if (r == XTC_OK) r = replace ? xtc_graph_replace_plugin(graph,id,&spec) : xtc_graph_set_plugin(graph,id,&spec);
/* Compile before adoption even with a mocked/disconnected backend. */
xtc_plan *check = nullptr;
xtc_backend_status status{}; double rate = 48000;
@ -1440,30 +1491,52 @@ void MainWindow::plugin_callback(Fl_Widget *widget, void *context)
auto *menu = static_cast<Fl_Menu_Bar *>(widget);
const char *label = menu->mvalue()->label();
xtc_result r;
if (std::strcmp(label,"Load LADSPA plugin") == 0) {
if (std::strcmp(label,"Reset selected plugin") == 0) {
r = w->reset_plugin(w->graph_widget_->selected_node());
} else if (std::strcmp(label,"Load LADSPA plugin") == 0 ||
std::strcmp(label,"Replace selected plugin") == 0 ||
std::strcmp(label,"Insert LADSPA on selected wire") == 0) {
const size_t selected = w->graph_widget_->selected_node();
xtc_connection_info wire{};
const bool insert = std::strcmp(label,"Insert LADSPA on selected wire") == 0;
const bool replace = std::strcmp(label,"Replace selected plugin") == 0;
if (insert && !w->graph_widget_->selected_connection(wire)) {
w->report_error("Select an existing wire before inserting an effect",XTC_ERR_INVALID_STATE); return;
}
if (replace) {
xtc_plugin_spec old{};
r = xtc_graph_get_plugin(xtc_project_graph(w->project_.get()),selected,&old);
if (r != XTC_OK) { w->report_error("Select a LADSPA node to replace",r); return; }
}
Fl_Native_File_Chooser chooser;
chooser.title("Load trusted LADSPA module (executes native code)"); chooser.filter("LADSPA\t*.so");
chooser.title("Choose trusted LADSPA module (executes native code)"); chooser.filter("LADSPA\t*.so");
if (chooser.show() != 0 || !chooser.filename()) return;
double rate = 48000; xtc_backend_status status{};
if (w->ready_ && xtc_backend_get_status(w->backend_,&status) == XTC_OK) rate = status.sample_rate;
std::string choices = "Compatible descriptors (index: label):\n";
for (unsigned i = 0; i < 1024; ++i) {
xtc_plugin_spec spec{};
r = xtc_plugin_probe(chooser.filename(),i,rate,&spec);
if (r == XTC_ERR_NOT_FOUND) break;
if (r == XTC_OK) choices += std::to_string(i) + ": " + spec.label + "\n";
unsigned int index = 0;
xtc_plugin_spec probe{};
r = xtc_plugin_probe(chooser.filename(),0,rate,&probe);
if (r != XTC_OK && r != XTC_ERR_UNSUPPORTED) {
w->report_error("Cannot discover LADSPA module; check path, dependencies and ladspa_descriptor export",r); return;
}
choices += "Enter descriptor index:";
const char *answer = fl_input("%s","0",choices.c_str());
if (!answer) return;
char *end = nullptr; errno = 0; unsigned long index = std::strtoul(answer,&end,10);
if (errno || !answer[0] || *end || index >= 1024) r = XTC_ERR_INVALID_ARGUMENT;
else r = w->add_plugin(chooser.filename(),static_cast<unsigned int>(index));
if (!xtc_choose_plugin(chooser.filename(),rate,index)) return;
if (replace) r = w->replace_plugin(selected,chooser.filename(),index);
else if (insert) r = w->insert_plugin(wire,chooser.filename(),index);
else r = w->add_plugin(chooser.filename(),index);
} else {
size_t id = w->graph_widget_->selected_node(); xtc_plugin_spec spec{};
r = xtc_graph_get_plugin(xtc_project_graph(w->project_.get()),id,&spec);
if (r == XTC_OK) {
std::string prompt = std::string(spec.label) + " control ports and values:\n";
if (std::strcmp(label,"Selected plugin control") == 0) {
double rate = 48000; xtc_backend_status status{};
if (w->ready_ && xtc_backend_get_status(w->backend_,&status) == XTC_OK) rate = status.sample_rate;
xtc_plugin_details details{}; xtc_plugin_spec edited{};
r = xtc_plugin_describe(&spec,rate,&details);
if (r == XTC_OK && xtc_edit_plugin(spec,details,edited)) r = w->apply_plugin_spec(id,edited);
if (r != XTC_OK) w->report_error("Plugin editor failed; configuration retained. Check module identity and control ranges",r);
return;
}
xtc_parameter_info info[XTC_PLUGIN_CONTROLS]{};
double rate = 48000; xtc_backend_status status{};
if (w->ready_ && xtc_backend_get_status(w->backend_,&status) == XTC_OK) rate = status.sample_rate;
@ -1487,12 +1560,6 @@ void MainWindow::plugin_callback(Fl_Widget *widget, void *context)
if (r != XTC_OK) w->report_error("Plugin automation rejected: check tick, port, range and discrete mode",r);
return;
}
prompt += "Enter port and value (for example: 2 0.5):";
const char *answer = fl_input("%s","",prompt.c_str());
if (!answer) return;
unsigned port; float value; char extra;
if (std::sscanf(answer,"%u %f %c",&port,&value,&extra) != 2 || !std::isfinite(value)) r = XTC_ERR_INVALID_ARGUMENT;
else r = w->set_plugin_control(id,port,value);
}
}
if (r != XTC_OK) w->report_error("Plugin change failed: check module, mono layout, control port/range and JACK format",r);

View file

@ -22,6 +22,9 @@ class MainWindow : public Fl_Double_Window {
/* Control-thread plugin commands, transactional model adoption. */
xtc_result add_plugin(const char *path, unsigned int index, size_t *id = nullptr);
xtc_result set_plugin_automation(size_t id, const xtc_plugin_point &point, bool remove = false);
xtc_result replace_plugin(size_t id, const char *path, unsigned int index);
xtc_result reset_plugin(size_t id, unsigned int port = UINT32_MAX);
xtc_result insert_plugin(const xtc_connection_info &wire, const char *path, unsigned int index, size_t *id = nullptr);
xtc_result set_plugin_control(size_t id, unsigned int port, float value);
/**
* @brief Constructs the window, its widgets, and the initial project.
@ -290,7 +293,7 @@ class MainWindow : public Fl_Double_Window {
* @param context MainWindow * owning the project and file path.
*/
static void plugin_callback(Fl_Widget *widget, void *context);
xtc_result apply_plugin_spec(size_t id, const xtc_plugin_spec &spec);
xtc_result apply_plugin_spec(size_t id, const xtc_plugin_spec &spec, bool replace = false);
xtc_result install_plugin_graph(xtc_graph *graph);
static void file_callback(Fl_Widget * widget, void *context);
GraphWidget *graph_widget_ = nullptr;

103
src/gui/plugin_dialog.cpp Normal file
View file

@ -0,0 +1,103 @@
#include "plugin_dialog.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Hold_Browser.H>
#include <FL/Fl_Box.H>
#include <FL/Fl_Button.H>
#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Value_Input.H>
#include <FL/Fl_Scroll.H>
#include <FL/fl_ask.H>
#include <array>
#include <vector>
#include <string>
#include <cmath>
namespace {
struct Dialog : Fl_Double_Window {
bool accepted = false;
Dialog(int width, int height, const char *title) : Fl_Double_Window(width,height,title) { set_modal(); }
static void accept(Fl_Widget *, void *data) { auto *d = static_cast<Dialog *>(data); d->accepted = true; d->hide(); }
static void cancel(Fl_Widget *, void *data) { static_cast<Dialog *>(data)->hide(); }
bool run() { callback(cancel,this); end(); show(); while (shown()) Fl::wait(); return accepted; }
};
}
bool xtc_choose_plugin(const char *path, double rate, unsigned int &index)
{
Dialog dialog(760,450,"LADSPA descriptors");
auto *heading = new Fl_Box(15,10,730,40);
heading->copy_label(path); heading->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
auto *list = new Fl_Hold_Browser(15,55,730,325);
list->format_char(0); // Plugin names are data, never browser formatting.
std::vector<unsigned int> indices;
size_t rejected = 0;
for (unsigned int i = 0; i < 1024; ++i) {
xtc_plugin_spec spec{}; xtc_plugin_details details{};
xtc_result r = xtc_plugin_probe(path,i,rate,&spec);
if (r == XTC_ERR_NOT_FOUND) break;
if (r != XTC_OK) { ++rejected; continue; }
if (xtc_plugin_describe(&spec,rate,&details) != XTC_OK) { ++rejected; continue; }
std::string row = std::to_string(i) + ": " + details.name + " (" + spec.label + ") — " + details.maker +
(spec.inputs ? " [effect]" : " [source]");
list->add(row.c_str()); indices.push_back(i);
}
auto *status = new Fl_Box(15,385,520,50);
std::string summary = std::to_string(indices.size()) + " compatible; " + std::to_string(rejected) +
" unsupported/unavailable. Select a descriptor.";
status->copy_label(summary.c_str()); status->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
auto *cancel = new Fl_Button(540,400,90,30,"Cancel"); cancel->callback(Dialog::cancel,&dialog);
auto *choose = new Fl_Return_Button(645,400,100,30,"Choose"); choose->callback(Dialog::accept,&dialog);
if (indices.empty()) choose->deactivate(); else list->select(1);
if (!dialog.run() || list->value() < 1) return false;
index = indices[static_cast<size_t>(list->value()-1)]; return true;
}
bool xtc_edit_plugin(const xtc_plugin_spec &spec, const xtc_plugin_details &details, xtc_plugin_spec &edited)
{
Dialog dialog(800,600,"Plugin identity and controls");
auto *identity = new Fl_Box(15,10,770,125);
std::string text = std::string(details.name) + " — " + details.maker + "\n" + spec.label +
" | LADSPA ID " + std::to_string(spec.unique_id) + " | descriptor " + std::to_string(spec.index) +
"\n" + spec.path + "\n" + details.copyright +
"\nMetadata verified; Apply validates initialization. Units unspecified by LADSPA.";
identity->copy_label(text.c_str()); identity->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
auto *scroll = new Fl_Scroll(10,140,780,370);
std::array<Fl_Value_Input *,XTC_PLUGIN_CONTROLS> inputs{};
for (unsigned int i = 0; i < spec.control_count; ++i) {
int y = 150 + static_cast<int>(i)*65;
const auto &p = details.parameters[i];
std::string name = std::to_string(p.id) + ": " + p.name;
auto *label = new Fl_Box(25,y,425,25); label->copy_label(name.c_str()); label->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
inputs[i] = new Fl_Value_Input(460,y,150,25); inputs[i]->value(spec.values[i]);
inputs[i]->step((details.flags[i] & (XTC_PLUGIN_INTEGER|XTC_PLUGIN_TOGGLED)) ? 1 : 0.001);
std::string hint = "Range " + std::string(details.flags[i] & XTC_PLUGIN_BOUNDED_BELOW ? std::to_string(p.minimum) : "unbounded") +
" .. " + (details.flags[i] & XTC_PLUGIN_BOUNDED_ABOVE ? std::to_string(p.maximum) : "unbounded") +
"; default " + std::to_string(p.default_value) +
((details.flags[i] & XTC_PLUGIN_TOGGLED) ? "; toggle 0/1" : (details.flags[i] & XTC_PLUGIN_INTEGER) ? "; integer" : "; continuous") +
((details.flags[i] & XTC_PLUGIN_LOGARITHMIC) ? "; logarithmic hint" : "");
auto *range = new Fl_Box(25,y+27,715,25); range->copy_label(hint.c_str()); range->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
}
scroll->end();
auto *note = new Fl_Box(15,515,770,30,"Automation overrides static controls. Reset defaults also clears all plugin automation.");
note->labelsize(12);
struct Reset { const xtc_plugin_details *details; std::array<Fl_Value_Input *,XTC_PLUGIN_CONTROLS> *inputs; unsigned int count; bool used; } reset{&details,&inputs,spec.control_count,false};
auto *defaults = new Fl_Button(20,555,170,30,"Reset defaults");
defaults->callback([](Fl_Widget *, void *data) {
auto *r = static_cast<Reset *>(data); r->used = true;
for (unsigned int i = 0; i < r->count; ++i) (*r->inputs)[i]->value(r->details->parameters[i].default_value);
},&reset);
auto *cancel = new Fl_Button(570,555,90,30,"Cancel"); cancel->callback(Dialog::cancel,&dialog);
auto *apply = new Fl_Return_Button(675,555,105,30,"Apply"); apply->callback(Dialog::accept,&dialog);
if (!dialog.run()) return false;
xtc_plugin_spec candidate = spec;
for (unsigned int i = 0; i < spec.control_count; ++i) {
double value = inputs[i]->value(); const auto &p = details.parameters[i]; unsigned int flags = details.flags[i];
if (!std::isfinite(value) || value < p.minimum || value > p.maximum ||
((flags & XTC_PLUGIN_INTEGER) && value != std::floor(value)) ||
((flags & XTC_PLUGIN_TOGGLED) && value != 0 && value != 1)) {
fl_alert("Invalid value for port %u (%s); no controls were changed.",p.id,p.name); return false;
}
candidate.values[i] = static_cast<float>(value);
}
if (reset.used) candidate.point_count = 0;
edited = candidate; return true;
}

View file

@ -0,0 +1,9 @@
#ifndef XTC_PLUGIN_DIALOG_HPP
#define XTC_PLUGIN_DIALOG_HPP
#include "xtc/xtc_plugin.h"
/* Modal, control-thread-only views. They own copied metadata and widget state,
* never engine/module handles. Cancel/close leaves caller configuration intact. */
bool xtc_choose_plugin(const char *path, double rate, unsigned int &index);
bool xtc_edit_plugin(const xtc_plugin_spec &spec, const xtc_plugin_details &details,
xtc_plugin_spec &edited);
#endif

View file

@ -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;
}