Add a ReadOnlyControl parameter abstraction
This allows to pass a sperici Controllable alike instance around without relying on directly exposing the Plugin instance and parameter-id.
This commit is contained in:
parent
64f40c09fa
commit
7a489dd553
@ -34,6 +34,7 @@
|
||||
#include "ardour/parameter_descriptor.h"
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/processor.h"
|
||||
#include "ardour/readonly_control.h"
|
||||
#include "ardour/sidechain.h"
|
||||
#include "ardour/automation_control.h"
|
||||
|
||||
@ -243,6 +244,8 @@ class LIBARDOUR_API PluginInsert : public Processor
|
||||
|
||||
PluginType type ();
|
||||
|
||||
boost::shared_ptr<ReadOnlyControl> control_output (uint32_t) const;
|
||||
|
||||
std::string describe_parameter (Evoral::Parameter param);
|
||||
|
||||
framecnt_t signal_latency () const;
|
||||
@ -375,6 +378,9 @@ class LIBARDOUR_API PluginInsert : public Processor
|
||||
bool _latency_changed;
|
||||
uint32_t _bypass_port;
|
||||
|
||||
typedef std::map<uint32_t, boost::shared_ptr<ReadOnlyControl> >CtrlOutMap;
|
||||
CtrlOutMap _control_outputs;
|
||||
|
||||
void preset_load_set_value (uint32_t, float);
|
||||
};
|
||||
|
||||
|
44
libs/ardour/ardour/readonly_control.h
Normal file
44
libs/ardour/ardour/readonly_control.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
|
||||
* Copyright (C) 2000, 2007 Paul Davis
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __ardour_readonly_control_h__
|
||||
#define __ardour_readonly_control_h__
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
class Plugin;
|
||||
|
||||
class LIBARDOUR_API ReadOnlyControl : public PBD::Destructible
|
||||
{
|
||||
public:
|
||||
ReadOnlyControl (boost::shared_ptr<Plugin> p, uint32_t pnum);
|
||||
|
||||
double get_parameter () const;
|
||||
std::string describe_parameter ();
|
||||
|
||||
private:
|
||||
boost::weak_ptr<Plugin> _plugin;
|
||||
uint32_t _parameter_num;
|
||||
};
|
||||
|
||||
} // namespace ARDOUR
|
||||
|
||||
#endif /* __ardour_readonly_control_h__ */
|
@ -98,6 +98,9 @@ PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug)
|
||||
|
||||
PluginInsert::~PluginInsert ()
|
||||
{
|
||||
for (CtrlOutMap::const_iterator i = _control_outputs.begin(); i != _control_outputs.end(); ++i) {
|
||||
boost::dynamic_pointer_cast<ReadOnlyControl>(i->second)->drop_references ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
@ -452,7 +455,11 @@ PluginInsert::create_automatable_parameters ()
|
||||
set<Evoral::Parameter> a = _plugins.front()->automatable ();
|
||||
|
||||
for (uint32_t i = 0; i < plugin->parameter_count(); ++i) {
|
||||
if (!plugin->parameter_is_control (i) || !plugin->parameter_is_input (i)) {
|
||||
if (!plugin->parameter_is_control (i)) {
|
||||
continue;
|
||||
}
|
||||
if (!plugin->parameter_is_input (i)) {
|
||||
_control_outputs[i] = boost::shared_ptr<ReadOnlyControl> (new ReadOnlyControl (plugin, i));
|
||||
continue;
|
||||
}
|
||||
Evoral::Parameter param (PluginAutomation, 0, i);
|
||||
@ -2803,6 +2810,16 @@ PluginInsert::set_parameter_state_2X (const XMLNode& node, int version)
|
||||
}
|
||||
}
|
||||
|
||||
boost::shared_ptr<ReadOnlyControl>
|
||||
PluginInsert::control_output (uint32_t num) const
|
||||
{
|
||||
CtrlOutMap::const_iterator i = _control_outputs.find (num);
|
||||
if (i == _control_outputs.end ()) {
|
||||
return boost::shared_ptr<ReadOnlyControl> ();
|
||||
} else {
|
||||
return (*i).second;
|
||||
}
|
||||
}
|
||||
|
||||
string
|
||||
PluginInsert::describe_parameter (Evoral::Parameter param)
|
||||
|
50
libs/ardour/readonly_control.cc
Normal file
50
libs/ardour/readonly_control.cc
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
|
||||
* Copyright (C) 2000, 2007 Paul Davis
|
||||
*
|
||||
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "pbd/destructible.h"
|
||||
|
||||
#include "ardour/plugin.h"
|
||||
#include "ardour/readonly_control.h"
|
||||
|
||||
using namespace ARDOUR;
|
||||
|
||||
ReadOnlyControl::ReadOnlyControl (boost::shared_ptr<Plugin> p, uint32_t pnum)
|
||||
: _plugin (boost::weak_ptr<Plugin> (p))
|
||||
, _parameter_num (pnum)
|
||||
{ }
|
||||
|
||||
double
|
||||
ReadOnlyControl::get_parameter () const
|
||||
{
|
||||
boost::shared_ptr<Plugin> p = _plugin.lock();
|
||||
if (p) {
|
||||
return p->get_parameter (_parameter_num);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string
|
||||
ReadOnlyControl::describe_parameter ()
|
||||
{
|
||||
boost::shared_ptr<Plugin> p = _plugin.lock();
|
||||
if (p) {
|
||||
return p->describe_parameter (Evoral::Parameter (ARDOUR::PluginAutomation, 0, _parameter_num));
|
||||
}
|
||||
return "";
|
||||
}
|
@ -178,6 +178,7 @@ libardour_sources = [
|
||||
'progress.cc',
|
||||
'quantize.cc',
|
||||
'rc_configuration.cc',
|
||||
'readonly_control.cc',
|
||||
'recent_sessions.cc',
|
||||
'record_enable_control.cc',
|
||||
'record_safe_control.cc',
|
||||
|
Loading…
Reference in New Issue
Block a user