mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-23 05:37:22 +01:00
Uncrustify (no functional changes).
git-svn-id: svn://localhost/ardour2/branches/3.0@9084 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
f000061dc7
commit
fc32ea7642
2 changed files with 242 additions and 241 deletions
|
|
@ -31,19 +31,18 @@ using namespace ARDOUR;
|
|||
using namespace PBD;
|
||||
|
||||
void
|
||||
LV2PluginUI::lv2_ui_write(
|
||||
LV2UI_Controller controller,
|
||||
uint32_t port_index,
|
||||
uint32_t /*buffer_size*/,
|
||||
uint32_t /*format*/,
|
||||
const void* buffer)
|
||||
LV2PluginUI::lv2_ui_write(LV2UI_Controller controller,
|
||||
uint32_t port_index,
|
||||
uint32_t /*buffer_size*/,
|
||||
uint32_t /*format*/,
|
||||
const void* buffer)
|
||||
{
|
||||
//cout << "lv2_ui_write" << endl;
|
||||
LV2PluginUI* me = (LV2PluginUI *) controller;
|
||||
me->_controllables[port_index]->set_value (*(float *) buffer);
|
||||
LV2PluginUI* me = (LV2PluginUI*)controller;
|
||||
me->_controllables[port_index]->set_value(*(float*)buffer);
|
||||
}
|
||||
|
||||
void LV2PluginUI::on_external_ui_closed(LV2UI_Controller controller)
|
||||
void
|
||||
LV2PluginUI::on_external_ui_closed(LV2UI_Controller controller)
|
||||
{
|
||||
LV2PluginUI* me = (LV2PluginUI*)controller;
|
||||
me->_screen_update_connection.disconnect();
|
||||
|
|
@ -51,17 +50,17 @@ void LV2PluginUI::on_external_ui_closed(LV2UI_Controller controller)
|
|||
}
|
||||
|
||||
void
|
||||
LV2PluginUI::parameter_changed (uint32_t port_index, float val)
|
||||
LV2PluginUI::parameter_changed(uint32_t port_index, float val)
|
||||
{
|
||||
PlugUIBase::parameter_changed (port_index, val);
|
||||
|
||||
PlugUIBase::parameter_changed(port_index, val);
|
||||
|
||||
if (val != _values[port_index]) {
|
||||
parameter_update(port_index, val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LV2PluginUI::parameter_update (uint32_t port_index, float val)
|
||||
LV2PluginUI::parameter_update(uint32_t port_index, float val)
|
||||
{
|
||||
if (!_inst) {
|
||||
return;
|
||||
|
|
@ -70,8 +69,8 @@ LV2PluginUI::parameter_update (uint32_t port_index, float val)
|
|||
#ifdef HAVE_NEW_SLV2
|
||||
slv2_ui_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);
|
||||
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);
|
||||
}
|
||||
|
|
@ -85,7 +84,7 @@ LV2PluginUI::start_updating(GdkEventAny*)
|
|||
if (!_output_ports.empty()) {
|
||||
_screen_update_connection.disconnect();
|
||||
_screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
|
||||
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
|
||||
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -95,8 +94,8 @@ LV2PluginUI::stop_updating(GdkEventAny*)
|
|||
{
|
||||
//cout << "stop_updating" << endl;
|
||||
|
||||
if (//!_external_ui_ptr &&
|
||||
!_output_ports.empty()) {
|
||||
if ( //!_external_ui_ptr &&
|
||||
!_output_ports.empty()) {
|
||||
_screen_update_connection.disconnect();
|
||||
}
|
||||
return false;
|
||||
|
|
@ -119,8 +118,9 @@ LV2PluginUI::output_update()
|
|||
|
||||
}
|
||||
|
||||
LV2PluginUI::LV2PluginUI (boost::shared_ptr<PluginInsert> pi, boost::shared_ptr<LV2Plugin> lv2p)
|
||||
: PlugUIBase (pi)
|
||||
LV2PluginUI::LV2PluginUI(boost::shared_ptr<PluginInsert> pi,
|
||||
boost::shared_ptr<LV2Plugin> lv2p)
|
||||
: PlugUIBase(pi)
|
||||
, _lv2(lv2p)
|
||||
, _inst(NULL)
|
||||
, _values(NULL)
|
||||
|
|
@ -137,16 +137,16 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
LV2_Feature** features;
|
||||
LV2_Feature** features_src;
|
||||
LV2_Feature** features_dst;
|
||||
size_t features_count;
|
||||
bool is_external_ui;
|
||||
size_t features_count;
|
||||
bool is_external_ui;
|
||||
|
||||
is_external_ui = _lv2->is_external_ui();
|
||||
|
||||
if (is_external_ui) {
|
||||
_external_ui_host.ui_closed = LV2PluginUI::on_external_ui_closed;
|
||||
_external_ui_host.ui_closed = LV2PluginUI::on_external_ui_closed;
|
||||
_external_ui_host.plugin_human_id = strdup(title.c_str());
|
||||
|
||||
_external_ui_feature.URI = LV2_EXTERNAL_UI_URI;
|
||||
_external_ui_feature.URI = LV2_EXTERNAL_UI_URI;
|
||||
_external_ui_feature.data = &_external_ui_host;
|
||||
|
||||
features_src = features = (LV2_Feature**)_lv2->features();
|
||||
|
|
@ -154,8 +154,8 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
while (*features++) {
|
||||
features_count++;
|
||||
}
|
||||
|
||||
features_dst = features = (LV2_Feature**)malloc(sizeof(LV2_Feature*) * features_count);
|
||||
features_dst = features = (LV2_Feature**)malloc(
|
||||
sizeof(LV2_Feature*) * features_count);
|
||||
features_dst[--features_count] = NULL;
|
||||
features_dst[--features_count] = &_external_ui_feature;
|
||||
while (features_count--) {
|
||||
|
|
@ -167,18 +167,18 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
|
||||
#ifdef HAVE_NEW_SLV2
|
||||
SLV2UIHost ui_host = slv2_ui_host_new(
|
||||
this, LV2PluginUI::lv2_ui_write, NULL, NULL, NULL);
|
||||
this, LV2PluginUI::lv2_ui_write, NULL, NULL, NULL);
|
||||
SLV2Value gtk_ui = slv2_value_new_uri(
|
||||
ARDOUR::PluginManager::the_manager()->lv2_world()->world,
|
||||
"http://lv2plug.in/ns/extensions/ui#GtkUI");
|
||||
ARDOUR::PluginManager::the_manager()->lv2_world()->world,
|
||||
"http://lv2plug.in/ns/extensions/ui#GtkUI");
|
||||
_inst = slv2_ui_instance_new(
|
||||
_lv2->slv2_plugin(), _lv2->slv2_ui(), gtk_ui, ui_host, features_dst);
|
||||
_lv2->slv2_plugin(), _lv2->slv2_ui(), gtk_ui, ui_host, features_dst);
|
||||
slv2_value_free(gtk_ui);
|
||||
slv2_ui_host_free(ui_host);
|
||||
#else
|
||||
_inst = slv2_ui_instantiate(
|
||||
_lv2->slv2_plugin(), _lv2->slv2_ui(), LV2PluginUI::lv2_ui_write, this,
|
||||
features_dst);
|
||||
_lv2->slv2_plugin(), _lv2->slv2_ui(), LV2PluginUI::lv2_ui_write, this,
|
||||
features_dst);
|
||||
#endif
|
||||
|
||||
if (is_external_ui) {
|
||||
|
|
@ -187,7 +187,9 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
|
||||
uint32_t num_ports = slv2_plugin_get_num_ports(_lv2->slv2_plugin());
|
||||
for (uint32_t i = 0; i < num_ports; ++i) {
|
||||
if (_lv2->parameter_is_output(i) && _lv2->parameter_is_control(i) && is_update_wanted(i)) {
|
||||
if (_lv2->parameter_is_output(i)
|
||||
&& _lv2->parameter_is_control(i)
|
||||
&& is_update_wanted(i)) {
|
||||
_output_ports.push_back(i);
|
||||
}
|
||||
}
|
||||
|
|
@ -200,21 +202,20 @@ LV2PluginUI::lv2ui_instantiate(const std::string& title)
|
|||
_gui_widget->show_all();
|
||||
pack_start(*_gui_widget, true, true);
|
||||
} else {
|
||||
_external_ui_ptr = (struct lv2_external_ui *)slv2_ui_instance_get_widget(_inst);
|
||||
_external_ui_ptr = (struct lv2_external_ui*)slv2_ui_instance_get_widget(_inst);
|
||||
}
|
||||
}
|
||||
|
||||
_values = new float[num_ports];
|
||||
_controllables.resize (num_ports);
|
||||
_controllables.resize(num_ports);
|
||||
for (uint32_t i = 0; i < num_ports; ++i) {
|
||||
bool ok;
|
||||
bool ok;
|
||||
uint32_t port = _lv2->nth_parameter(i, ok);
|
||||
if (ok) {
|
||||
_values[port] = _lv2->get_parameter(port);
|
||||
_values[port] = _lv2->get_parameter(port);
|
||||
_controllables[port] = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (
|
||||
insert->control (Evoral::Parameter (PluginAutomation, 0, port))
|
||||
);
|
||||
|
||||
insert->control(Evoral::Parameter(PluginAutomation, 0, port)));
|
||||
|
||||
if (_lv2->parameter_is_control(port) && _lv2->parameter_is_input(port)) {
|
||||
parameter_update(port, _values[port]);
|
||||
}
|
||||
|
|
@ -234,15 +235,15 @@ LV2PluginUI::~LV2PluginUI ()
|
|||
#ifdef HAVE_NEW_SLV2
|
||||
slv2_ui_instance_free(_inst);
|
||||
#else
|
||||
const LV2UI_Descriptor* ui_desc = slv2_ui_instance_get_descriptor(_inst);
|
||||
LV2UI_Handle ui_handle = slv2_ui_instance_get_handle(_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);
|
||||
}
|
||||
#endif
|
||||
|
||||
_screen_update_connection.disconnect();
|
||||
|
||||
_screen_update_connection.disconnect();
|
||||
|
||||
if (_lv2->is_external_ui()) {
|
||||
/* External UI is no longer valid.
|
||||
|
|
@ -253,36 +254,38 @@ LV2PluginUI::~LV2PluginUI ()
|
|||
}
|
||||
|
||||
int
|
||||
LV2PluginUI::get_preferred_height ()
|
||||
LV2PluginUI::get_preferred_height()
|
||||
{
|
||||
Gtk::Requisition r = size_request();
|
||||
return r.height;
|
||||
}
|
||||
|
||||
int
|
||||
LV2PluginUI::get_preferred_width ()
|
||||
LV2PluginUI::get_preferred_width()
|
||||
{
|
||||
Gtk::Requisition r = size_request();
|
||||
return r.width;
|
||||
}
|
||||
|
||||
int
|
||||
LV2PluginUI::package (Gtk::Window& win)
|
||||
LV2PluginUI::package(Gtk::Window& win)
|
||||
{
|
||||
//cout << "package" << endl;
|
||||
if (_external_ui_ptr) {
|
||||
_win_ptr = &win;
|
||||
} else {
|
||||
/* forward configure events to plugin window */
|
||||
win.signal_configure_event().connect (sigc::mem_fun (*this, &LV2PluginUI::configure_handler));
|
||||
win.signal_map_event().connect (sigc::mem_fun (*this, &LV2PluginUI::start_updating));
|
||||
win.signal_unmap_event().connect (sigc::mem_fun (*this, &LV2PluginUI::stop_updating));
|
||||
win.signal_configure_event().connect(
|
||||
sigc::mem_fun(*this, &LV2PluginUI::configure_handler));
|
||||
win.signal_map_event().connect(
|
||||
sigc::mem_fun(*this, &LV2PluginUI::start_updating));
|
||||
win.signal_unmap_event().connect(
|
||||
sigc::mem_fun(*this, &LV2PluginUI::stop_updating));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
LV2PluginUI::configure_handler (GdkEventConfigure*)
|
||||
LV2PluginUI::configure_handler(GdkEventConfigure*)
|
||||
{
|
||||
std::cout << "CONFIGURE" << std::endl;
|
||||
return false;
|
||||
|
|
@ -291,7 +294,9 @@ LV2PluginUI::configure_handler (GdkEventConfigure*)
|
|||
bool
|
||||
LV2PluginUI::is_update_wanted(uint32_t /*index*/)
|
||||
{
|
||||
/* FIXME this should check the port notification properties, which nobody sets now anyway :) */
|
||||
/* FIXME: use port notification properties
|
||||
and/or new UI extension subscription methods
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -313,7 +318,7 @@ LV2PluginUI::on_window_show(const std::string& title)
|
|||
LV2_EXTERNAL_UI_SHOW(_external_ui_ptr);
|
||||
_screen_update_connection.disconnect();
|
||||
_screen_update_connection = ARDOUR_UI::instance()->RapidScreenUpdate.connect
|
||||
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
|
||||
(sigc::mem_fun(*this, &LV2PluginUI::output_update));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,40 +57,40 @@ using namespace std;
|
|||
using namespace ARDOUR;
|
||||
using namespace PBD;
|
||||
|
||||
URIMap LV2Plugin::_uri_map;
|
||||
uint32_t LV2Plugin::_midi_event_type = _uri_map.uri_to_id (
|
||||
"http://lv2plug.in/ns/ext/event",
|
||||
"http://lv2plug.in/ns/ext/midi#MidiEvent");
|
||||
URIMap LV2Plugin:: _uri_map;
|
||||
uint32_t LV2Plugin::_midi_event_type = _uri_map.uri_to_id(
|
||||
"http://lv2plug.in/ns/ext/event",
|
||||
"http://lv2plug.in/ns/ext/midi#MidiEvent");
|
||||
|
||||
LV2Plugin::LV2Plugin (AudioEngine& engine,
|
||||
Session& session,
|
||||
LV2World& world,
|
||||
SLV2Plugin plugin,
|
||||
framecnt_t rate)
|
||||
: Plugin (engine, session)
|
||||
, _world (world)
|
||||
, _features (NULL)
|
||||
: Plugin(engine, session)
|
||||
, _world(world)
|
||||
, _features(NULL)
|
||||
{
|
||||
init (world, plugin, rate);
|
||||
init(world, plugin, rate);
|
||||
}
|
||||
|
||||
LV2Plugin::LV2Plugin (const LV2Plugin &other)
|
||||
: Plugin (other)
|
||||
LV2Plugin::LV2Plugin (const LV2Plugin& other)
|
||||
: Plugin(other)
|
||||
, _world(other._world)
|
||||
, _features(NULL)
|
||||
{
|
||||
init (other._world, other._plugin, other._sample_rate);
|
||||
init(other._world, other._plugin, other._sample_rate);
|
||||
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i) {
|
||||
_control_data[i] = other._shadow_data[i];
|
||||
_shadow_data[i] = other._shadow_data[i];
|
||||
_shadow_data[i] = other._shadow_data[i];
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
||||
LV2Plugin::init(LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, "LV2 plugin init\n");
|
||||
DEBUG_TRACE(DEBUG::LV2, "LV2 plugin init\n");
|
||||
|
||||
_world = world;
|
||||
_plugin = plugin;
|
||||
|
|
@ -122,7 +122,7 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
|||
|
||||
if (_instance == 0) {
|
||||
error << _("LV2: Failed to instantiate plugin ")
|
||||
<< slv2_value_as_string (slv2_plugin_get_uri(plugin)) << endmsg;
|
||||
<< slv2_value_as_string(slv2_plugin_get_uri(plugin)) << endmsg;
|
||||
throw failed_constructor();
|
||||
}
|
||||
|
||||
|
|
@ -132,8 +132,8 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
|||
|
||||
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;
|
||||
_("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);
|
||||
throw failed_constructor();
|
||||
|
|
@ -144,7 +144,7 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
|||
const uint32_t num_ports = slv2_plugin_get_num_ports(plugin);
|
||||
const bool latent = slv2_plugin_has_latency(plugin);
|
||||
const uint32_t latency_port = (latent)
|
||||
? slv2_plugin_get_latency_port_index(plugin)
|
||||
? slv2_plugin_get_latency_port_index(plugin)
|
||||
: 0;
|
||||
|
||||
_control_data = new float[num_ports];
|
||||
|
|
@ -154,22 +154,26 @@ LV2Plugin::init (LV2World& world, 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);
|
||||
|
||||
// Store index in map so we can look up index by symbol
|
||||
_port_indices.insert(std::make_pair(slv2_value_as_string(sym), i));
|
||||
|
||||
// Get range and default value if applicable
|
||||
if (parameter_is_control(i)) {
|
||||
SLV2Value def;
|
||||
slv2_port_get_range(plugin, port, &def, NULL, NULL);
|
||||
_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(_instance, i, &_control_data[i]);
|
||||
|
||||
if (latent && i == latency_port) {
|
||||
_latency_control_port = &_control_data[i];
|
||||
if (latent && ( i == latency_port) ) {
|
||||
_latency_control_port = &_control_data[i];
|
||||
*_latency_control_port = 0;
|
||||
}
|
||||
|
||||
if (parameter_is_input(i)) {
|
||||
_shadow_data[i] = default_value (i);
|
||||
_shadow_data[i] = default_value(i);
|
||||
}
|
||||
} else {
|
||||
_defaults[i] = 0.0f;
|
||||
|
|
@ -178,7 +182,8 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
|||
|
||||
SLV2UIs uis = slv2_plugin_get_uis(_plugin);
|
||||
if (slv2_uis_size(uis) > 0) {
|
||||
for (unsigned i=0; i < slv2_uis_size(uis); ++i) {
|
||||
// Look for Gtk native 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.gtk_gui)) {
|
||||
_ui = ui;
|
||||
|
|
@ -186,9 +191,9 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
|||
}
|
||||
}
|
||||
|
||||
// if gtk gui is not available, try to find external gui
|
||||
// If Gtk UI is not available, try to find external UI
|
||||
if (!_ui) {
|
||||
for (unsigned i=0; i < slv2_uis_size(uis); ++i) {
|
||||
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;
|
||||
|
|
@ -198,15 +203,15 @@ LV2Plugin::init (LV2World& world, SLV2Plugin plugin, framecnt_t rate)
|
|||
}
|
||||
}
|
||||
|
||||
latency_compute_run ();
|
||||
latency_compute_run();
|
||||
}
|
||||
|
||||
LV2Plugin::~LV2Plugin ()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, string_compose ("%1 destroy\n", name()));
|
||||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 destroy\n", name()));
|
||||
|
||||
deactivate ();
|
||||
cleanup ();
|
||||
deactivate();
|
||||
cleanup();
|
||||
|
||||
slv2_instance_free(_instance);
|
||||
slv2_value_free(_name);
|
||||
|
|
@ -228,15 +233,14 @@ LV2Plugin::unique_id() const
|
|||
return slv2_value_as_uri(slv2_plugin_get_uri(_plugin));
|
||||
}
|
||||
|
||||
|
||||
float
|
||||
LV2Plugin::default_value (uint32_t port)
|
||||
LV2Plugin::default_value(uint32_t port)
|
||||
{
|
||||
return _defaults[port];
|
||||
}
|
||||
|
||||
const char*
|
||||
LV2Plugin::port_symbol (uint32_t index) const
|
||||
LV2Plugin::port_symbol(uint32_t index) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, index);
|
||||
if (!port) {
|
||||
|
|
@ -247,41 +251,41 @@ LV2Plugin::port_symbol (uint32_t index) const
|
|||
return slv2_value_as_string(sym);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
LV2Plugin::set_parameter (uint32_t which, float val)
|
||||
LV2Plugin::set_parameter(uint32_t which, float val)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, string_compose ("%1 set parameter %2 to %3\n", name(), which, 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)) {
|
||||
_shadow_data[which] = val;
|
||||
} else {
|
||||
warning << string_compose (
|
||||
_("Illegal parameter number used with plugin \"%1\". "
|
||||
"This is a bug in either %2 or the LV2 plugin (%3)"),
|
||||
name(), PROGRAM_NAME, unique_id()) << endmsg;
|
||||
warning << string_compose(
|
||||
_("Illegal parameter number used with plugin \"%1\". "
|
||||
"This is a bug in either %2 or the LV2 plugin <%3>"),
|
||||
name(), PROGRAM_NAME, unique_id()) << endmsg;
|
||||
}
|
||||
|
||||
Plugin::set_parameter (which, val);
|
||||
|
||||
Plugin::set_parameter(which, val);
|
||||
}
|
||||
|
||||
float
|
||||
LV2Plugin::get_parameter (uint32_t which) const
|
||||
LV2Plugin::get_parameter(uint32_t which) const
|
||||
{
|
||||
if (parameter_is_input(which)) {
|
||||
return (float) _shadow_data[which];
|
||||
return (float)_shadow_data[which];
|
||||
} else {
|
||||
return (float) _control_data[which];
|
||||
return (float)_control_data[which];
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
LV2Plugin::nth_parameter (uint32_t n, bool& ok) const
|
||||
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) {
|
||||
if (parameter_is_control (x)) {
|
||||
for (uint32_t c = 0, x = 0; x < slv2_plugin_get_num_ports(_plugin); ++x) {
|
||||
if (parameter_is_control(x)) {
|
||||
if (c++ == n) {
|
||||
ok = true;
|
||||
return x;
|
||||
|
|
@ -319,19 +323,19 @@ LV2Plugin::lv2_persist_retrieve_callback(void* callback_data,
|
|||
}
|
||||
|
||||
void
|
||||
LV2Plugin::add_state (XMLNode* root) const
|
||||
LV2Plugin::add_state(XMLNode* root) const
|
||||
{
|
||||
XMLNode *child;
|
||||
char buf[16];
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
XMLNode* child;
|
||||
char buf[16];
|
||||
LocaleGuard lg(X_("POSIX"));
|
||||
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i){
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i) {
|
||||
if (parameter_is_input(i) && parameter_is_control(i)) {
|
||||
child = new XMLNode("Port");
|
||||
child->add_property("symbol", port_symbol(i));
|
||||
snprintf(buf, sizeof(buf), "%+f", _shadow_data[i]);
|
||||
child->add_property("value", string(buf));
|
||||
root->add_child_nocopy (*child);
|
||||
root->add_child_nocopy(*child);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,17 +343,17 @@ LV2Plugin::add_state (XMLNode* root) const
|
|||
// Create state directory for this plugin instance
|
||||
const std::string state_filename = _id.to_s() + ".lv2pfile";
|
||||
const std::string state_path = Glib::build_filename(
|
||||
_session.plugins_dir(), state_filename);
|
||||
_session.plugins_dir(), state_filename);
|
||||
|
||||
cout << "Saving LV2 plugin state to " << state_path << endl;
|
||||
|
||||
// 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");
|
||||
_instance, "http://lv2plug.in/ns/ext/persist");
|
||||
if (!persist) {
|
||||
warning << string_compose(
|
||||
_("Plugin \"%1\% failed to return LV2 persist data"),
|
||||
unique_id());
|
||||
_("Plugin \"%1\% failed to return LV2 persist data"),
|
||||
unique_id());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -369,7 +373,7 @@ get_value(SLV2Plugin p, SLV2Value subject, SLV2Value predicate)
|
|||
}
|
||||
|
||||
void
|
||||
LV2Plugin::find_presets ()
|
||||
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");
|
||||
|
|
@ -381,12 +385,12 @@ LV2Plugin::find_presets ()
|
|||
if (name) {
|
||||
_presets.insert(std::make_pair(slv2_value_as_string(preset),
|
||||
PresetRecord(
|
||||
slv2_value_as_string(preset),
|
||||
slv2_value_as_string(name))));
|
||||
slv2_value_as_string(preset),
|
||||
slv2_value_as_string(name))));
|
||||
} else {
|
||||
warning << string_compose(
|
||||
_("Plugin \"%1\% preset \"%2%\" is missing a dc:title\n"),
|
||||
unique_id(), slv2_value_as_string(preset));
|
||||
_("Plugin \"%1\% preset \"%2%\" is missing a dc:title\n"),
|
||||
unique_id(), slv2_value_as_string(preset));
|
||||
}
|
||||
}
|
||||
slv2_values_free(presets);
|
||||
|
|
@ -396,13 +400,13 @@ LV2Plugin::find_presets ()
|
|||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::load_preset (PresetRecord r)
|
||||
LV2Plugin::load_preset(PresetRecord r)
|
||||
{
|
||||
Plugin::load_preset (r);
|
||||
Plugin::load_preset(r);
|
||||
|
||||
#ifdef HAVE_NEW_SLV2
|
||||
// New (>= 0.7.0) slv2 no longer supports SPARQL, but exposes blank nodes
|
||||
// so querying ports is possible with the simple API
|
||||
// so querying ports is possible with the simple/fast API
|
||||
SLV2Value lv2_port = slv2_value_new_uri(_world.world, NS_LV2 "port");
|
||||
SLV2Value lv2_symbol = slv2_value_new_uri(_world.world, NS_LV2 "symbol");
|
||||
SLV2Value pset_value = slv2_value_new_uri(_world.world, NS_PSET "value");
|
||||
|
|
@ -426,10 +430,10 @@ LV2Plugin::load_preset (PresetRecord r)
|
|||
slv2_value_free(lv2_port);
|
||||
#else
|
||||
const string query = string(
|
||||
"PREFIX lv2p: <http://lv2plug.in/ns/dev/presets#>\n"
|
||||
"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 . }";
|
||||
"PREFIX lv2p: <http://lv2plug.in/ns/dev/presets#>\n"
|
||||
"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());
|
||||
for (; !slv2_results_finished(values); slv2_results_next(values)) {
|
||||
SLV2Value sym = slv2_results_get_binding_value(values, 0);
|
||||
|
|
@ -445,21 +449,19 @@ LV2Plugin::load_preset (PresetRecord r)
|
|||
}
|
||||
|
||||
std::string
|
||||
LV2Plugin::do_save_preset (string /*name*/)
|
||||
LV2Plugin::do_save_preset(string /*name*/)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
LV2Plugin::do_remove_preset (string /*name*/)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LV2Plugin::do_remove_preset(string /*name*/)
|
||||
{}
|
||||
|
||||
bool
|
||||
LV2Plugin::has_editor() const
|
||||
{
|
||||
return (_ui != NULL);
|
||||
return _ui != NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -479,13 +481,13 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (version < 3000){
|
||||
nodes = node.children ("port");
|
||||
if (version < 3000) {
|
||||
nodes = node.children("port");
|
||||
} else {
|
||||
nodes = node.children ("Port");
|
||||
nodes = node.children("Port");
|
||||
}
|
||||
|
||||
for (iter = nodes.begin(); iter != nodes.end(); ++iter){
|
||||
|
||||
for (iter = nodes.begin(); iter != nodes.end(); ++iter) {
|
||||
|
||||
child = *iter;
|
||||
|
||||
|
|
@ -496,8 +498,8 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
continue;
|
||||
}
|
||||
|
||||
map<string,uint32_t>::iterator i = _port_indices.find(sym);
|
||||
|
||||
map<string, uint32_t>::iterator i = _port_indices.find(sym);
|
||||
|
||||
if (i != _port_indices.end()) {
|
||||
port_id = i->second;
|
||||
} else {
|
||||
|
|
@ -512,7 +514,7 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
continue;
|
||||
}
|
||||
|
||||
set_parameter (port_id, atof(value));
|
||||
set_parameter(port_id, atof(value));
|
||||
}
|
||||
|
||||
if ((prop = node.property("state-file")) != 0) {
|
||||
|
|
@ -521,7 +523,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");
|
||||
_instance, "http://lv2plug.in/ns/ext/persist");
|
||||
if (persist) {
|
||||
cout << "Loading LV2 state from " << state_path << endl;
|
||||
LV2PFile file = lv2_pfile_open(state_path.c_str(), false);
|
||||
|
|
@ -531,34 +533,34 @@ LV2Plugin::set_state(const XMLNode& node, int version)
|
|||
lv2_pfile_close(file);
|
||||
} else {
|
||||
warning << string_compose(
|
||||
_("Plugin \"%1\% failed to return LV2 persist data"),
|
||||
unique_id());
|
||||
_("Plugin \"%1\% failed to return LV2 persist data"),
|
||||
unique_id());
|
||||
}
|
||||
}
|
||||
|
||||
latency_compute_run ();
|
||||
latency_compute_run();
|
||||
|
||||
return Plugin::set_state (node, version);
|
||||
return Plugin::set_state(node, version);
|
||||
}
|
||||
|
||||
int
|
||||
LV2Plugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc) const
|
||||
LV2Plugin::get_parameter_descriptor(uint32_t which, ParameterDescriptor& desc) const
|
||||
{
|
||||
SLV2Port port = slv2_plugin_get_port_by_index(_plugin, which);
|
||||
|
||||
SLV2Value def, min, max;
|
||||
slv2_port_get_range(_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.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
|
||||
desc.max_unbound = false; // TODO: LV2 extension required
|
||||
|
||||
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.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
|
||||
desc.max_unbound = false; // TODO: LV2 extension required
|
||||
|
||||
if (desc.integer_step) {
|
||||
desc.step = 1.0;
|
||||
desc.smallstep = 0.1;
|
||||
|
|
@ -567,7 +569,7 @@ LV2Plugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
|
|||
const float delta = desc.upper - desc.lower;
|
||||
desc.step = delta / 1000.0f;
|
||||
desc.smallstep = delta / 10000.0f;
|
||||
desc.largestep = delta/10.0f;
|
||||
desc.largestep = delta / 10.0f;
|
||||
}
|
||||
|
||||
slv2_value_free(def);
|
||||
|
|
@ -577,11 +579,10 @@ LV2Plugin::get_parameter_descriptor (uint32_t which, ParameterDescriptor& desc)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
string
|
||||
LV2Plugin::describe_parameter (Evoral::Parameter which)
|
||||
LV2Plugin::describe_parameter(Evoral::Parameter which)
|
||||
{
|
||||
if (which.type() == PluginAutomation && which.id() < parameter_count()) {
|
||||
if (( which.type() == PluginAutomation) && ( which.id() < parameter_count()) ) {
|
||||
SLV2Value name = slv2_port_get_name(_plugin,
|
||||
slv2_plugin_get_port_by_index(_plugin, which.id()));
|
||||
string ret(slv2_value_as_string(name));
|
||||
|
|
@ -593,23 +594,23 @@ LV2Plugin::describe_parameter (Evoral::Parameter which)
|
|||
}
|
||||
|
||||
framecnt_t
|
||||
LV2Plugin::signal_latency () const
|
||||
LV2Plugin::signal_latency() const
|
||||
{
|
||||
if (_latency_control_port) {
|
||||
return (framecnt_t) floor (*_latency_control_port);
|
||||
return (framecnt_t)floor(*_latency_control_port);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
set<Evoral::Parameter>
|
||||
LV2Plugin::automatable () const
|
||||
LV2Plugin::automatable() const
|
||||
{
|
||||
set<Evoral::Parameter> ret;
|
||||
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i){
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i) {
|
||||
if (parameter_is_input(i) && parameter_is_control(i)) {
|
||||
ret.insert (ret.end(), Evoral::Parameter(PluginAutomation, 0, i));
|
||||
ret.insert(ret.end(), Evoral::Parameter(PluginAutomation, 0, i));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -617,48 +618,47 @@ LV2Plugin::automatable () const
|
|||
}
|
||||
|
||||
void
|
||||
LV2Plugin::activate ()
|
||||
LV2Plugin::activate()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, string_compose ("%1 activate\n", name()));
|
||||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 activate\n", name()));
|
||||
|
||||
if (!_was_activated) {
|
||||
slv2_instance_activate (_instance);
|
||||
slv2_instance_activate(_instance);
|
||||
_was_activated = true;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LV2Plugin::deactivate ()
|
||||
LV2Plugin::deactivate()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, string_compose ("%1 deactivate\n", name()));
|
||||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 deactivate\n", name()));
|
||||
|
||||
if (_was_activated) {
|
||||
slv2_instance_deactivate (_instance);
|
||||
slv2_instance_deactivate(_instance);
|
||||
_was_activated = false;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LV2Plugin::cleanup ()
|
||||
LV2Plugin::cleanup()
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, string_compose ("%1 cleanup\n", name()));
|
||||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 cleanup\n", name()));
|
||||
|
||||
activate ();
|
||||
deactivate ();
|
||||
slv2_instance_free (_instance);
|
||||
activate();
|
||||
deactivate();
|
||||
slv2_instance_free(_instance);
|
||||
_instance = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
LV2Plugin::connect_and_run (BufferSet& bufs,
|
||||
ChanMapping in_map, ChanMapping out_map,
|
||||
pframes_t nframes, framecnt_t offset)
|
||||
LV2Plugin::connect_and_run(BufferSet& bufs,
|
||||
ChanMapping in_map, ChanMapping out_map,
|
||||
pframes_t nframes, framecnt_t offset)
|
||||
{
|
||||
DEBUG_TRACE (DEBUG::LV2, string_compose ("%1 run %2 offset %3\n", name(), nframes, offset));
|
||||
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 run %2 offset %3\n", name(), nframes, offset));
|
||||
Plugin::connect_and_run(bufs, in_map, out_map, nframes, offset);
|
||||
|
||||
Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
|
||||
|
||||
cycles_t then = get_cycles ();
|
||||
cycles_t then = get_cycles();
|
||||
|
||||
uint32_t audio_in_index = 0;
|
||||
uint32_t audio_out_index = 0;
|
||||
|
|
@ -668,26 +668,23 @@ 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++);
|
||||
//cerr << port_index << " : " << " AUDIO IN " << buf_index << endl;
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
bufs.get_audio(buf_index).data(offset));
|
||||
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,
|
||||
bufs.get_audio(buf_index).data(offset));
|
||||
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++);
|
||||
//cerr << port_index << " : " << " MIDI IN " << buf_index << endl;
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
bufs.get_lv2_midi(true, buf_index).data());
|
||||
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++);
|
||||
//cerr << port_index << " : " << " MIDI OUT " << buf_index << endl;
|
||||
slv2_instance_connect_port(_instance, port_index,
|
||||
bufs.get_lv2_midi(false, buf_index).data());
|
||||
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...)
|
||||
|
|
@ -695,7 +692,7 @@ LV2Plugin::connect_and_run (BufferSet& bufs,
|
|||
}
|
||||
}
|
||||
|
||||
run (nframes);
|
||||
run(nframes);
|
||||
|
||||
midi_out_index = 0;
|
||||
for (uint32_t port_index = 0; port_index < parameter_count(); ++port_index) {
|
||||
|
|
@ -705,28 +702,28 @@ LV2Plugin::connect_and_run (BufferSet& bufs,
|
|||
}
|
||||
}
|
||||
|
||||
cycles_t now = get_cycles ();
|
||||
set_cycles ((uint32_t) (now - then));
|
||||
cycles_t now = get_cycles();
|
||||
set_cycles((uint32_t)(now - then));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_control (uint32_t param) const
|
||||
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);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_audio (uint32_t param) const
|
||||
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);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_midi (uint32_t param) const
|
||||
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);
|
||||
|
|
@ -734,36 +731,36 @@ LV2Plugin::parameter_is_midi (uint32_t param) const
|
|||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_output (uint32_t param) const
|
||||
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);
|
||||
}
|
||||
|
||||
bool
|
||||
LV2Plugin::parameter_is_input (uint32_t param) const
|
||||
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);
|
||||
}
|
||||
|
||||
void
|
||||
LV2Plugin::print_parameter (uint32_t param, char* buf, uint32_t len) const
|
||||
LV2Plugin::print_parameter(uint32_t param, char* buf, uint32_t len) const
|
||||
{
|
||||
if (buf && len) {
|
||||
if (param < parameter_count()) {
|
||||
snprintf (buf, len, "%.3f", get_parameter (param));
|
||||
snprintf(buf, len, "%.3f", get_parameter(param));
|
||||
} else {
|
||||
strcat (buf, "0");
|
||||
strcat(buf, "0");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
LV2Plugin::run (pframes_t nframes)
|
||||
LV2Plugin::run(pframes_t nframes)
|
||||
{
|
||||
for (uint32_t i = 0; i < parameter_count(); ++i) {
|
||||
if (parameter_is_control(i) && parameter_is_input(i)) {
|
||||
if (parameter_is_control(i) && parameter_is_input(i)) {
|
||||
_control_data[i] = _shadow_data[i];
|
||||
}
|
||||
}
|
||||
|
|
@ -772,24 +769,22 @@ LV2Plugin::run (pframes_t nframes)
|
|||
}
|
||||
|
||||
void
|
||||
LV2Plugin::latency_compute_run ()
|
||||
LV2Plugin::latency_compute_run()
|
||||
{
|
||||
if (!_latency_control_port) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* we need to run the plugin so that it can set its latency
|
||||
parameter.
|
||||
*/
|
||||
// Run the plugin so that it can set its latency parameter
|
||||
|
||||
activate ();
|
||||
activate();
|
||||
|
||||
uint32_t port_index = 0;
|
||||
uint32_t in_index = 0;
|
||||
uint32_t out_index = 0;
|
||||
|
||||
const framecnt_t bufsize = 1024;
|
||||
float buffer[bufsize];
|
||||
float buffer[bufsize];
|
||||
|
||||
memset(buffer, 0, sizeof(float) * bufsize);
|
||||
|
||||
|
|
@ -798,20 +793,20 @@ LV2Plugin::latency_compute_run ()
|
|||
port_index = 0;
|
||||
|
||||
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);
|
||||
if (parameter_is_audio(port_index)) {
|
||||
if (parameter_is_input(port_index)) {
|
||||
slv2_instance_connect_port(_instance, port_index, buffer);
|
||||
in_index++;
|
||||
} else if (parameter_is_output (port_index)) {
|
||||
slv2_instance_connect_port (_instance, port_index, buffer);
|
||||
} else if (parameter_is_output(port_index)) {
|
||||
slv2_instance_connect_port(_instance, port_index, buffer);
|
||||
out_index++;
|
||||
}
|
||||
}
|
||||
port_index++;
|
||||
}
|
||||
|
||||
run (bufsize);
|
||||
deactivate ();
|
||||
run(bufsize);
|
||||
deactivate();
|
||||
}
|
||||
|
||||
LV2World::LV2World()
|
||||
|
|
@ -852,41 +847,39 @@ LV2PluginInfo::LV2PluginInfo (void* lv2_world, void* slv2_plugin)
|
|||
}
|
||||
|
||||
LV2PluginInfo::~LV2PluginInfo()
|
||||
{
|
||||
}
|
||||
{}
|
||||
|
||||
PluginPtr
|
||||
LV2PluginInfo::load (Session& session)
|
||||
LV2PluginInfo::load(Session& session)
|
||||
{
|
||||
try {
|
||||
PluginPtr plugin;
|
||||
|
||||
plugin.reset (new LV2Plugin (session.engine(), session,
|
||||
*(LV2World*)_lv2_world, (SLV2Plugin)_slv2_plugin, session.frame_rate()));
|
||||
plugin.reset(new LV2Plugin(session.engine(), session,
|
||||
*(LV2World*)_lv2_world, (SLV2Plugin)_slv2_plugin,
|
||||
session.frame_rate()));
|
||||
|
||||
plugin->set_info(PluginInfoPtr(new LV2PluginInfo(*this)));
|
||||
return plugin;
|
||||
}
|
||||
|
||||
catch (failed_constructor &err) {
|
||||
return PluginPtr ((Plugin*) 0);
|
||||
} catch (failed_constructor& err) {
|
||||
return PluginPtr((Plugin*)0);
|
||||
}
|
||||
|
||||
return PluginPtr();
|
||||
}
|
||||
|
||||
PluginInfoList*
|
||||
LV2PluginInfo::discover (void* lv2_world)
|
||||
LV2PluginInfo::discover(void* lv2_world)
|
||||
{
|
||||
PluginInfoList* plugs = new PluginInfoList;
|
||||
LV2World* world = (LV2World*)lv2_world;
|
||||
SLV2Plugins plugins = slv2_world_get_all_plugins(world->world);
|
||||
|
||||
cerr << "LV2: Discovering " << slv2_plugins_size (plugins) << " plugins" << endl;
|
||||
cerr << "LV2: Discovering " << slv2_plugins_size(plugins) << " plugins" << endl;
|
||||
|
||||
for (unsigned i=0; i < slv2_plugins_size(plugins); ++i) {
|
||||
SLV2Plugin p = slv2_plugins_get_at(plugins, i);
|
||||
LV2PluginInfoPtr info (new LV2PluginInfo(lv2_world, p));
|
||||
for (unsigned i = 0; i < slv2_plugins_size(plugins); ++i) {
|
||||
SLV2Plugin p = slv2_plugins_get_at(plugins, i);
|
||||
LV2PluginInfoPtr info(new LV2PluginInfo(lv2_world, p));
|
||||
|
||||
SLV2Value name = slv2_plugin_get_name(p);
|
||||
|
||||
|
|
@ -901,7 +894,7 @@ LV2PluginInfo::discover (void* lv2_world)
|
|||
slv2_value_free(name);
|
||||
|
||||
SLV2PluginClass pclass = slv2_plugin_get_class(p);
|
||||
SLV2Value label = slv2_plugin_class_get_label(pclass);
|
||||
SLV2Value label = slv2_plugin_class_get_label(pclass);
|
||||
info->category = slv2_value_as_string(label);
|
||||
|
||||
SLV2Value author_name = slv2_plugin_get_author_name(p);
|
||||
|
|
@ -910,24 +903,27 @@ LV2PluginInfo::discover (void* lv2_world)
|
|||
|
||||
info->path = "/NOPATH"; // Meaningless for LV2
|
||||
|
||||
info->n_inputs.set_audio(slv2_plugin_get_num_ports_of_class(p,
|
||||
world->input_class, world->audio_class, NULL));
|
||||
info->n_inputs.set_midi(slv2_plugin_get_num_ports_of_class(p,
|
||||
world->input_class, world->event_class, NULL));
|
||||
info->n_inputs.set_audio(
|
||||
slv2_plugin_get_num_ports_of_class(
|
||||
p, world->input_class, world->audio_class, NULL));
|
||||
info->n_inputs.set_midi(
|
||||
slv2_plugin_get_num_ports_of_class(
|
||||
p, world->input_class, world->event_class, NULL));
|
||||
|
||||
info->n_outputs.set_audio(slv2_plugin_get_num_ports_of_class(p,
|
||||
world->output_class, world->audio_class, NULL));
|
||||
info->n_outputs.set_midi(slv2_plugin_get_num_ports_of_class(p,
|
||||
world->output_class, world->event_class, NULL));
|
||||
info->n_outputs.set_audio(
|
||||
slv2_plugin_get_num_ports_of_class(
|
||||
p, world->output_class, world->audio_class, NULL));
|
||||
info->n_outputs.set_midi(
|
||||
slv2_plugin_get_num_ports_of_class(
|
||||
p, world->output_class, world->event_class, NULL));
|
||||
|
||||
info->unique_id = slv2_value_as_uri(slv2_plugin_get_uri(p));
|
||||
info->index = 0; // Meaningless for LV2
|
||||
info->index = 0; // Meaningless for LV2
|
||||
|
||||
plugs->push_back (info);
|
||||
plugs->push_back(info);
|
||||
}
|
||||
|
||||
cerr << "Done LV2 discovery" << endl;
|
||||
|
||||
return plugs;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue