Completely localist use of SLV2 to lv2_plugin.cc and lv2_plugin_ui.cc.
git-svn-id: svn://localhost/ardour2/branches/3.0@9514 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
ac367e8904
commit
4e49c56361
|
@ -28,6 +28,12 @@
|
|||
|
||||
#include "lv2_ui.h"
|
||||
|
||||
#include <slv2/slv2.h>
|
||||
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
#include <suil/suil.h>
|
||||
#endif
|
||||
|
||||
using namespace Gtk;
|
||||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
@ -35,7 +41,7 @@ using namespace PBD;
|
|||
#define NS_UI "http://lv2plug.in/ns/extensions/ui#"
|
||||
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
SuilHost* LV2PluginUI::ui_host = NULL;
|
||||
static SuilHost* ui_host = NULL;
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -81,8 +87,9 @@ LV2PluginUI::parameter_update(uint32_t port_index, float val)
|
|||
#ifdef HAVE_SUIL
|
||||
suil_instance_port_event(_inst, port_index, 4, 0, &val);
|
||||
#else
|
||||
const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(_inst);
|
||||
LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_inst);
|
||||
SLV2UIInstance inst = (SLV2UIInstance)_inst;
|
||||
const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(inst);
|
||||
LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(inst);
|
||||
if (ui_desc->port_event) {
|
||||
ui_desc->port_event(ui_handle, port_index, 4, 0, &val);
|
||||
}
|
||||
|
@ -178,9 +185,8 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
}
|
||||
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
if (!LV2PluginUI::ui_host) {
|
||||
LV2PluginUI::ui_host = suil_host_new(
|
||||
LV2PluginUI::lv2_ui_write, NULL, NULL, NULL);
|
||||
if (!ui_host) {
|
||||
ui_host = suil_host_new(LV2PluginUI::lv2_ui_write, NULL, NULL, NULL);
|
||||
}
|
||||
const char* container_type = (is_external_ui)
|
||||
? NS_UI "external"
|
||||
|
@ -188,7 +194,7 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
|
||||
SLV2UI ui = _lv2->slv2_ui();
|
||||
_inst = suil_instance_new(
|
||||
LV2PluginUI::ui_host,
|
||||
ui_host,
|
||||
this,
|
||||
container_type,
|
||||
slv2_value_as_uri(slv2_plugin_get_uri(_lv2->slv2_plugin())),
|
||||
|
@ -198,9 +204,11 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
slv2_uri_to_path(slv2_value_as_uri(slv2_ui_get_binary_uri(ui))),
|
||||
features_dst);
|
||||
#else
|
||||
_inst = slv2_ui_instantiate(
|
||||
_lv2->slv2_plugin(), _lv2->slv2_ui(), LV2PluginUI::lv2_ui_write, this,
|
||||
features_dst);
|
||||
_inst = slv2_ui_instantiate((SLV2Plugin)_lv2->c_plugin(),
|
||||
(SLV2UI)_lv2->c_ui(),
|
||||
LV2PluginUI::lv2_ui_write,
|
||||
this,
|
||||
features_dst);
|
||||
#endif
|
||||
|
||||
if (is_external_ui) {
|
||||
|
@ -208,12 +216,12 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
}
|
||||
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
#define GET_WIDGET(inst) suil_instance_get_widget(inst);
|
||||
#define GET_WIDGET(inst) suil_instance_get_widget((SuilInstance*)inst);
|
||||
#else
|
||||
#define GET_WIDGET(inst) slv2_ui_instance_get_widget(inst);
|
||||
#define GET_WIDGET(inst) slv2_ui_instance_get_widget((SLV2UIInstance)inst);
|
||||
#endif
|
||||
|
||||
uint32_t num_ports = slv2_plugin_get_num_ports(_lv2->slv2_plugin());
|
||||
const uint32_t num_ports = _lv2->num_ports();
|
||||
for (uint32_t i = 0; i < num_ports; ++i) {
|
||||
if (_lv2->parameter_is_output(i)
|
||||
&& _lv2->parameter_is_control(i)
|
||||
|
@ -261,10 +269,11 @@ LV2PluginUI::~LV2PluginUI ()
|
|||
|
||||
/* Close and delete GUI. */
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
suil_instance_free(_inst);
|
||||
suil_instance_free((SuilInstance*)_inst);
|
||||
#else
|
||||
const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(_inst);
|
||||
LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_inst);
|
||||
SLV2UIInstance inst = (SLV2UIInstance)_inst;
|
||||
const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(inst);
|
||||
LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(inst);
|
||||
|
||||
if (ui_desc) {
|
||||
ui_desc->cleanup(ui_handle);
|
||||
|
|
|
@ -36,14 +36,10 @@
|
|||
#include "ardour/types.h"
|
||||
#include "plugin_ui.h"
|
||||
|
||||
#ifdef HAVE_SLV2
|
||||
#ifdef LV2_SUPPORT
|
||||
|
||||
#include "lv2_external_ui.h"
|
||||
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
#include <suil/suil.h>
|
||||
#endif
|
||||
|
||||
namespace ARDOUR {
|
||||
class PluginInsert;
|
||||
class LV2Plugin;
|
||||
|
@ -81,15 +77,7 @@ class LV2PluginUI : public PlugUIBase, public Gtk::VBox
|
|||
|
||||
static void on_external_ui_closed(void* controller);
|
||||
|
||||
#if defined(HAVE_NEW_SLV2) && defined(HAVE_SUIL)
|
||||
static SuilHost* ui_host;
|
||||
static SLV2Value ui_GtkUI;
|
||||
static SLV2Value ui_external;
|
||||
|
||||
SuilInstance* _inst;
|
||||
#else
|
||||
SLV2UIInstance _inst;
|
||||
#endif
|
||||
void* _inst;
|
||||
|
||||
static void lv2_ui_write(
|
||||
void* controller,
|
||||
|
@ -110,7 +98,7 @@ class LV2PluginUI : public PlugUIBase, public Gtk::VBox
|
|||
virtual void on_window_hide();
|
||||
};
|
||||
|
||||
#endif // HAVE_SLV2
|
||||
#endif // LV2_SUPPORT
|
||||
|
||||
#endif /* __ardour_lv2_plugin_ui_h__ */
|
||||
|
||||
|
|
|
@ -340,7 +340,7 @@ PluginSelector::ladspa_refiller (const std::string& filterstr)
|
|||
void
|
||||
PluginSelector::lv2_refiller (const std::string& filterstr)
|
||||
{
|
||||
#ifdef HAVE_SLV2
|
||||
#ifdef LV2_SUPPORT
|
||||
refiller (manager->lv2_plugin_info(), filterstr, "LV2");
|
||||
#endif
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ PluginSelector::build_plugin_menu ()
|
|||
#ifdef HAVE_AUDIOUNITS
|
||||
all_plugs.insert (all_plugs.end(), manager->au_plugin_info().begin(), manager->au_plugin_info().end());
|
||||
#endif
|
||||
#ifdef HAVE_SLV2
|
||||
#ifdef LV2_SUPPORT
|
||||
all_plugs.insert (all_plugs.end(), manager->lv2_plugin_info().begin(), manager->lv2_plugin_info().end());
|
||||
#endif
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
#include "pbd/stateful.h"
|
||||
|
||||
#include <jack/types.h>
|
||||
#include <slv2/slv2.h>
|
||||
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/uri_map.h"
|
||||
|
@ -45,16 +44,18 @@ class LV2Plugin : public ARDOUR::Plugin
|
|||
public:
|
||||
LV2Plugin (ARDOUR::AudioEngine& engine,
|
||||
ARDOUR::Session& session,
|
||||
SLV2Plugin plugin,
|
||||
void* c_plugin,
|
||||
framecnt_t sample_rate);
|
||||
LV2Plugin (const LV2Plugin &);
|
||||
~LV2Plugin ();
|
||||
|
||||
std::string unique_id () const;
|
||||
const char* uri () const;
|
||||
const char* label () const;
|
||||
const char* name () const;
|
||||
const char* maker () const;
|
||||
|
||||
uint32_t num_ports () const;
|
||||
uint32_t parameter_count () const;
|
||||
float default_value (uint32_t port);
|
||||
framecnt_t signal_latency () const;
|
||||
|
@ -63,13 +64,10 @@ class LV2Plugin : public ARDOUR::Plugin
|
|||
int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
|
||||
uint32_t nth_parameter (uint32_t port, bool& ok) const;
|
||||
|
||||
const void* extension_data (const char* uri) {
|
||||
return _instance->lv2_descriptor->extension_data (uri);
|
||||
}
|
||||
const void* extension_data (const char* uri);
|
||||
|
||||
SLV2Plugin slv2_plugin () { return _plugin; }
|
||||
SLV2UI slv2_ui () { return _ui; }
|
||||
SLV2Value ui_type () { return _ui_type; }
|
||||
void* c_plugin();
|
||||
void* c_ui();
|
||||
|
||||
bool is_external_ui () const;
|
||||
|
||||
|
@ -119,14 +117,10 @@ class LV2Plugin : public ARDOUR::Plugin
|
|||
bool has_editor () const;
|
||||
|
||||
private:
|
||||
struct Impl;
|
||||
Impl* _impl;
|
||||
void* _module;
|
||||
LV2_Feature** _features;
|
||||
SLV2Plugin _plugin;
|
||||
SLV2UI _ui;
|
||||
SLV2Value _ui_type;
|
||||
SLV2Value _name;
|
||||
SLV2Value _author;
|
||||
SLV2Instance _instance;
|
||||
framecnt_t _sample_rate;
|
||||
float* _control_data;
|
||||
float* _shadow_data;
|
||||
|
@ -172,7 +166,7 @@ class LV2Plugin : public ARDOUR::Plugin
|
|||
static char* lv2_files_new_file_path (void* host_data,
|
||||
const char* relative_path);
|
||||
|
||||
void init (SLV2Plugin plugin, framecnt_t rate);
|
||||
void init (void* c_plugin, framecnt_t rate);
|
||||
void run (pframes_t nsamples);
|
||||
|
||||
void latency_compute_run ();
|
||||
|
@ -185,14 +179,14 @@ class LV2Plugin : public ARDOUR::Plugin
|
|||
|
||||
class LV2PluginInfo : public PluginInfo {
|
||||
public:
|
||||
LV2PluginInfo (void* slv2_plugin);
|
||||
LV2PluginInfo (void* c_plugin);
|
||||
~LV2PluginInfo ();
|
||||
|
||||
static PluginInfoList* discover ();
|
||||
|
||||
PluginPtr load (Session& session);
|
||||
|
||||
void* _slv2_plugin;
|
||||
void* _c_plugin;
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<LV2PluginInfo> LV2PluginInfoPtr;
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
#include "i18n.h"
|
||||
#include <locale.h>
|
||||
|
||||
#include <slv2/slv2.h>
|
||||
|
||||
#include "lv2ext/lv2_files.h"
|
||||
#include "lv2ext/lv2_persist.h"
|
||||
#include "rdff.h"
|
||||
|
@ -92,23 +94,35 @@ public:
|
|||
|
||||
static LV2World _world;
|
||||
|
||||
struct LV2Plugin::Impl {
|
||||
Impl() : plugin(0), ui(0), ui_type(0), name(0), author(0), instance(0) {}
|
||||
SLV2Plugin plugin;
|
||||
SLV2UI ui;
|
||||
SLV2Value ui_type;
|
||||
SLV2Value name;
|
||||
SLV2Value author;
|
||||
SLV2Instance instance;
|
||||
};
|
||||
|
||||
LV2Plugin::LV2Plugin (AudioEngine& engine,
|
||||
Session& session,
|
||||
SLV2Plugin plugin,
|
||||
void* c_plugin,
|
||||
framecnt_t rate)
|
||||
: Plugin(engine, session)
|
||||
, _impl(new Impl())
|
||||
, _features(NULL)
|
||||
, _insert_id("0")
|
||||
{
|
||||
init(plugin, rate);
|
||||
init(c_plugin, rate);
|
||||
}
|
||||
|
||||
LV2Plugin::LV2Plugin (const LV2Plugin& other)
|
||||
: Plugin(other)
|
||||
, _impl(new Impl())
|
||||
, _features(NULL)
|
||||
, _insert_id(other._insert_id)
|
||||
{
|
||||
init(other._plugin, other._sample_rate);
|
||||
init(other._impl->plugin, other._sample_rate);
|
||||
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i) {
|
||||
_control_data[i] = other._shadow_data[i];
|
||||
|
@ -117,13 +131,13 @@ LV2Plugin::LV2Plugin (const LV2Plugin& other)
|
|||
}
|
||||
|
||||
void
|
||||
LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
||||
LV2Plugin::init(void* c_plugin, framecnt_t rate)
|
||||
{
|
||||
DEBUG_TRACE(DEBUG::LV2, "init\n");
|
||||
|
||||
_plugin = plugin;
|
||||
_ui = NULL;
|
||||
_ui_type = NULL;
|
||||
_impl->plugin = (SLV2Plugin)c_plugin;
|
||||
_impl->ui = NULL;
|
||||
_impl->ui_type = NULL;
|
||||
_control_data = 0;
|
||||
_shadow_data = 0;
|
||||
_latency_control_port = 0;
|
||||
|
@ -136,6 +150,8 @@ LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
|||
_persist_feature.URI = "http://lv2plug.in/ns/ext/persist";
|
||||
_persist_feature.data = NULL;
|
||||
|
||||
SLV2Plugin plugin = _impl->plugin;
|
||||
|
||||
SLV2Value persist_uri = slv2_value_new_uri(_world.world, _persist_feature.URI);
|
||||
_supports_persist = slv2_plugin_has_feature(plugin, persist_uri);
|
||||
slv2_value_free(persist_uri);
|
||||
|
@ -162,32 +178,31 @@ LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
|||
new_file_support->new_file_path = &lv2_files_new_file_path;
|
||||
_new_file_support_feature.data = new_file_support;
|
||||
|
||||
_instance = slv2_plugin_instantiate(plugin, rate, _features);
|
||||
_name = slv2_plugin_get_name(plugin);
|
||||
_author = slv2_plugin_get_author_name(plugin);
|
||||
_impl->instance = slv2_plugin_instantiate(plugin, rate, _features);
|
||||
_impl->name = slv2_plugin_get_name(plugin);
|
||||
_impl->author = slv2_plugin_get_author_name(plugin);
|
||||
|
||||
if (_instance == 0) {
|
||||
error << _("LV2: Failed to instantiate plugin ")
|
||||
<< slv2_value_as_string(slv2_plugin_get_uri(plugin)) << endmsg;
|
||||
if (_impl->instance == 0) {
|
||||
error << _("LV2: Failed to instantiate plugin ") << uri() << endmsg;
|
||||
throw failed_constructor();
|
||||
}
|
||||
|
||||
_instance_access_feature.data = (void*)_instance->lv2_handle;
|
||||
_data_access_extension_data.extension_data = _instance->lv2_descriptor->extension_data;
|
||||
_instance_access_feature.data = (void*)_impl->instance->lv2_handle;
|
||||
_data_access_extension_data.extension_data = _impl->instance->lv2_descriptor->extension_data;
|
||||
_data_access_feature.data = &_data_access_extension_data;
|
||||
|
||||
if (slv2_plugin_has_feature(plugin, _world.in_place_broken)) {
|
||||
error << string_compose(
|
||||
_("LV2: \"%1\" cannot be used, since it cannot do inplace processing"),
|
||||
slv2_value_as_string(_name)) << endmsg;
|
||||
slv2_value_free(_name);
|
||||
slv2_value_free(_author);
|
||||
slv2_value_as_string(_impl->name)) << endmsg;
|
||||
slv2_value_free(_impl->name);
|
||||
slv2_value_free(_impl->author);
|
||||
throw failed_constructor();
|
||||
}
|
||||
|
||||
_sample_rate = rate;
|
||||
|
||||
const uint32_t num_ports = slv2_plugin_get_num_ports(plugin);
|
||||
const uint32_t num_ports = this->num_ports();
|
||||
const bool latent = slv2_plugin_has_latency(plugin);
|
||||
const uint32_t latency_port = (latent)
|
||||
? slv2_plugin_get_latency_port_index(plugin)
|
||||
|
@ -199,7 +214,7 @@ LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
|||
|
||||
for (uint32_t i = 0; i < num_ports; ++i) {
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(plugin, i);
|
||||
SLV2Value sym = slv2_port_get_symbol(_plugin, port);
|
||||
SLV2Value sym = slv2_port_get_symbol(plugin, port);
|
||||
|
||||
// Store index in map so we can look up index by symbol
|
||||
_port_indices.insert(std::make_pair(slv2_value_as_string(sym), i));
|
||||
|
@ -211,7 +226,7 @@ LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
|||
_defaults[i] = def ? slv2_value_as_float(def) : 0.0f;
|
||||
slv2_value_free(def);
|
||||
|
||||
slv2_instance_connect_port(_instance, i, &_control_data[i]);
|
||||
slv2_instance_connect_port(_impl->instance, i, &_control_data[i]);
|
||||
|
||||
if (latent && ( i == latency_port) ) {
|
||||
_latency_control_port = &_control_data[i];
|
||||
|
@ -226,7 +241,7 @@ LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
|||
}
|
||||
}
|
||||
|
||||
SLV2UIs uis = slv2_plugin_get_uis(_plugin);
|
||||
SLV2UIs uis = slv2_plugin_get_uis(plugin);
|
||||
if (slv2_uis_size(uis) > 0) {
|
||||
#if defined(HAVE_NEW_SLV2) and defined(HAVE_SUIL)
|
||||
// Look for embeddable UI
|
||||
|
@ -249,20 +264,20 @@ LV2Plugin::init(SLV2Plugin plugin, framecnt_t rate)
|
|||
for (unsigned i = 0; i < slv2_uis_size(uis); ++i) {
|
||||
SLV2UI ui = slv2_uis_get_at(uis, i);
|
||||
if (slv2_ui_is_a(ui, _world.gtk_gui)) {
|
||||
_ui = ui;
|
||||
_ui_type = _world.gtk_gui;
|
||||
_impl->ui = ui;
|
||||
_impl->ui_type = _world.gtk_gui;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// If Gtk UI is not available, try to find external UI
|
||||
if (!_ui) {
|
||||
if (!_impl->ui) {
|
||||
for (unsigned i = 0; i < slv2_uis_size(uis); ++i) {
|
||||
SLV2UI ui = slv2_uis_get_at(uis, i);
|
||||
if (slv2_ui_is_a(ui, _world.external_gui)) {
|
||||
_ui = ui;
|
||||
_ui_type = _world.external_gui;
|
||||
_impl->ui = ui;
|
||||
_impl->ui_type = _world.external_gui;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -279,11 +294,11 @@ LV2Plugin::~LV2Plugin ()
|
|||
deactivate();
|
||||
cleanup();
|
||||
|
||||
slv2_instance_free(_instance);
|
||||
slv2_value_free(_name);
|
||||
slv2_value_free(_author);
|
||||
slv2_instance_free(_impl->instance);
|
||||
slv2_value_free(_impl->name);
|
||||
slv2_value_free(_impl->author);
|
||||
#if defined(HAVE_NEW_SLV2) and defined(HAVE_SUIL)
|
||||
slv2_value_free(_ui_type);
|
||||
slv2_value_free(_impl->ui_type);
|
||||
#else
|
||||
/* _ui_type points to a global, so leave it alone */
|
||||
#endif
|
||||
|
@ -294,40 +309,52 @@ LV2Plugin::~LV2Plugin ()
|
|||
bool
|
||||
LV2Plugin::is_external_ui() const
|
||||
{
|
||||
if (!_ui) {
|
||||
if (!_impl->ui) {
|
||||
return false;
|
||||
}
|
||||
return slv2_ui_is_a(_ui, _world.external_gui);
|
||||
return slv2_ui_is_a(_impl->ui, _world.external_gui);
|
||||
}
|
||||
|
||||
string
|
||||
LV2Plugin::unique_id() const
|
||||
{
|
||||
return slv2_value_as_uri(slv2_plugin_get_uri(_plugin));
|
||||
return slv2_value_as_uri(slv2_plugin_get_uri(_impl->plugin));
|
||||
}
|
||||
|
||||
const char*
|
||||
LV2Plugin::uri() const
|
||||
{
|
||||
return slv2_value_as_uri(slv2_plugin_get_uri(_impl->plugin));
|
||||
}
|
||||
|
||||
const char*
|
||||
LV2Plugin::label() const
|
||||
{
|
||||
return slv2_value_as_string(_name);
|
||||
return slv2_value_as_string(_impl->name);
|
||||
}
|
||||
|
||||
const char*
|
||||
LV2Plugin::name() const
|
||||
{
|
||||
return slv2_value_as_string(_name);
|
||||
return slv2_value_as_string(_impl->name);
|
||||
}
|
||||
|
||||
const char*
|
||||
LV2Plugin::maker() const
|
||||
{
|
||||
return _author ? slv2_value_as_string (_author) : "Unknown";
|
||||
return _impl->author ? slv2_value_as_string (_impl->author) : "Unknown";
|
||||
}
|
||||
|
||||
uint32_t
|
||||
LV2Plugin::num_ports() const
|
||||
{
|
||||
return slv2_plugin_get_num_ports(_impl->plugin);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
LV2Plugin::parameter_count() const
|
||||
{
|
||||
return slv2_plugin_get_num_ports(_plugin);
|
||||
return slv2_plugin_get_num_ports(_impl->plugin);
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -339,12 +366,12 @@ LV2Plugin::default_value(uint32_t port)
|
|||
const char*
|
||||
LV2Plugin::port_symbol(uint32_t index) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, index);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, index);
|
||||
if (!port) {
|
||||
error << name() << ": Invalid port index " << index << endmsg;
|
||||
}
|
||||
|
||||
SLV2Value sym = slv2_port_get_symbol(_plugin, port);
|
||||
SLV2Value sym = slv2_port_get_symbol(_impl->plugin, port);
|
||||
return slv2_value_as_string(sym);
|
||||
}
|
||||
|
||||
|
@ -354,7 +381,7 @@ LV2Plugin::set_parameter(uint32_t which, float val)
|
|||
DEBUG_TRACE(DEBUG::LV2, string_compose(
|
||||
"%1 set parameter %2 to %3\n", name(), which, val));
|
||||
|
||||
if (which < slv2_plugin_get_num_ports(_plugin)) {
|
||||
if (which < slv2_plugin_get_num_ports(_impl->plugin)) {
|
||||
_shadow_data[which] = val;
|
||||
} else {
|
||||
warning << string_compose(
|
||||
|
@ -381,7 +408,7 @@ uint32_t
|
|||
LV2Plugin::nth_parameter(uint32_t n, bool& ok) const
|
||||
{
|
||||
ok = false;
|
||||
for (uint32_t c = 0, x = 0; x < slv2_plugin_get_num_ports(_plugin); ++x) {
|
||||
for (uint32_t c = 0, x = 0; x < slv2_plugin_get_num_ports(_impl->plugin); ++x) {
|
||||
if (parameter_is_control(x)) {
|
||||
if (c++ == n) {
|
||||
ok = true;
|
||||
|
@ -393,6 +420,24 @@ LV2Plugin::nth_parameter(uint32_t n, bool& ok) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
const void*
|
||||
LV2Plugin::extension_data (const char* uri)
|
||||
{
|
||||
return _impl->instance->lv2_descriptor->extension_data (uri);
|
||||
}
|
||||
|
||||
void*
|
||||
LV2Plugin::c_plugin ()
|
||||
{
|
||||
return _impl->plugin;
|
||||
}
|
||||
|
||||
void*
|
||||
LV2Plugin::c_ui ()
|
||||
{
|
||||
return _impl->ui;
|
||||
}
|
||||
|
||||
struct PersistValue {
|
||||
inline PersistValue(uint32_t k, const void* v, size_t s, uint32_t t, uint32_t f)
|
||||
: key(k), value(v), size(s), type(t), flags(f)
|
||||
|
@ -606,7 +651,7 @@ LV2Plugin::add_state(XMLNode* root) const
|
|||
|
||||
// Get LV2 Persist extension data from plugin instance
|
||||
LV2_Persist* persist = (LV2_Persist*)slv2_instance_get_extension_data(
|
||||
_instance, "http://lv2plug.in/ns/ext/persist");
|
||||
_impl->instance, "http://lv2plug.in/ns/ext/persist");
|
||||
if (!persist) {
|
||||
warning << string_compose(
|
||||
_("Plugin \"%1\% failed to return LV2 persist data"),
|
||||
|
@ -616,7 +661,7 @@ LV2Plugin::add_state(XMLNode* root) const
|
|||
|
||||
// Save plugin state to state object
|
||||
PersistState state(_uri_map);
|
||||
persist->save(_instance->lv2_handle,
|
||||
persist->save(_impl->instance->lv2_handle,
|
||||
&LV2Plugin::lv2_persist_store_callback,
|
||||
&state);
|
||||
|
||||
|
@ -665,10 +710,10 @@ LV2Plugin::find_presets()
|
|||
SLV2Value dc_title = slv2_value_new_uri(_world.world, NS_DC "title");
|
||||
SLV2Value pset_hasPreset = slv2_value_new_uri(_world.world, NS_PSET "hasPreset");
|
||||
|
||||
SLV2Values presets = slv2_plugin_get_value(_plugin, pset_hasPreset);
|
||||
SLV2Values presets = slv2_plugin_get_value(_impl->plugin, pset_hasPreset);
|
||||
for (unsigned i = 0; i < slv2_values_size(presets); ++i) {
|
||||
SLV2Value preset = slv2_values_get_at(presets, i);
|
||||
SLV2Value name = get_value(_plugin, preset, dc_title);
|
||||
SLV2Value name = get_value(_impl->plugin, preset, dc_title);
|
||||
if (name) {
|
||||
_presets.insert(std::make_pair(slv2_value_as_string(preset),
|
||||
PresetRecord(
|
||||
|
@ -699,11 +744,11 @@ LV2Plugin::load_preset(PresetRecord r)
|
|||
SLV2Value pset_value = slv2_value_new_uri(_world.world, NS_PSET "value");
|
||||
SLV2Value preset = slv2_value_new_uri(_world.world, r.uri.c_str());
|
||||
|
||||
SLV2Values ports = slv2_plugin_get_value_for_subject(_plugin, preset, lv2_port);
|
||||
SLV2Values ports = slv2_plugin_get_value_for_subject(_impl->plugin, preset, lv2_port);
|
||||
for (unsigned i = 0; i < slv2_values_size(ports); ++i) {
|
||||
SLV2Value port = slv2_values_get_at(ports, i);
|
||||
SLV2Value symbol = get_value(_plugin, port, lv2_symbol);
|
||||
SLV2Value value = get_value(_plugin, port, pset_value);
|
||||
SLV2Value symbol = get_value(_impl->plugin, port, lv2_symbol);
|
||||
SLV2Value value = get_value(_impl->plugin, port, pset_value);
|
||||
if (value && slv2_value_is_float(value)) {
|
||||
set_parameter(_port_indices[slv2_value_as_string(symbol)],
|
||||
slv2_value_as_float(value));
|
||||
|
@ -721,7 +766,7 @@ LV2Plugin::load_preset(PresetRecord r)
|
|||
"PREFIX dc: <http://dublincore.org/documents/dcmi-namespace/>\n"
|
||||
"SELECT ?sym ?val WHERE { <") + r.uri + "> lv2:port ?port . "
|
||||
" ?port lv2:symbol ?sym ; lv2p:value ?val . }";
|
||||
SLV2Results values = slv2_plugin_query_sparql(_plugin, query.c_str());
|
||||
SLV2Results values = slv2_plugin_query_sparql(_impl->plugin, query.c_str());
|
||||
for (; !slv2_results_finished(values); slv2_results_next(values)) {
|
||||
SLV2Value sym = slv2_results_get_binding_value(values, 0);
|
||||
SLV2Value val = slv2_results_get_binding_value(values, 1);
|
||||
|
@ -748,7 +793,7 @@ LV2Plugin::do_remove_preset(string /*name*/)
|
|||
bool
|
||||
LV2Plugin::has_editor() const
|
||||
{
|
||||
return _ui != NULL;
|
||||
return _impl->ui != NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -818,7 +863,7 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
|
||||
// Get LV2 Persist extension data from plugin instance
|
||||
LV2_Persist* persist = (LV2_Persist*)slv2_instance_get_extension_data(
|
||||
_instance, "http://lv2plug.in/ns/ext/persist");
|
||||
_impl->instance, "http://lv2plug.in/ns/ext/persist");
|
||||
if (persist) {
|
||||
cout << "Loading LV2 state from " << state_path << endl;
|
||||
RDFF file = rdff_open(state_path.c_str(), false);
|
||||
|
@ -843,7 +888,7 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
}
|
||||
free(chunk);
|
||||
|
||||
persist->restore(_instance->lv2_handle,
|
||||
persist->restore(_impl->instance->lv2_handle,
|
||||
&LV2Plugin::lv2_persist_retrieve_callback,
|
||||
&state);
|
||||
rdff_close(file);
|
||||
|
@ -862,16 +907,16 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
int
|
||||
LV2Plugin::get_parameter_descriptor(uint32_t which, ParameterDescriptor& desc) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, which);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, which);
|
||||
|
||||
SLV2Value def, min, max;
|
||||
slv2_port_get_range(_plugin, port, &def, &min, &max);
|
||||
slv2_port_get_range(_impl->plugin, port, &def, &min, &max);
|
||||
|
||||
desc.integer_step = slv2_port_has_property(_plugin, port, _world.integer);
|
||||
desc.toggled = slv2_port_has_property(_plugin, port, _world.toggled);
|
||||
desc.logarithmic = slv2_port_has_property(_plugin, port, _world.logarithmic);
|
||||
desc.sr_dependent = slv2_port_has_property(_plugin, port, _world.srate);
|
||||
desc.label = slv2_value_as_string(slv2_port_get_name(_plugin, port));
|
||||
desc.integer_step = slv2_port_has_property(_impl->plugin, port, _world.integer);
|
||||
desc.toggled = slv2_port_has_property(_impl->plugin, port, _world.toggled);
|
||||
desc.logarithmic = slv2_port_has_property(_impl->plugin, port, _world.logarithmic);
|
||||
desc.sr_dependent = slv2_port_has_property(_impl->plugin, port, _world.srate);
|
||||
desc.label = slv2_value_as_string(slv2_port_get_name(_impl->plugin, port));
|
||||
desc.lower = min ? slv2_value_as_float(min) : 0.0f;
|
||||
desc.upper = max ? slv2_value_as_float(max) : 1.0f;
|
||||
desc.min_unbound = false; // TODO: LV2 extension required
|
||||
|
@ -899,8 +944,8 @@ string
|
|||
LV2Plugin::describe_parameter(Evoral::Parameter which)
|
||||
{
|
||||
if (( which.type() == PluginAutomation) && ( which.id() < parameter_count()) ) {
|
||||
SLV2Value name = slv2_port_get_name(_plugin,
|
||||
slv2_plugin_get_port_by_index(_plugin, which.id()));
|
||||
SLV2Value name = slv2_port_get_name(_impl->plugin,
|
||||
slv2_plugin_get_port_by_index(_impl->plugin, which.id()));
|
||||
string ret(slv2_value_as_string(name));
|
||||
slv2_value_free(name);
|
||||
return ret;
|
||||
|
@ -939,7 +984,7 @@ LV2Plugin::activate()
|
|||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 activate\n", name()));
|
||||
|
||||
if (!_was_activated) {
|
||||
slv2_instance_activate(_instance);
|
||||
slv2_instance_activate(_impl->instance);
|
||||
_was_activated = true;
|
||||
}
|
||||
}
|
||||
|
@ -950,7 +995,7 @@ LV2Plugin::deactivate()
|
|||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 deactivate\n", name()));
|
||||
|
||||
if (_was_activated) {
|
||||
slv2_instance_deactivate(_instance);
|
||||
slv2_instance_deactivate(_impl->instance);
|
||||
_was_activated = false;
|
||||
}
|
||||
}
|
||||
|
@ -962,8 +1007,8 @@ LV2Plugin::cleanup()
|
|||
|
||||
activate();
|
||||
deactivate();
|
||||
slv2_instance_free(_instance);
|
||||
_instance = NULL;
|
||||
slv2_instance_free(_impl->instance);
|
||||
_impl->instance = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -984,27 +1029,27 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
if (parameter_is_audio(port_index)) {
|
||||
if (parameter_is_input(port_index)) {
|
||||
const uint32_t buf_index = in_map.get(DataType::AUDIO, audio_in_index++);
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
slv2_instance_connect_port(_impl->instance, port_index,
|
||||
bufs.get_audio(buf_index).data(offset));
|
||||
} else if (parameter_is_output(port_index)) {
|
||||
const uint32_t buf_index = out_map.get(DataType::AUDIO, audio_out_index++);
|
||||
//cerr << port_index << " : " << " AUDIO OUT " << buf_index << endl;
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
slv2_instance_connect_port(_impl->instance, port_index,
|
||||
bufs.get_audio(buf_index).data(offset));
|
||||
}
|
||||
} else if (parameter_is_midi(port_index)) {
|
||||
if (parameter_is_input(port_index)) {
|
||||
const uint32_t buf_index = in_map.get(DataType::MIDI, midi_in_index++);
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
slv2_instance_connect_port(_impl->instance, port_index,
|
||||
bufs.get_lv2_midi(true, buf_index).data());
|
||||
} else if (parameter_is_output(port_index)) {
|
||||
const uint32_t buf_index = out_map.get(DataType::MIDI, midi_out_index++);
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
slv2_instance_connect_port(_impl->instance, port_index,
|
||||
bufs.get_lv2_midi(false, buf_index).data());
|
||||
}
|
||||
} else if (!parameter_is_control(port_index)) {
|
||||
// Optional port (it'd better be if we've made it this far...)
|
||||
slv2_instance_connect_port(_instance, port_index, NULL);
|
||||
slv2_instance_connect_port(_impl->instance, port_index, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1027,37 +1072,37 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||
bool
|
||||
LV2Plugin::parameter_is_control(uint32_t param) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, param);
|
||||
return slv2_port_is_a(_plugin, port, _world.control_class);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, param);
|
||||
return slv2_port_is_a(_impl->plugin, port, _world.control_class);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_audio(uint32_t param) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, param);
|
||||
return slv2_port_is_a(_plugin, port, _world.audio_class);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, param);
|
||||
return slv2_port_is_a(_impl->plugin, port, _world.audio_class);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_midi(uint32_t param) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, param);
|
||||
return slv2_port_is_a(_plugin, port, _world.event_class);
|
||||
// && slv2_port_supports_event(_plugin, port, _world.midi_class);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, param);
|
||||
return slv2_port_is_a(_impl->plugin, port, _world.event_class);
|
||||
// && slv2_port_supports_event(_impl->plugin, port, _world.midi_class);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_output(uint32_t param) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, param);
|
||||
return slv2_port_is_a(_plugin, port, _world.output_class);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, param);
|
||||
return slv2_port_is_a(_impl->plugin, port, _world.output_class);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_input(uint32_t param) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, param);
|
||||
return slv2_port_is_a(_plugin, port, _world.input_class);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, param);
|
||||
return slv2_port_is_a(_impl->plugin, port, _world.input_class);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1075,8 +1120,8 @@ LV2Plugin::print_parameter(uint32_t param, char* buf, uint32_t len) const
|
|||
boost::shared_ptr<Plugin::ScalePoints>
|
||||
LV2Plugin::get_scale_points(uint32_t port_index) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, port_index);
|
||||
SLV2ScalePoints points = slv2_port_get_scale_points(_plugin, port);
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_impl->plugin, port_index);
|
||||
SLV2ScalePoints points = slv2_port_get_scale_points(_impl->plugin, port);
|
||||
|
||||
boost::shared_ptr<Plugin::ScalePoints> ret;
|
||||
if (!points) {
|
||||
|
@ -1108,7 +1153,7 @@ LV2Plugin::run(pframes_t nframes)
|
|||
}
|
||||
}
|
||||
|
||||
slv2_instance_run(_instance, nframes);
|
||||
slv2_instance_run(_impl->instance, nframes);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1138,10 +1183,10 @@ LV2Plugin::latency_compute_run()
|
|||
while (port_index < parameter_count()) {
|
||||
if (parameter_is_audio(port_index)) {
|
||||
if (parameter_is_input(port_index)) {
|
||||
slv2_instance_connect_port(_instance, port_index, buffer);
|
||||
slv2_instance_connect_port(_impl->instance, port_index, buffer);
|
||||
in_index++;
|
||||
} else if (parameter_is_output(port_index)) {
|
||||
slv2_instance_connect_port(_instance, port_index, buffer);
|
||||
slv2_instance_connect_port(_impl->instance, port_index, buffer);
|
||||
out_index++;
|
||||
}
|
||||
}
|
||||
|
@ -1182,8 +1227,8 @@ LV2World::~LV2World()
|
|||
slv2_value_free(in_place_broken);
|
||||
}
|
||||
|
||||
LV2PluginInfo::LV2PluginInfo (void* slv2_plugin)
|
||||
: _slv2_plugin(slv2_plugin)
|
||||
LV2PluginInfo::LV2PluginInfo (void* c_plugin)
|
||||
: _c_plugin(c_plugin)
|
||||
{
|
||||
type = ARDOUR::LV2;
|
||||
}
|
||||
|
@ -1198,7 +1243,7 @@ LV2PluginInfo::load(Session& session)
|
|||
PluginPtr plugin;
|
||||
|
||||
plugin.reset(new LV2Plugin(session.engine(), session,
|
||||
(SLV2Plugin)_slv2_plugin,
|
||||
(SLV2Plugin)_c_plugin,
|
||||
session.frame_rate()));
|
||||
|
||||
plugin->set_info(PluginInfoPtr(new LV2PluginInfo(*this)));
|
||||
|
|
Loading…
Reference in New Issue
Block a user