21 #include "libardour-config.h"
33 #include "ardour/debug.h"
43 #ifdef WINDOWS_VST_SUPPORT
51 #ifdef AUDIOUNIT_SUPPORT
64 const string PluginInsert::port_automation_node_name =
"PortAutomation";
67 :
Processor (s, (plug ? plug->
name() : string (
"toBeRenamed")))
68 , _signal_analysis_collected_nframes(0)
69 , _signal_analysis_collect_nframes_max(0)
82 bool require_state = !
_plugins.empty();
91 uint32_t diff = num -
_plugins.size();
93 for (uint32_t n = 0; n < diff; ++n) {
106 uint32_t diff =
_plugins.size() - num;
107 for (uint32_t n= 0; n < diff; ++n) {
140 if (info->reconfigurable_io()) {
164 in =
_plugins.front()->input_streams();
177 if (in.get (*t) > 1) {
193 in.set (*t, in.get (*t) *
_plugins.size ());
203 return _plugins[0]->get_info()->n_outputs;
209 return _plugins[0]->get_info()->n_inputs;
221 return _plugins[0]->get_info()->n_inputs.n_audio() == 0;
241 set<Evoral::Parameter> a =
_plugins.front()->automatable ();
243 for (set<Evoral::Parameter>::iterator i = a.begin(); i != a.end(); ++i) {
249 _plugins.front()->get_parameter_descriptor(i->id(), desc);
276 Plugins::iterator i =
_plugins.begin();
283 (*i)->set_parameter (which, val);
294 if ((*i)->set_block_size (nframes) != 0) {
335 if (nframes < collect_signal_nframes) {
336 collect_signal_nframes = nframes;
370 for (Controls::iterator li =
controls().begin(); li !=
controls().end(); ++li, ++n) {
378 const float val = c->
list()->rt_safe_eval (now, valid);
388 if (collect_signal_nframes > 0) {
399 collect_signal_nframes,
406 (*i)->connect_and_run(bufs, in_map, out_map, nframes, offset);
413 if (collect_signal_nframes > 0) {
423 collect_signal_nframes,
483 for (uint32_t n = 0; n < out; ++n) {
487 }
else if (out > in) {
493 for (uint32_t n = in; n < out; ++n) {
526 warning <<
"set_parameter called for nonexistant parameter "
540 return _plugins[0]->get_parameter (param.
id());
596 fatal <<
_(
"programming error: ") <<
X_(
"PluginInsert::default_parameter_value() called with no plugin")
601 return _plugins[0]->default_value (param.
id());
610 for (uint32_t par = 0; par <
_plugins[0]->parameter_count(); ++par) {
612 const uint32_t cid =
_plugins[0]->nth_parameter (par, ok);
614 if (!ok || !
_plugins[0]->parameter_is_input(cid)) {
629 return all && (params > 0);
637 for (uint32_t par = 0; par <
_plugins[0]->parameter_count(); ++par) {
639 const uint32_t cid =
_plugins[0]->nth_parameter (par, ok);
641 if (!ok || !
_plugins[0]->parameter_is_input(cid)) {
645 const float dflt =
_plugins[0]->default_value (cid);
646 const float curr =
_plugins[0]->get_parameter (cid);
674 #ifdef WINDOWS_VST_SUPPORT
680 #ifdef AUDIOUNIT_SUPPORT
684 if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
687 }
else if ((lv2p = boost::dynamic_pointer_cast<LV2Plugin> (other)) != 0) {
690 #ifdef WINDOWS_VST_SUPPORT
691 }
else if ((vp = boost::dynamic_pointer_cast<WindowsVSTPlugin> (other)) != 0) {
695 }
else if ((lxvp = boost::dynamic_pointer_cast<LXVSTPlugin> (other)) != 0) {
698 #ifdef AUDIOUNIT_SUPPORT
699 }
else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
705 X_(
"unknown plugin type in PluginInsert::plugin_factory"))
736 if (
_plugins.front()->configure_io (
_plugins.front()->get_info()->n_inputs, out)) {
742 if (
_plugins.front()->configure_io (in, out) ==
false) {
794 bool const r =
_plugins.front()->can_support_io_configuration (in, out);
814 bool no_inputs =
true;
816 if (inputs.
get (*t) != 0) {
841 bool can_replicate =
true;
844 uint32_t nin = inputs.
get (*t);
847 if (nin == 0 && in.
get(*t) == 0) {
851 if (nin != 1 || outputs.
get (*t) != 1) {
852 can_replicate =
false;
858 f = in.
get(*t) / nin;
862 if (f != (in.
get(*t) / nin)) {
863 can_replicate =
false;
870 out.
set (*t, outputs.
get(*t) *
f);
884 bool can_split =
true;
887 bool const can_split_type = (in.
get (*t) == 1 && inputs.
get (*t) > 1);
888 bool const nothing_to_do_for_type = (in.
get (*t) == 0 && inputs.
get (*t) == 0);
890 if (!can_split_type && !nothing_to_do_for_type) {
904 bool could_hide =
false;
905 bool cannot_hide =
false;
909 if (inputs.
get(*t) > in.
get(*t)) {
911 hide_channels.
set (*t, inputs.
get(*t) - in.
get(*t));
913 }
else if (inputs.
get(*t) < in.
get(*t)) {
919 if (could_hide && !cannot_hide) {
944 for (Controls::iterator c =
controls().begin(); c !=
controls().end(); ++c) {
959 set<Evoral::Parameter>::const_iterator p;
961 for (iter = nlist.begin(); iter != nlist.end(); ++iter) {
965 if ((prop = (*iter)->property (
X_(
"parameter"))) != 0) {
972 #ifndef NO_PLUGIN_STATE
995 if ((prop = node.
property (
"type")) == 0) {
996 error <<
_(
"XML node describing plugin is missing the `type' field") <<
endmsg;
1000 if (prop->
value() ==
X_(
"ladspa") || prop->
value() ==
X_(
"Ladspa")) {
1002 }
else if (prop->
value() ==
X_(
"lv2")) {
1004 }
else if (prop->
value() ==
X_(
"windows-vst")) {
1006 }
else if (prop->
value() ==
X_(
"lxvst")) {
1008 }
else if (prop->
value() ==
X_(
"audiounit")) {
1017 prop = node.
property (
"unique-id");
1020 #ifdef WINDOWS_VST_SUPPORT
1029 #ifdef LXVST_SUPPORT
1048 #ifdef LXVST_SUPPORT
1055 #ifdef WINDOWS_VST_SUPPORT
1064 _(
"Found a reference to a plugin (\"%1\") that is unknown.\n"
1065 "Perhaps it was removed or moved since it was last used."),
1092 if ((prop = node.
property (
"count")) != 0) {
1093 sscanf (prop->
value().c_str(),
"%u", &count);
1097 for (uint32_t n = 1; n < count; ++n) {
1104 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1113 (*i)->set_state (**niter, version);
1120 if (version < 3000) {
1126 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1127 if ((*niter)->name() ==
"Redirect") {
1141 (*i)->deactivate ();
1156 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
1169 cnodes = (*niter)->
children (
"port");
1171 for (iter = cnodes.begin(); iter != cnodes.end(); ++iter){
1175 if ((cprop = child->
property(
"number")) != 0) {
1176 port = cprop->
value().c_str();
1178 warning <<
_(
"PluginInsert: Auto: no ladspa port number") <<
endmsg;
1182 sscanf (port,
"%" PRIu32, &port_id);
1184 if (port_id >=
_plugins[0]->parameter_count()) {
1185 warning <<
_(
"PluginInsert: Auto: port id out of range") <<
endmsg;
1208 _plugins.front()->get_parameter_descriptor (port_id, desc);
1210 if (min_y == FLT_MIN) {
1214 if (max_y == FLT_MAX) {
1236 return _plugins[0]->describe_parameter (param);
1253 return _plugins[0]->signal_latency ();
1259 return plugin()->get_info()->type;
1266 :
AutomationControl (p->session(), param, desc, list, p->describe_parameter(param))
1287 for (Plugins::iterator i = _plugin->_plugins.begin(); i != _plugin->_plugins.end(); ++i) {
1288 (*i)->set_parameter (
_list->parameter().id(), user_val);
1304 if (_desc.logarithmic) {
1306 val = pow (val, 1/1.5);
1318 if (_desc.logarithmic) {
1322 val = pow (val, 1.5);
1337 ss << parameter().id();
1348 return _plugin->get_parameter (
_list->parameter());
1374 const Variant value(_desc.datatype, user_val);
1376 error <<
"set_value(double) called for non-numeric property" <<
endmsg;
1380 for (Plugins::iterator i = _plugin->_plugins.begin(); i != _plugin->_plugins.end(); ++i) {
1381 (*i)->set_property(
_list->parameter().id(), value);
1394 ss << parameter().id();
1404 return _value.to_double();
1455 (*i)->realtime_handle_transport_stopped ();
1463 (*i)->realtime_locate ();
1471 (*i)->monitoring_changed ();
bool transport_rolling() const
AutoState automation_state() const
XMLNodeList::iterator XMLNodeIterator
ARDOUR::Session & _session
LIBPBD_API Transmitter fatal
framecnt_t _signal_analysis_collected_nframes
void ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capacity)
int atoi(const string &s)
ChanCount hide
number of channels to hide
void end_touch(uint32_t param_id)
float lower
Minimum value (in Hz, for frequencies)
ChanCount natural_output_streams() const
float normal
Default value.
we copy one of our insert's inputs to multiple plugin inputs
const std::string & value() const
void set_yrange(double min, double max)
PBD::Signal0< void > PluginIoReConfigure
void silence(framecnt_t nframes)
BufferSet _signal_analysis_inputs
MatchingMethod method
method to employ
Session & session() const
virtual void set_parameter(uint32_t which, float val)
void set_count(const ChanCount &count)
void create_automatable_parameters()
we `hide' some of the plugin's inputs by feeding them silence
double interface_to_internal(double) const
void collect_signal_for_analysis(framecnt_t nframes)
shared_ptr< T > dynamic_pointer_cast(shared_ptr< U > const &r)
int set_state(const XMLNode &, int version)
PBD::Signal1< void, uint32_t > EndTouch
int set_state(const XMLNode &, int version)
PluginPropertyControl(PluginInsert *p, const Evoral::Parameter ¶m, const ParameterDescriptor &desc, boost::shared_ptr< AutomationList > list=boost::shared_ptr< AutomationList >())
std::list< XMLProperty * > XMLPropertyList
void set_value(double val)
framecnt_t signal_latency() const
boost::shared_ptr< Control > control(const Parameter &id, bool create_if_missing=false)
void set_parameter(Evoral::Parameter param, float val)
void ensure_buffer_set(BufferSet &buffers, const ChanCount &howmany)
bool find_next_event(double start, double end, ControlEvent &ev) const
void set_interpolation(InterpolationStyle)
void monitoring_changed()
LIBPBD_API Transmitter error
LIBPBD_API Transmitter warning
our insert's inputs are the same as the plugin's
const XMLNodeList & children(const std::string &str=std::string()) const
std::ostream & endmsg(std::ostream &ostr)
boost::shared_ptr< Plugin > plugin(uint32_t num=0) const
bool can_reset_all_parameters()
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > start
virtual bool reconfigurable_io() const
bool automation_playback() const
PBD::Signal2< void, uint32_t, float > ParameterChanged
int set_state(const XMLNode &, int version)
AudioBuffer & get_audio(size_t i)
we are delegating to the plugin, and it can handle it
void realtime_handle_transport_stopped()
virtual void add_control(boost::shared_ptr< Evoral::Control >)
std::list< XMLNode * > XMLNodeList
void automation_run(BufferSet &bufs, framepos_t start, pframes_t nframes)
void start_touch(double when)
Match private_can_support_io_configuration(ChanCount const &, ChanCount &)
virtual void deactivate()
ChanCount natural_input_streams() const
bool reset_parameters_to_default()
bool can_support_io_configuration(const ChanCount &in, ChanCount &out)
void parameter_changed(uint32_t, float)
float get_parameter(Evoral::Parameter param)
framecnt_t _signal_analysis_collect_nframes_max
static const std::string port_automation_node_name
static const std::string state_node_name
ChanCount output_streams() const
XMLProperty * property(const char *)
Glib::Threads::Mutex & control_lock() const
float upper
Maximum value (in Hz, for frequencies)
void silence(framecnt_t len, framecnt_t offset=0)
const ParameterDescriptor & desc() const
virtual double internal_to_interface(double i) const
virtual std::string describe_parameter(Evoral::Parameter param)
void set_value(const Variant &val)
bool configure_io(ChanCount in, ChanCount out)
PluginControl(PluginInsert *p, const Evoral::Parameter ¶m, const ParameterDescriptor &desc, boost::shared_ptr< AutomationList > list=boost::shared_ptr< AutomationList >())
void can_automate(Evoral::Parameter)
double get_value(void) const
framepos_t transport_frame() const
ChanCount input_streams() const
bool set_id(const XMLNode &)
void set_parameter_state_2X(const XMLNode &node, int version)
void offset_to(DataType t, int32_t delta)
int set_state(const XMLNode &, int version)
void run(BufferSet &in, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
virtual bool configure_io(ChanCount in, ChanCount out)
#define DEBUG_TRACE(bits, str)
static ChanCount max(const ChanCount &a, const ChanCount &b)
static EventTypeMap & instance()
void connect_and_run(BufferSet &bufs, pframes_t nframes, framecnt_t offset, bool with_auto, framepos_t now=0)
int set_block_size(pframes_t nframes)
PBD::Property< std::string > _name
LIBPBD_API Transmitter info
PluginInfoPtr get_info() const
bool is_midi_instrument() const
void set_audio(uint32_t a)
LIBARDOUR_API uint64_t Processors
static const std::string xml_node_name
virtual void activate()=0
XMLProperty * add_property(const char *name, const std::string &value)
PBD::Signal2< void, BufferSet *, BufferSet * > AnalysisDataGathered
we have multiple instances of the plugin
std::string to_symbol(const Evoral::Parameter ¶m) const
void reset_default(double val)
void add_child_nocopy(XMLNode &)
uint32_t get(DataType t) const
boost::shared_ptr< Plugin > plugin_factory(boost::shared_ptr< Plugin >)
void set_midi(uint32_t m)
bool toggled
True iff parameter is boolean.
virtual void set_insert_id(PBD::ID id)
void control_list_automation_state_changed(Evoral::Parameter, AutoState)
boost::shared_ptr< ControlList > list()
const ChanCount & count() const
void remove_property(const std::string &)
PluginPtr find_plugin(ARDOUR::Session &, std::string unique_id, ARDOUR::PluginType)
void set(DataType t, uint32_t count)
virtual double interface_to_internal(double i) const
PBD::Signal1< void, uint32_t > StartTouch
bool has_no_audio_inputs() const
bool bounce_processing() const
XMLNode & get_state(void)
virtual XMLNode & state(bool full)
boost::shared_ptr< AutomationControl > automation_control(const Evoral::Parameter &id, bool create_if_missing=false)
double internal_to_interface(double) const
bool set_count(uint32_t num)
boost::weak_ptr< Plugin > _impulseAnalysisPlugin
boost::shared_ptr< AutomationList > alist() const
double get_value(void) const
virtual bool requires_fixed_sized_buffers() const
void start_touch(uint32_t param_id)
void add_plugin(boost::shared_ptr< Plugin >)
virtual std::string state_node_name() const =0
bool has_no_inputs() const
float default_parameter_value(const Evoral::Parameter ¶m)
void read_from(const Sample *src, framecnt_t len, framecnt_t dst_offset=0, framecnt_t src_offset=0)
BufferSet _signal_analysis_outputs
Variant::Type datatype
for properties
static const ChanCount ZERO
XMLNodeList::const_iterator XMLNodeConstIterator
void set_control_ids(const XMLNode &, int version)
plugin has no inputs, so anything goes
BufferSet & get_scratch_buffers(ChanCount count=ChanCount::ZERO, bool silence=true)
static bool type_is_numeric(Type type)
uint32_t get(DataType t, uint32_t from, bool *valid)
std::string string_compose(const std::string &fmt, const T1 &o1)
void stop_touch(bool mark, double when)
int32_t plugins
number of copies of the plugin that we need
std::string describe_parameter(Evoral::Parameter param)
boost::shared_ptr< Plugin > get_impulse_analysis_plugin()