2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "libardour-config.h"
27 #include "pbd/failed_constructor.h"
28 #include "pbd/xml++.h"
30 #include "ardour/audio_buffer.h"
31 #include "ardour/automation_list.h"
32 #include "ardour/buffer_set.h"
33 #include "ardour/event_type_map.h"
34 #include "ardour/ladspa_plugin.h"
35 #include "ardour/plugin.h"
36 #include "ardour/plugin_insert.h"
37 #include "ardour/port.h"
38 #include "ardour/route.h"
41 #include "ardour/lv2_plugin.h"
45 #include "ardour/vst_plugin.h"
48 #ifdef HAVE_AUDIOUNITS
49 #include "ardour/audio_unit.h"
52 #include "ardour/audioengine.h"
53 #include "ardour/session.h"
54 #include "ardour/types.h"
59 using namespace ARDOUR;
62 const string PluginInsert::port_automation_node_name = "PortAutomation";
64 PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug)
65 : Processor (s, plug->name())
66 , _signal_analysis_collected_nframes(0)
67 , _signal_analysis_collect_nframes_max(0)
69 /* the first is the master */
71 _plugins.push_back (plug);
75 Glib::Mutex::Lock em (_session.engine().process_lock());
76 IO::PortCountChanged (max(input_streams(), output_streams()));
79 ProcessorCreated (this); /* EMIT SIGNAL */
82 PluginInsert::PluginInsert (Session& s, const XMLNode& node)
83 : Processor (s, "unnamed plugin insert"),
84 _signal_analysis_collected_nframes(0),
85 _signal_analysis_collect_nframes_max(0)
87 if (set_state (node, Stateful::loading_state_version)) {
88 throw failed_constructor();
91 _pending_active = _active;
94 Glib::Mutex::Lock em (_session.engine().process_lock());
95 IO::PortCountChanged (max(input_streams(), output_streams()));
100 PluginInsert::set_count (uint32_t num)
102 bool require_state = !_plugins.empty();
104 /* this is a bad idea.... we shouldn't do this while active.
105 only a route holding their redirect_lock should be calling this
110 } else if (num > _plugins.size()) {
111 uint32_t diff = num - _plugins.size();
113 for (uint32_t n = 0; n < diff; ++n) {
114 _plugins.push_back (plugin_factory (_plugins[0]));
117 /* XXX do something */
121 } else if (num < _plugins.size()) {
122 uint32_t diff = _plugins.size() - num;
123 for (uint32_t n= 0; n < diff; ++n) {
131 PluginInsert::~PluginInsert ()
136 PluginInsert::auto_state_changed (Evoral::Parameter which)
138 if (which.type() != PluginAutomation)
141 boost::shared_ptr<AutomationControl> c
142 = boost::dynamic_pointer_cast<AutomationControl>(control (which));
144 if (c && ((AutomationList*)c->list().get())->automation_state() != Off) {
145 _plugins[0]->set_parameter (which.id(), c->list()->eval (_session.transport_frame()));
150 PluginInsert::output_streams() const
152 ChanCount out = _plugins.front()->get_info()->n_outputs;
154 if (out == ChanCount::INFINITE) {
155 return _plugins.front()->output_streams ();
157 out.set_audio (out.n_audio() * _plugins.size());
158 out.set_midi (out.n_midi() * _plugins.size());
164 PluginInsert::input_streams() const
166 ChanCount in = _plugins[0]->get_info()->n_inputs;
168 if (in == ChanCount::INFINITE) {
169 return _plugins[0]->input_streams ();
171 in.set_audio (in.n_audio() * _plugins.size());
172 in.set_midi (in.n_midi() * _plugins.size());
178 PluginInsert::natural_output_streams() const
180 return _plugins[0]->get_info()->n_outputs;
184 PluginInsert::natural_input_streams() const
186 return _plugins[0]->get_info()->n_inputs;
190 PluginInsert::is_generator() const
192 /* XXX more finesse is possible here. VST plugins have a
193 a specific "instrument" flag, for example.
196 return _plugins[0]->get_info()->n_inputs.n_audio() == 0;
200 PluginInsert::set_automatable ()
202 set<Evoral::Parameter> a = _plugins.front()->automatable ();
204 Plugin::ParameterDescriptor desc;
206 for (set<Evoral::Parameter>::iterator i = a.begin(); i != a.end(); ++i) {
207 if (i->type() == PluginAutomation) {
209 Evoral::Parameter param(*i);
211 _plugins.front()->get_parameter_descriptor(i->id(), desc);
213 /* the Parameter belonging to the actual plugin doesn't have its range set
214 but we want the Controllable related to this Parameter to have those limits.
217 param.set_range (desc.lower, desc.upper, _plugins.front()->default_value(i->id()));
218 can_automate (param);
219 boost::shared_ptr<AutomationList> list(new AutomationList(param));
220 add_control (boost::shared_ptr<AutomationControl>(new PluginControl(this, param, list)));
226 PluginInsert::parameter_changed (Evoral::Parameter which, float val)
228 if (which.type() != PluginAutomation)
231 Plugins::iterator i = _plugins.begin();
233 /* don't set the first plugin, just all the slaves */
235 if (i != _plugins.end()) {
237 for (; i != _plugins.end(); ++i) {
238 (*i)->set_parameter (which, val);
244 PluginInsert::set_block_size (nframes_t nframes)
246 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
247 (*i)->set_block_size (nframes);
252 PluginInsert::activate ()
254 Processor::activate ();
256 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
262 PluginInsert::deactivate ()
264 Processor::deactivate ();
266 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
272 PluginInsert::connect_and_run (BufferSet& bufs, nframes_t nframes, nframes_t offset, bool with_auto, nframes_t now)
274 // Calculate if, and how many frames we need to collect for analysis
275 nframes_t collect_signal_nframes = (_signal_analysis_collect_nframes_max -
276 _signal_analysis_collected_nframes);
277 if (nframes < collect_signal_nframes) { // we might not get all frames now
278 collect_signal_nframes = nframes;
281 ChanMapping in_map(input_streams());
282 ChanMapping out_map(output_streams());
284 /* Note that we've already required that plugins
285 be able to handle in-place processing.
292 for (Controls::iterator li = controls().begin(); li != controls().end(); ++li, ++n) {
294 boost::shared_ptr<AutomationControl> c
295 = boost::dynamic_pointer_cast<AutomationControl>(li->second);
297 if (c->parameter().type() == PluginAutomation && c->automation_playback()) {
300 const float val = c->list()->rt_safe_eval (now, valid);
310 if (collect_signal_nframes > 0) {
312 //std::cerr << "collect input, bufs " << bufs.count().n_audio() << " count, " << bufs.available().n_audio() << " available" << std::endl;
313 //std::cerr << " streams " << input_streams().n_audio() << std::endl;
314 //std::cerr << "filling buffer with " << collect_signal_nframes << " frames at " << _signal_analysis_collected_nframes << std::endl;
316 _signal_analysis_inputs.set_count(input_streams());
318 for (uint32_t i = 0; i < input_streams().n_audio(); ++i) {
319 _signal_analysis_inputs.get_audio(i).read_from(
321 collect_signal_nframes,
322 _signal_analysis_collected_nframes); // offset is for target buffer
327 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
328 (*i)->connect_and_run(bufs, in_map, out_map, nframes, offset);
329 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
330 in_map.offset_to(*t, natural_input_streams().get(*t));
331 out_map.offset_to(*t, natural_output_streams().get(*t));
335 if (collect_signal_nframes > 0) {
337 //std::cerr << " output, bufs " << bufs.count().n_audio() << " count, " << bufs.available().n_audio() << " available" << std::endl;
338 //std::cerr << " streams " << output_streams().n_audio() << std::endl;
340 _signal_analysis_outputs.set_count(output_streams());
342 for (uint32_t i = 0; i < output_streams().n_audio(); ++i) {
343 _signal_analysis_outputs.get_audio(i).read_from(
345 collect_signal_nframes,
346 _signal_analysis_collected_nframes); // offset is for target buffer
349 _signal_analysis_collected_nframes += collect_signal_nframes;
350 assert(_signal_analysis_collected_nframes <= _signal_analysis_collect_nframes_max);
352 if (_signal_analysis_collected_nframes == _signal_analysis_collect_nframes_max) {
353 _signal_analysis_collect_nframes_max = 0;
354 _signal_analysis_collected_nframes = 0;
356 AnalysisDataGathered(&_signal_analysis_inputs,
357 &_signal_analysis_outputs);
360 /* leave remaining channel buffers alone */
364 PluginInsert::silence (nframes_t nframes)
366 ChanMapping in_map(input_streams());
367 ChanMapping out_map(output_streams());
370 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
371 (*i)->connect_and_run (_session.get_silent_buffers ((*i)->get_info()->n_inputs), in_map, out_map, nframes, 0);
377 PluginInsert::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
379 if (_active || _pending_active) {
381 if (_session.transport_rolling()) {
382 automation_run (bufs, nframes);
384 connect_and_run (bufs, nframes, 0, false);
389 /* FIXME: type, audio only */
391 uint32_t in = _plugins[0]->get_info()->n_inputs.n_audio();
392 uint32_t out = _plugins[0]->get_info()->n_outputs.n_audio();
396 /* not active, but something has make up for any channel count increase */
398 for (uint32_t n = out - in; n < out; ++n) {
399 memcpy (bufs.get_audio(n).data(), bufs.get_audio(in - 1).data(), sizeof (Sample) * nframes);
403 bufs.count().set_audio(out);
406 _active = _pending_active;
410 PluginInsert::set_parameter (Evoral::Parameter param, float val)
412 if (param.type() != PluginAutomation)
415 /* the others will be set from the event triggered by this */
417 _plugins[0]->set_parameter (param.id(), val);
419 boost::shared_ptr<AutomationControl> ac
420 = boost::dynamic_pointer_cast<AutomationControl>(control(param));
425 warning << "set_parameter called for nonexistant parameter "
426 << EventTypeMap::instance().to_symbol(param) << endmsg;
429 _session.set_dirty();
433 PluginInsert::get_parameter (Evoral::Parameter param)
435 if (param.type() != PluginAutomation) {
438 assert (!_plugins.empty ());
439 return _plugins[0]->get_parameter (param.id());
444 PluginInsert::automation_run (BufferSet& bufs, nframes_t nframes)
446 Evoral::ControlEvent next_event (0, 0.0f);
447 nframes_t now = _session.transport_frame ();
448 nframes_t end = now + nframes;
449 nframes_t offset = 0;
451 Glib::Mutex::Lock lm (control_lock(), Glib::TRY_LOCK);
454 connect_and_run (bufs, nframes, offset, false);
458 if (!find_next_event (now, end, next_event)) {
460 /* no events have a time within the relevant range */
462 connect_and_run (bufs, nframes, offset, true, now);
468 nframes_t cnt = min (((nframes_t) ceil (next_event.when) - now), nframes);
470 connect_and_run (bufs, cnt, offset, true, now);
476 if (!find_next_event (now, end, next_event)) {
481 /* cleanup anything that is left to do */
484 connect_and_run (bufs, nframes, offset, true, now);
489 PluginInsert::default_parameter_value (const Evoral::Parameter& param)
491 if (param.type() != PluginAutomation)
494 if (_plugins.empty()) {
495 fatal << _("programming error: ") << X_("PluginInsert::default_parameter_value() called with no plugin")
500 return _plugins[0]->default_value (param.id());
503 boost::shared_ptr<Plugin>
504 PluginInsert::plugin_factory (boost::shared_ptr<Plugin> other)
506 boost::shared_ptr<LadspaPlugin> lp;
508 boost::shared_ptr<LV2Plugin> lv2p;
511 boost::shared_ptr<VSTPlugin> vp;
513 #ifdef HAVE_AUDIOUNITS
514 boost::shared_ptr<AUPlugin> ap;
517 if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
518 return boost::shared_ptr<Plugin> (new LadspaPlugin (*lp));
520 } else if ((lv2p = boost::dynamic_pointer_cast<LV2Plugin> (other)) != 0) {
521 return boost::shared_ptr<Plugin> (new LV2Plugin (*lv2p));
524 } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
525 return boost::shared_ptr<Plugin> (new VSTPlugin (*vp));
527 #ifdef HAVE_AUDIOUNITS
528 } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
529 return boost::shared_ptr<Plugin> (new AUPlugin (*ap));
533 fatal << string_compose (_("programming error: %1"),
534 X_("unknown plugin type in PluginInsert::plugin_factory"))
537 return boost::shared_ptr<Plugin> ((Plugin*) 0);
541 PluginInsert::configure_io (ChanCount in, ChanCount out)
543 if (set_count (count_for_configuration (in, out)) < 0) {
547 /* if we're running replicated plugins, each plugin has
548 the same i/o configuration and we may need to announce how many
549 output streams there are.
551 if we running a single plugin, we need to configure it.
554 if (_plugins.front()->configure_io (in, out) < 0) {
558 // we don't know the analysis window size, so we must work with the
559 // current buffer size here. each request for data fills in these
560 // buffers and the analyser makes sure it gets enough data for the
562 session().ensure_buffer_set (_signal_analysis_inputs, in);
563 //_signal_analysis_inputs.set_count (in);
565 session().ensure_buffer_set (_signal_analysis_outputs, out);
566 //_signal_analysis_outputs.set_count (out);
568 // std::cerr << "set counts to i" << in.n_audio() << "/o" << out.n_audio() << std::endl;
570 return Processor::configure_io (in, out);
574 PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
576 // Plugin has flexible I/O, so delegate to it
577 if (_plugins.front()->reconfigurable_io()) {
578 return _plugins.front()->can_support_io_configuration (in, out);
581 ChanCount inputs = _plugins[0]->get_info()->n_inputs;
582 ChanCount outputs = _plugins[0]->get_info()->n_outputs;
584 // Plugin inputs match requested inputs exactly
590 // See if replication is possible
591 // We can replicate if there exists a single factor f such that, for every type,
592 // the number of plugin inputs * f = the requested number of inputs
594 bool can_replicate = true;
595 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
596 // No inputs of this type
597 if (inputs.get(*t) == 0 && in.get(*t) == 0) {
600 // Plugin has more inputs than requested, can not replicate
601 } else if (inputs.get(*t) >= in.get(*t)) {
602 can_replicate = false;
605 // Plugin inputs is not a factor of requested inputs, can not replicate
606 } else if (inputs.get(*t) == 0 || in.get(*t) % inputs.get(*t) != 0) {
607 can_replicate = false;
610 // Potential factor not set yet
612 f = in.get(*t) / inputs.get(*t);;
615 // Factor for this type does not match another type, can not replicate
616 if (f != (in.get(*t) / inputs.get(*t))) {
617 can_replicate = false;
623 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
624 out.set (*t, outputs.get(*t) * f);
632 /* Number of plugin instances required to support a given channel configuration.
636 PluginInsert::count_for_configuration (ChanCount in, ChanCount /*out*/) const
638 if (_plugins.front()->reconfigurable_io()) {
639 /* plugin has flexible I/O, so the answer is always 1 */
640 /* this could change if we ever decide to replicate AU's */
644 // FIXME: take 'out' into consideration
646 ChanCount outputs = _plugins[0]->get_info()->n_outputs;
647 ChanCount inputs = _plugins[0]->get_info()->n_inputs;
649 if (inputs.n_total() == 0) {
650 /* instrument plugin, always legal, but throws away any existing streams */
654 if (inputs.n_total() == 1 && outputs == inputs
655 && ((inputs.n_audio() == 0 && in.n_audio() == 0)
656 || (inputs.n_midi() == 0 && in.n_midi() == 0))) {
657 /* mono plugin, replicate as needed to match in */
666 // assumes in is valid, so we must be replicating
667 if (inputs.n_total() < in.n_total()
668 && (in.n_total() % inputs.n_total() == 0)) {
670 return in.n_total() / inputs.n_total();
678 PluginInsert::get_state(void)
684 PluginInsert::state (bool full)
686 XMLNode& node = Processor::state (full);
688 node.add_property("type", _plugins[0]->state_node_name());
689 node.add_property("unique-id", _plugins[0]->unique_id());
690 node.add_property("count", string_compose("%1", _plugins.size()));
691 node.add_child_nocopy (_plugins[0]->get_state());
693 /* add port automation state */
694 XMLNode *autonode = new XMLNode(port_automation_node_name);
695 set<Evoral::Parameter> automatable = _plugins[0]->automatable();
697 for (set<Evoral::Parameter>::iterator x = automatable.begin(); x != automatable.end(); ++x) {
699 /*XMLNode* child = new XMLNode("port");
700 snprintf(buf, sizeof(buf), "%" PRIu32, *x);
701 child->add_property("number", string(buf));
703 child->add_child_nocopy (automation_list (*x).state (full));
704 autonode->add_child_nocopy (*child);
706 AutomationList* list = dynamic_cast<AutomationList*>(control(*x)->list().get());
707 autonode->add_child_nocopy (list->state (full));
710 node.add_child_nocopy (*autonode);
716 PluginInsert::set_state(const XMLNode& node, int version)
718 XMLNodeList nlist = node.children();
719 XMLNodeIterator niter;
720 XMLPropertyList plist;
721 const XMLProperty *prop;
722 ARDOUR::PluginType type;
724 if ((prop = node.property ("type")) == 0) {
725 error << _("XML node describing plugin is missing the `type' field") << endmsg;
729 if (prop->value() == X_("ladspa") || prop->value() == X_("Ladspa")) { /* handle old school sessions */
730 type = ARDOUR::LADSPA;
731 } else if (prop->value() == X_("lv2")) {
733 } else if (prop->value() == X_("vst")) {
735 } else if (prop->value() == X_("audiounit")) {
736 type = ARDOUR::AudioUnit;
738 error << string_compose (_("unknown plugin type %1 in plugin insert state"),
744 prop = node.property ("unique-id");
748 /* older sessions contain VST plugins with only an "id" field.
751 if (type == ARDOUR::VST) {
752 prop = node.property ("id");
758 error << _("Plugin has no unique ID field") << endmsg;
763 boost::shared_ptr<Plugin> plugin;
765 plugin = find_plugin (_session, prop->value(), type);
768 error << string_compose(_("Found a reference to a plugin (\"%1\") that is unknown.\n"
769 "Perhaps it was removed or moved since it was last used."), prop->value())
775 bool need_automatables = true;
777 if (_plugins.empty()) {
778 /* if we are adding the first plugin, we will need to set
779 up automatable controls.
781 need_automatables = true;
784 if ((prop = node.property ("count")) != 0) {
785 sscanf (prop->value().c_str(), "%u", &count);
788 if (_plugins.size() != count) {
790 _plugins.push_back (plugin);
792 for (uint32_t n = 1; n < count; ++n) {
793 _plugins.push_back (plugin_factory (plugin));
797 if (need_automatables) {
801 /* Handle the node list for this Processor (or Insert if an A2 session) */
802 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
804 if ((*niter)->name() == plugin->state_node_name()) {
806 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
807 (*i)->set_state (**niter, version);
813 if (version < 3000) {
815 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
816 if ((*niter)->name() == "Redirect") {
817 /* XXX do we need to tackle placement? i think not (pd; oct 16 2009) */
818 Processor::set_state (**niter, version);
823 set_parameter_state_2X (node, version);
826 Processor::set_state (node, version);
827 set_parameter_state (node, version);
830 // The name of the PluginInsert comes from the plugin, nothing else
831 _name = plugin->get_info()->name;
837 PluginInsert::set_parameter_state (const XMLNode& node, int version)
839 XMLNodeList nlist = node.children();
840 XMLNodeIterator niter;
842 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
844 if ((*niter)->name() != port_automation_node_name) {
850 XMLNodeConstIterator iter;
855 cnodes = (*niter)->children ("AutomationList");
857 for (iter = cnodes.begin(); iter != cnodes.end(); ++iter) {
861 /* XXX this code knows way too much about the internal details of an AutomationList state node */
863 if ((cprop = child->property("automation-id")) != 0) {
864 port = cprop->value().c_str();
866 warning << _("PluginInsert: Auto: no plugin parameter number seen") << endmsg;
870 if (sscanf (port, "parameter-%" PRIu32, &port_id) != 1) {
871 warning << _("PluginInsert: Auto: no parameter number found") << endmsg;
875 if (port_id >= _plugins[0]->parameter_count()) {
876 warning << _("PluginInsert: Auto: plugin parameter out of range") << endmsg;
880 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(
881 control(Evoral::Parameter(PluginAutomation, 0, port_id), true));
884 c->alist()->set_state (*child, version);
886 error << string_compose (_("PluginInsert: automatable control %1 not found - ignored"), port_id) << endmsg;
897 PluginInsert::set_parameter_state_2X (const XMLNode& node, int version)
899 XMLNodeList nlist = node.children();
900 XMLNodeIterator niter;
902 /* look for port automation node */
904 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
906 if ((*niter)->name() != port_automation_node_name) {
912 XMLNodeConstIterator iter;
917 cnodes = (*niter)->children ("port");
919 for (iter = cnodes.begin(); iter != cnodes.end(); ++iter){
923 if ((cprop = child->property("number")) != 0) {
924 port = cprop->value().c_str();
926 warning << _("PluginInsert: Auto: no ladspa port number") << endmsg;
930 sscanf (port, "%" PRIu32, &port_id);
932 if (port_id >= _plugins[0]->parameter_count()) {
933 warning << _("PluginInsert: Auto: port id out of range") << endmsg;
937 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(
938 control(Evoral::Parameter(PluginAutomation, 0, port_id), true));
941 if (!child->children().empty()) {
942 c->alist()->set_state (*child->children().front(), version);
945 error << string_compose (_("PluginInsert: automatable control %1 not found - ignored"), port_id) << endmsg;
957 PluginInsert::describe_parameter (Evoral::Parameter param)
959 if (param.type() != PluginAutomation)
960 return Automatable::describe_parameter(param);
962 return _plugins[0]->describe_parameter (param);
966 PluginInsert::signal_latency() const
969 return _user_latency;
972 return _plugins[0]->signal_latency ();
976 PluginInsert::type ()
978 boost::shared_ptr<LadspaPlugin> lp;
980 boost::shared_ptr<VSTPlugin> vp;
982 #ifdef HAVE_AUDIOUNITS
983 boost::shared_ptr<AUPlugin> ap;
986 PluginPtr other = plugin ();
988 if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
989 return ARDOUR::LADSPA;
991 } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
994 #ifdef HAVE_AUDIOUNITS
995 } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
996 return ARDOUR::AudioUnit;
1000 return (ARDOUR::PluginType) 0;
1004 PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> list)
1005 : AutomationControl (p->session(), param, list, p->describe_parameter(param))
1008 Plugin::ParameterDescriptor desc;
1009 p->plugin(0)->get_parameter_descriptor (param.id(), desc);
1010 _logarithmic = desc.logarithmic;
1011 _toggled = desc.toggled;
1015 PluginInsert::PluginControl::set_value (float val)
1017 /* FIXME: probably should be taking out some lock here.. */
1027 /*const float range = _list->get_max_y() - _list->get_min_y();
1028 const float lower = _list->get_min_y();
1030 if (!_logarithmic) {
1031 val = lower + (range * val);
1033 float log_lower = 0.0f;
1035 log_lower = log(lower);
1038 val = exp(log_lower + log(range) * val);
1043 for (Plugins::iterator i = _plugin->_plugins.begin();
1044 i != _plugin->_plugins.end(); ++i) {
1045 (*i)->set_parameter (_list->parameter().id(), val);
1048 boost::shared_ptr<Plugin> iasp = _plugin->_impulseAnalysisPlugin.lock();
1050 iasp->set_parameter (_list->parameter().id(), val);
1053 AutomationControl::set_value(val);
1057 PluginInsert::PluginControl::get_value (void) const
1059 /* FIXME: probably should be taking out some lock here.. */
1061 float val = _plugin->get_parameter (_list->parameter());
1075 return ((val - lower) / range);
1079 boost::shared_ptr<Plugin>
1080 PluginInsert::get_impulse_analysis_plugin()
1082 boost::shared_ptr<Plugin> ret;
1083 if (_impulseAnalysisPlugin.expired()) {
1084 ret = plugin_factory(_plugins[0]);
1085 _impulseAnalysisPlugin = ret;
1087 ret = _impulseAnalysisPlugin.lock();
1094 PluginInsert::collect_signal_for_analysis(nframes_t nframes)
1096 // called from outside the audio thread, so this should be safe
1097 // only do audio as analysis is (currently) only for audio plugins
1098 _signal_analysis_inputs.ensure_buffers( DataType::AUDIO, input_streams().n_audio(), nframes);
1099 _signal_analysis_outputs.ensure_buffers( DataType::AUDIO, output_streams().n_audio(), nframes);
1101 _signal_analysis_collected_nframes = 0;
1102 _signal_analysis_collect_nframes_max = nframes;