From 6dfb11c2d08201f1a27818955707590b762f5a40 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 31 Oct 2014 23:48:27 -0400 Subject: Move ParameterDescriptor from Plugin to its own header. This fixes circular dependency issues that arise when using ParameterDescriptor more widely. --- gtk2_ardour/generic_pluginui.cc | 18 ++++---- gtk2_ardour/plugin_ui.h | 8 ++-- libs/ardour/ardour/audio_unit.h | 2 +- libs/ardour/ardour/ladspa_plugin.h | 2 +- libs/ardour/ardour/lv2_plugin.h | 2 +- libs/ardour/ardour/parameter_descriptor.h | 74 +++++++++++++++++++++++++++++++ libs/ardour/ardour/plugin.h | 42 +----------------- libs/ardour/ardour/variant.h | 1 + libs/ardour/ladspa_plugin.cc | 6 +-- libs/ardour/lv2_plugin.cc | 11 +++-- libs/ardour/plugin_insert.cc | 6 +-- libs/surfaces/osc/osc.cc | 4 +- 12 files changed, 108 insertions(+), 68 deletions(-) create mode 100644 libs/ardour/ardour/parameter_descriptor.h diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index b50d888f2f..459c8d54d9 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -262,7 +262,7 @@ GenericPluginUI::build () = boost::dynamic_pointer_cast( insert->control(Evoral::Parameter(PluginAutomation, 0, i))); - Plugin::ParameterDescriptor desc; + ParameterDescriptor desc; plugin->get_parameter_descriptor(i, desc); if ((cui = build_control_ui (desc, c, plugin->parameter_is_input(i))) == 0) { error << string_compose(_("Plugin Editor: could not build control element for port %1"), i) << endmsg; @@ -308,7 +308,7 @@ GenericPluginUI::build () } // Add property controls (currently file chooser button for paths only) - typedef std::vector Descs; + typedef std::vector Descs; Descs descs; plugin->get_supported_properties(descs); for (Descs::const_iterator d = descs.begin(); d != descs.end(); ++d) { @@ -514,7 +514,7 @@ GenericPluginUI::integer_printer (char buf[32], Adjustment &adj, ControlUI* cui) float const v = adj.get_value (); if (cui->scale_points) { - Plugin::ScalePoints::const_iterator i = cui->scale_points->begin (); + ScalePoints::const_iterator i = cui->scale_points->begin (); while (i != cui->scale_points->end() && i->second != v) { ++i; } @@ -535,7 +535,7 @@ GenericPluginUI::midinote_printer (char buf[32], Adjustment &adj, ControlUI* cui float const v = adj.get_value (); if (cui->scale_points) { - Plugin::ScalePoints::const_iterator i = cui->scale_points->begin (); + ScalePoints::const_iterator i = cui->scale_points->begin (); while (i != cui->scale_points->end() && i->second != v) { ++i; } @@ -562,7 +562,7 @@ GenericPluginUI::print_parameter (char *buf, uint32_t len, uint32_t param) } GenericPluginUI::ControlUI* -GenericPluginUI::build_control_ui (const Plugin::ParameterDescriptor& desc, +GenericPluginUI::build_control_ui (const ParameterDescriptor& desc, boost::shared_ptr mcontrol, bool is_input) { @@ -601,7 +601,7 @@ GenericPluginUI::build_control_ui (const Plugin::ParameterDescriptor& desc, std::vector labels; for ( - ARDOUR::Plugin::ScalePoints::const_iterator i = control_ui->scale_points->begin(); + ARDOUR::ScalePoints::const_iterator i = control_ui->scale_points->begin(); i != control_ui->scale_points->end(); ++i) { @@ -855,7 +855,7 @@ GenericPluginUI::update_control_display (ControlUI* cui) cui->ignore_change++; if (cui->combo && cui->scale_points) { - for (ARDOUR::Plugin::ScalePoints::iterator it = cui->scale_points->begin(); it != cui->scale_points->end(); ++it) { + for (ARDOUR::ScalePoints::iterator it = cui->scale_points->begin(); it != cui->scale_points->end(); ++it) { if (it->second == val) { cui->combo->set_active_text(it->first); break; @@ -969,8 +969,8 @@ GenericPluginUI::output_update () } void -GenericPluginUI::set_property (const Plugin::ParameterDescriptor& desc, - Gtk::FileChooserButton* widget) +GenericPluginUI::set_property (const ParameterDescriptor& desc, + Gtk::FileChooserButton* widget) { plugin->set_property(desc.key, Variant(Variant::PATH, widget->get_filename())); } diff --git a/gtk2_ardour/plugin_ui.h b/gtk2_ardour/plugin_ui.h index 1f2a390373..9ebd56436e 100644 --- a/gtk2_ardour/plugin_ui.h +++ b/gtk2_ardour/plugin_ui.h @@ -233,7 +233,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox /* input */ Gtk::ComboBoxText* combo; - boost::shared_ptr scale_points; + boost::shared_ptr scale_points; Gtk::ToggleButton* button; boost::shared_ptr controller; Gtkmm2ext::ClickBox* clickbox; @@ -261,7 +261,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox void output_update(); void build (); - ControlUI* build_control_ui (const ARDOUR::Plugin::ParameterDescriptor& desc, + ControlUI* build_control_ui (const ARDOUR::ParameterDescriptor& desc, boost::shared_ptr mcontrol, bool is_input); @@ -282,8 +282,8 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox bool integer_printer (char* buf, Gtk::Adjustment &, ControlUI *); bool midinote_printer(char* buf, Gtk::Adjustment &, ControlUI *); - void set_property (const ARDOUR::Plugin::ParameterDescriptor& desc, - Gtk::FileChooserButton* widget); + void set_property (const ARDOUR::ParameterDescriptor& desc, + Gtk::FileChooserButton* widget); void property_changed (uint32_t key, const ARDOUR::Variant& value); typedef std::map PropertyControls; diff --git a/libs/ardour/ardour/audio_unit.h b/libs/ardour/ardour/audio_unit.h index 8233e208d3..d840c258e7 100644 --- a/libs/ardour/ardour/audio_unit.h +++ b/libs/ardour/ardour/audio_unit.h @@ -48,7 +48,7 @@ namespace ARDOUR { class AudioEngine; class Session; -struct LIBARDOUR_API AUParameterDescriptor : public Plugin::ParameterDescriptor { +struct LIBARDOUR_API AUParameterDescriptor : public ParameterDescriptor { // additional fields to make operations more efficient AudioUnitParameterID id; AudioUnitScope scope; diff --git a/libs/ardour/ardour/ladspa_plugin.h b/libs/ardour/ardour/ladspa_plugin.h index 473953e221..cdcd9dbc6e 100644 --- a/libs/ardour/ardour/ladspa_plugin.h +++ b/libs/ardour/ardour/ladspa_plugin.h @@ -96,7 +96,7 @@ class LIBARDOUR_API LadspaPlugin : public ARDOUR::Plugin bool parameter_is_output(uint32_t) const; bool parameter_is_toggled(uint32_t) const; - boost::shared_ptr + boost::shared_ptr get_scale_points(uint32_t port_index) const; int set_state (const XMLNode&, int version); diff --git a/libs/ardour/ardour/lv2_plugin.h b/libs/ardour/ardour/lv2_plugin.h index 9e0bebad5a..82912a947d 100644 --- a/libs/ardour/ardour/lv2_plugin.h +++ b/libs/ardour/ardour/lv2_plugin.h @@ -116,7 +116,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee bool parameter_is_output (uint32_t) const; bool parameter_is_toggled (uint32_t) const; - boost::shared_ptr + boost::shared_ptr get_scale_points(uint32_t port_index) const; void set_insert_info(const PluginInsert* insert); diff --git a/libs/ardour/ardour/parameter_descriptor.h b/libs/ardour/ardour/parameter_descriptor.h new file mode 100644 index 0000000000..a6315ae429 --- /dev/null +++ b/libs/ardour/ardour/parameter_descriptor.h @@ -0,0 +1,74 @@ +/* + Copyright (C) 2014 Paul Davis + Author: David Robillard + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __ardour_parameter_descriptor_h__ +#define __ardour_parameter_descriptor_h__ + +#include "ardour/variant.h" + +namespace ARDOUR { + +typedef std::map ScalePoints; + +/** Descriptor of a parameter or control. + * + * Essentially a union of LADSPA, VST and LV2 info. + */ +struct ParameterDescriptor +{ + ParameterDescriptor() + : key((uint32_t)-1) + , datatype(Variant::VOID) + , lower(0) + , upper(0) + , step(0) + , smallstep(0) + , largestep(0) + , integer_step(false) + , toggled(false) + , logarithmic(false) + , sr_dependent(false) + , min_unbound(0) + , max_unbound(0) + , enumeration(false) + , midinote(false) + {} + + std::string label; + boost::shared_ptr scale_points; + uint32_t key; ///< for properties + Variant::Type datatype; ///< for properties + float lower; ///< for frequencies, this is in Hz (not a fraction of the sample rate) + float upper; ///< for frequencies, this is in Hz (not a fraction of the sample rate) + float step; + float smallstep; + float largestep; + bool integer_step; + bool toggled; + bool logarithmic; + bool sr_dependent; + bool min_unbound; + bool max_unbound; + bool enumeration; + bool midinote; ///< only used if integer_step is also true +}; + +} // namespace ARDOUR + +#endif // __ardour_parameter_descriptor_h__ diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h index f1a54b073a..dc7dbf68e1 100644 --- a/libs/ardour/ardour/plugin.h +++ b/libs/ardour/ardour/plugin.h @@ -32,6 +32,7 @@ #include "ardour/latent.h" #include "ardour/libardour_visibility.h" #include "ardour/midi_state_tracker.h" +#include "ardour/parameter_descriptor.h" #include "ardour/plugin_insert.h" #include "ardour/types.h" #include "ardour/variant.h" @@ -95,47 +96,6 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent Plugin (const Plugin&); virtual ~Plugin (); - typedef std::map ScalePoints; - - struct ParameterDescriptor { - - ParameterDescriptor () - : integer_step(false) - , toggled (false) - , logarithmic (false) - , sr_dependent (false) - , lower (0) - , upper (0) - , step (0) - , smallstep (0) - , largestep (0) - , min_unbound (0) - , max_unbound (0) - , enumeration (false) - , midinote(false) - {} - - /* essentially a union of LADSPA, VST and LV2 info */ - - bool integer_step; - bool toggled; - bool logarithmic; - bool sr_dependent; - std::string label; - float lower; ///< if this is a frequency, it will be in Hz (not a fraction of the sample rate) - float upper; ///< if this is a frequency, it will be in Hz (not a fraction of the sample rate) - float step; - float smallstep; - float largestep; - bool min_unbound; - bool max_unbound; - bool enumeration; - bool midinote; ///< only used if integer_step is also true - uint32_t key; ///< for properties - Variant::Type datatype; ///< for properties - boost::shared_ptr scale_points; - }; - XMLNode& get_state (); virtual int set_state (const XMLNode &, int version); diff --git a/libs/ardour/ardour/variant.h b/libs/ardour/ardour/variant.h index 00b9c3acf8..1e9dda179a 100644 --- a/libs/ardour/ardour/variant.h +++ b/libs/ardour/ardour/variant.h @@ -34,6 +34,7 @@ class LIBARDOUR_API Variant { public: enum Type { + VOID, ///< Nothing BOOL, ///< Boolean DOUBLE, ///< C double (64-bit IEEE-754) FLOAT, ///< C float (32-bit IEEE-754) diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc index a33e7e0911..4866516b1a 100644 --- a/libs/ardour/ladspa_plugin.cc +++ b/libs/ardour/ladspa_plugin.cc @@ -642,10 +642,10 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const } } -boost::shared_ptr +boost::shared_ptr LadspaPlugin::get_scale_points(uint32_t port_index) const { - boost::shared_ptr ret; + boost::shared_ptr ret; #ifdef HAVE_LRDF const uint32_t id = atol(unique_id().c_str()); lrdf_defaults* points = lrdf_get_scale_values(id, port_index); @@ -654,7 +654,7 @@ LadspaPlugin::get_scale_points(uint32_t port_index) const return ret; } - ret = boost::shared_ptr(new ScalePoints()); + ret = boost::shared_ptr(new ScalePoints()); for (uint32_t i = 0; i < points->count; ++i) { ret->insert(make_pair(points->items[i].label, diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index ac4e213851..4f41b51d1b 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1224,6 +1224,8 @@ static void forge_variant(LV2_Atom_Forge* forge, const Variant& value) { switch (value.type()) { + case Variant::VOID: + break; case Variant::BOOL: lv2_atom_forge_bool(forge, value.get_bool()); break; @@ -1286,6 +1288,9 @@ LV2Plugin::set_property(uint32_t key, const Variant& value) if (_patch_port_in_index == (uint32_t)-1) { error << "LV2: set_property called with unset patch_port_in_index" << endmsg; return; + } else if (value.type() == Variant::VOID) { + error << "LV2: set_property called with void value" << endmsg; + return; } // Set up forge to write to temporary buffer on the stack @@ -2085,18 +2090,18 @@ LV2Plugin::print_parameter(uint32_t param, char* buf, uint32_t len) const } } -boost::shared_ptr +boost::shared_ptr LV2Plugin::get_scale_points(uint32_t port_index) const { const LilvPort* port = lilv_plugin_get_port_by_index(_impl->plugin, port_index); LilvScalePoints* points = lilv_port_get_scale_points(_impl->plugin, port); - boost::shared_ptr ret; + boost::shared_ptr ret; if (!points) { return ret; } - ret = boost::shared_ptr(new ScalePoints()); + ret = boost::shared_ptr(new ScalePoints()); LILV_FOREACH(scale_points, i, points) { const LilvScalePoint* p = lilv_scale_points_get(points, i); diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index b98706a3d0..4ad3123e07 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -240,7 +240,7 @@ PluginInsert::create_automatable_parameters () set a = _plugins.front()->automatable (); - Plugin::ParameterDescriptor desc; + ParameterDescriptor desc; for (set::iterator i = a.begin(); i != a.end(); ++i) { if (i->type() == PluginAutomation) { @@ -1139,7 +1139,7 @@ PluginInsert::set_parameter_state_2X (const XMLNode& node, int version) float min_y = c->alist()->get_min_y (); float max_y = c->alist()->get_max_y (); - Plugin::ParameterDescriptor desc; + ParameterDescriptor desc; _plugins.front()->get_parameter_descriptor (port_id, desc); if (min_y == FLT_MIN) { @@ -1194,7 +1194,7 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Param : AutomationControl (p->session(), param, list, p->describe_parameter(param)) , _plugin (p) { - Plugin::ParameterDescriptor desc; + ParameterDescriptor desc; boost::shared_ptr plugin = p->plugin (0); alist()->reset_default (plugin->default_value (param.id())); diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 648dc4ea19..1e53b895b2 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -1004,7 +1004,7 @@ OSC::route_plugin_parameter (int rid, int piid, int par, float val) return -1; } - Plugin::ParameterDescriptor pd; + ParameterDescriptor pd; pi->plugin()->get_parameter_descriptor (controlid,pd); if (val >= pd.lower && val < pd.upper) { @@ -1051,7 +1051,7 @@ OSC::route_plugin_parameter_print (int rid, int piid, int par) return -1; } - Plugin::ParameterDescriptor pd; + ParameterDescriptor pd; if (pi->plugin()->get_parameter_descriptor (controlid, pd) == 0) { boost::shared_ptr c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid)); -- cgit v1.2.3