Move ParameterDescriptor from Plugin to its own header.

This fixes circular dependency issues that arise when using ParameterDescriptor more widely.
This commit is contained in:
David Robillard
2014-10-31 23:48:27 -04:00
parent bd6ba1717e
commit 6dfb11c2d0
12 changed files with 108 additions and 68 deletions

View File

@@ -262,7 +262,7 @@ GenericPluginUI::build ()
= boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
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<Plugin::ParameterDescriptor> Descs;
typedef std::vector<ParameterDescriptor> 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<AutomationControl> mcontrol,
bool is_input)
{
@@ -601,7 +601,7 @@ GenericPluginUI::build_control_ui (const Plugin::ParameterDescriptor& desc,
std::vector<std::string> 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()));
}

View File

@@ -233,7 +233,7 @@ class GenericPluginUI : public PlugUIBase, public Gtk::VBox
/* input */
Gtk::ComboBoxText* combo;
boost::shared_ptr<ARDOUR::Plugin::ScalePoints> scale_points;
boost::shared_ptr<ARDOUR::ScalePoints> scale_points;
Gtk::ToggleButton* button;
boost::shared_ptr<AutomationController> 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<ARDOUR::AutomationControl> 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<uint32_t, Gtk::FileChooserButton*> PropertyControls;

View File

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

View File

@@ -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<Plugin::ScalePoints>
boost::shared_ptr<ScalePoints>
get_scale_points(uint32_t port_index) const;
int set_state (const XMLNode&, int version);

View File

@@ -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<Plugin::ScalePoints>
boost::shared_ptr<ScalePoints>
get_scale_points(uint32_t port_index) const;
void set_insert_info(const PluginInsert* insert);

View File

@@ -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<const std::string, const float> 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<ScalePoints> 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__

View File

@@ -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<const std::string, const float> 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<ScalePoints> scale_points;
};
XMLNode& get_state ();
virtual int set_state (const XMLNode &, int version);

View File

@@ -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)

View File

@@ -642,10 +642,10 @@ LadspaPlugin::print_parameter (uint32_t param, char *buf, uint32_t len) const
}
}
boost::shared_ptr<Plugin::ScalePoints>
boost::shared_ptr<ScalePoints>
LadspaPlugin::get_scale_points(uint32_t port_index) const
{
boost::shared_ptr<Plugin::ScalePoints> ret;
boost::shared_ptr<ScalePoints> 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<Plugin::ScalePoints>(new ScalePoints());
ret = boost::shared_ptr<ScalePoints>(new ScalePoints());
for (uint32_t i = 0; i < points->count; ++i) {
ret->insert(make_pair(points->items[i].label,

View File

@@ -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<Plugin::ScalePoints>
boost::shared_ptr<ScalePoints>
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<Plugin::ScalePoints> ret;
boost::shared_ptr<ScalePoints> ret;
if (!points) {
return ret;
}
ret = boost::shared_ptr<Plugin::ScalePoints>(new ScalePoints());
ret = boost::shared_ptr<ScalePoints>(new ScalePoints());
LILV_FOREACH(scale_points, i, points) {
const LilvScalePoint* p = lilv_scale_points_get(points, i);

View File

@@ -240,7 +240,7 @@ PluginInsert::create_automatable_parameters ()
set<Evoral::Parameter> a = _plugins.front()->automatable ();
Plugin::ParameterDescriptor desc;
ParameterDescriptor desc;
for (set<Evoral::Parameter>::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> plugin = p->plugin (0);
alist()->reset_default (plugin->default_value (param.id()));

View File

@@ -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<AutomationControl> c = pi->automation_control (Evoral::Parameter(PluginAutomation, 0, controlid));