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 ? plug->name() : string ("toBeRenamed")))
66 , _signal_analysis_collected_nframes(0)
67 , _signal_analysis_collect_nframes_max(0)
69 /* the first is the master */
72 _plugins.push_back (plug);
75 Glib::Mutex::Lock em (_session.engine().process_lock());
76 IO::PortCountChanged (max(input_streams(), output_streams()));
81 PluginInsert::set_count (uint32_t num)
83 bool require_state = !_plugins.empty();
85 /* this is a bad idea.... we shouldn't do this while active.
86 only a route holding their redirect_lock should be calling this
91 } else if (num > _plugins.size()) {
92 uint32_t diff = num - _plugins.size();
94 for (uint32_t n = 0; n < diff; ++n) {
95 _plugins.push_back (plugin_factory (_plugins[0]));
98 /* XXX do something */
102 } else if (num < _plugins.size()) {
103 uint32_t diff = _plugins.size() - num;
104 for (uint32_t n= 0; n < diff; ++n) {
112 PluginInsert::~PluginInsert ()
117 PluginInsert::control_list_automation_state_changed (Evoral::Parameter which, AutoState s)
119 if (which.type() != PluginAutomation)
122 boost::shared_ptr<AutomationControl> c
123 = boost::dynamic_pointer_cast<AutomationControl>(control (which));
126 _plugins[0]->set_parameter (which.id(), c->list()->eval (_session.transport_frame()));
131 PluginInsert::output_streams() const
133 ChanCount out = _plugins.front()->get_info()->n_outputs;
135 if (out == ChanCount::INFINITE) {
136 return _plugins.front()->output_streams ();
138 out.set_audio (out.n_audio() * _plugins.size());
139 out.set_midi (out.n_midi() * _plugins.size());
145 PluginInsert::input_streams() const
147 ChanCount in = _plugins[0]->get_info()->n_inputs;
149 if (in == ChanCount::INFINITE) {
150 return _plugins[0]->input_streams ();
152 in.set_audio (in.n_audio() * _plugins.size());
153 in.set_midi (in.n_midi() * _plugins.size());
159 PluginInsert::natural_output_streams() const
161 return _plugins[0]->get_info()->n_outputs;
165 PluginInsert::natural_input_streams() const
167 return _plugins[0]->get_info()->n_inputs;
171 PluginInsert::is_generator() const
173 /* XXX more finesse is possible here. VST plugins have a
174 a specific "instrument" flag, for example.
177 return _plugins[0]->get_info()->n_inputs.n_audio() == 0;
181 PluginInsert::set_automatable ()
183 set<Evoral::Parameter> a = _plugins.front()->automatable ();
185 Plugin::ParameterDescriptor desc;
187 for (set<Evoral::Parameter>::iterator i = a.begin(); i != a.end(); ++i) {
188 if (i->type() == PluginAutomation) {
190 Evoral::Parameter param(*i);
192 _plugins.front()->get_parameter_descriptor(i->id(), desc);
194 /* the Parameter belonging to the actual plugin doesn't have its range set
195 but we want the Controllable related to this Parameter to have those limits.
198 param.set_range (desc.lower, desc.upper, _plugins.front()->default_value(i->id()));
199 can_automate (param);
200 boost::shared_ptr<AutomationList> list(new AutomationList(param));
201 add_control (boost::shared_ptr<AutomationControl>(new PluginControl(this, param, list)));
207 PluginInsert::parameter_changed (Evoral::Parameter which, float val)
209 if (which.type() != PluginAutomation)
212 Plugins::iterator i = _plugins.begin();
214 /* don't set the first plugin, just all the slaves */
216 if (i != _plugins.end()) {
218 for (; i != _plugins.end(); ++i) {
219 (*i)->set_parameter (which, val);
225 PluginInsert::set_block_size (nframes_t nframes)
228 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
229 if ((*i)->set_block_size (nframes) != 0) {
237 PluginInsert::activate ()
239 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
243 Processor::activate ();
247 PluginInsert::deactivate ()
249 Processor::deactivate ();
251 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
257 PluginInsert::flush ()
259 for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
265 PluginInsert::connect_and_run (BufferSet& bufs, nframes_t nframes, nframes_t offset, bool with_auto, nframes_t now)
267 // Calculate if, and how many frames we need to collect for analysis
268 nframes_t collect_signal_nframes = (_signal_analysis_collect_nframes_max -
269 _signal_analysis_collected_nframes);
270 if (nframes < collect_signal_nframes) { // we might not get all frames now
271 collect_signal_nframes = nframes;
274 ChanMapping in_map(input_streams());
275 ChanMapping out_map(output_streams());
277 /* Note that we've already required that plugins
278 be able to handle in-place processing.
285 for (Controls::iterator li = controls().begin(); li != controls().end(); ++li, ++n) {
287 boost::shared_ptr<AutomationControl> c
288 = boost::dynamic_pointer_cast<AutomationControl>(li->second);
290 if (c->parameter().type() == PluginAutomation && c->automation_playback()) {
293 const float val = c->list()->rt_safe_eval (now, valid);
303 if (collect_signal_nframes > 0) {
305 //std::cerr << "collect input, bufs " << bufs.count().n_audio() << " count, " << bufs.available().n_audio() << " available" << std::endl;
306 //std::cerr << " streams " << input_streams().n_audio() << std::endl;
307 //std::cerr << "filling buffer with " << collect_signal_nframes << " frames at " << _signal_analysis_collected_nframes << std::endl;
309 _signal_analysis_inputs.set_count(input_streams());
311 for (uint32_t i = 0; i < input_streams().n_audio(); ++i) {
312 _signal_analysis_inputs.get_audio(i).read_from(
314 collect_signal_nframes,
315 _signal_analysis_collected_nframes); // offset is for target buffer
320 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
321 (*i)->connect_and_run(bufs, in_map, out_map, nframes, offset);
322 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
323 in_map.offset_to(*t, natural_input_streams().get(*t));
324 out_map.offset_to(*t, natural_output_streams().get(*t));
328 if (collect_signal_nframes > 0) {
330 //std::cerr << " output, bufs " << bufs.count().n_audio() << " count, " << bufs.available().n_audio() << " available" << std::endl;
331 //std::cerr << " streams " << output_streams().n_audio() << std::endl;
333 _signal_analysis_outputs.set_count(output_streams());
335 for (uint32_t i = 0; i < output_streams().n_audio(); ++i) {
336 _signal_analysis_outputs.get_audio(i).read_from(
338 collect_signal_nframes,
339 _signal_analysis_collected_nframes); // offset is for target buffer
342 _signal_analysis_collected_nframes += collect_signal_nframes;
343 assert(_signal_analysis_collected_nframes <= _signal_analysis_collect_nframes_max);
345 if (_signal_analysis_collected_nframes == _signal_analysis_collect_nframes_max) {
346 _signal_analysis_collect_nframes_max = 0;
347 _signal_analysis_collected_nframes = 0;
349 AnalysisDataGathered(&_signal_analysis_inputs,
350 &_signal_analysis_outputs);
353 /* leave remaining channel buffers alone */
357 PluginInsert::silence (nframes_t nframes)
359 ChanMapping in_map(input_streams());
360 ChanMapping out_map(output_streams());
363 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
364 (*i)->connect_and_run (_session.get_silent_buffers ((*i)->get_info()->n_inputs), in_map, out_map, nframes, 0);
370 PluginInsert::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, nframes_t nframes, bool)
372 if (_active || _pending_active) {
374 if (_session.transport_rolling()) {
375 automation_run (bufs, nframes);
377 connect_and_run (bufs, nframes, 0, false);
382 /* FIXME: type, audio only */
384 uint32_t in = _plugins[0]->get_info()->n_inputs.n_audio();
385 uint32_t out = _plugins[0]->get_info()->n_outputs.n_audio();
389 /* not active, but something has make up for any channel count increase */
391 for (uint32_t n = out - in; n < out; ++n) {
392 memcpy (bufs.get_audio(n).data(), bufs.get_audio(in - 1).data(), sizeof (Sample) * nframes);
396 bufs.count().set_audio(out);
399 _active = _pending_active;
403 PluginInsert::set_parameter (Evoral::Parameter param, float val)
405 if (param.type() != PluginAutomation)
408 /* the others will be set from the event triggered by this */
410 _plugins[0]->set_parameter (param.id(), val);
412 boost::shared_ptr<AutomationControl> ac
413 = boost::dynamic_pointer_cast<AutomationControl>(control(param));
418 warning << "set_parameter called for nonexistant parameter "
419 << EventTypeMap::instance().to_symbol(param) << endmsg;
422 _session.set_dirty();
426 PluginInsert::get_parameter (Evoral::Parameter param)
428 if (param.type() != PluginAutomation) {
431 assert (!_plugins.empty ());
432 return _plugins[0]->get_parameter (param.id());
437 PluginInsert::automation_run (BufferSet& bufs, nframes_t nframes)
439 Evoral::ControlEvent next_event (0, 0.0f);
440 nframes_t now = _session.transport_frame ();
441 nframes_t end = now + nframes;
442 nframes_t offset = 0;
444 Glib::Mutex::Lock lm (control_lock(), Glib::TRY_LOCK);
447 connect_and_run (bufs, nframes, offset, false);
451 if (!find_next_event (now, end, next_event) || requires_fixed_sized_buffers()) {
453 /* no events have a time within the relevant range */
455 connect_and_run (bufs, nframes, offset, true, now);
461 nframes_t cnt = min (((nframes_t) ceil (next_event.when) - now), nframes);
463 connect_and_run (bufs, cnt, offset, true, now);
469 if (!find_next_event (now, end, next_event)) {
474 /* cleanup anything that is left to do */
477 connect_and_run (bufs, nframes, offset, true, now);
482 PluginInsert::default_parameter_value (const Evoral::Parameter& param)
484 if (param.type() != PluginAutomation)
487 if (_plugins.empty()) {
488 fatal << _("programming error: ") << X_("PluginInsert::default_parameter_value() called with no plugin")
493 return _plugins[0]->default_value (param.id());
496 boost::shared_ptr<Plugin>
497 PluginInsert::plugin_factory (boost::shared_ptr<Plugin> other)
499 boost::shared_ptr<LadspaPlugin> lp;
501 boost::shared_ptr<LV2Plugin> lv2p;
504 boost::shared_ptr<VSTPlugin> vp;
506 #ifdef HAVE_AUDIOUNITS
507 boost::shared_ptr<AUPlugin> ap;
510 if ((lp = boost::dynamic_pointer_cast<LadspaPlugin> (other)) != 0) {
511 return boost::shared_ptr<Plugin> (new LadspaPlugin (*lp));
513 } else if ((lv2p = boost::dynamic_pointer_cast<LV2Plugin> (other)) != 0) {
514 return boost::shared_ptr<Plugin> (new LV2Plugin (*lv2p));
517 } else if ((vp = boost::dynamic_pointer_cast<VSTPlugin> (other)) != 0) {
518 return boost::shared_ptr<Plugin> (new VSTPlugin (*vp));
520 #ifdef HAVE_AUDIOUNITS
521 } else if ((ap = boost::dynamic_pointer_cast<AUPlugin> (other)) != 0) {
522 return boost::shared_ptr<Plugin> (new AUPlugin (*ap));
526 fatal << string_compose (_("programming error: %1"),
527 X_("unknown plugin type in PluginInsert::plugin_factory"))
530 return boost::shared_ptr<Plugin> ((Plugin*) 0);
534 PluginInsert::configure_io (ChanCount in, ChanCount out)
536 if (set_count (count_for_configuration (in, out)) < 0) {
540 /* if we're running replicated plugins, each plugin has
541 the same i/o configuration and we may need to announce how many
542 output streams there are.
544 if we running a single plugin, we need to configure it.
547 if (_plugins.front()->configure_io (in, out) < 0) {
551 // we don't know the analysis window size, so we must work with the
552 // current buffer size here. each request for data fills in these
553 // buffers and the analyser makes sure it gets enough data for the
555 session().ensure_buffer_set (_signal_analysis_inputs, in);
556 //_signal_analysis_inputs.set_count (in);
558 session().ensure_buffer_set (_signal_analysis_outputs, out);
559 //_signal_analysis_outputs.set_count (out);
561 // std::cerr << "set counts to i" << in.n_audio() << "/o" << out.n_audio() << std::endl;
563 return Processor::configure_io (in, out);
567 PluginInsert::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
569 // Plugin has flexible I/O, so delegate to it
570 if (_plugins.front()->reconfigurable_io()) {
571 return _plugins.front()->can_support_io_configuration (in, out);
574 ChanCount inputs = _plugins[0]->get_info()->n_inputs;
575 ChanCount outputs = _plugins[0]->get_info()->n_outputs;
577 // Plugin inputs match requested inputs exactly
583 // See if replication is possible
584 // We can replicate if there exists a single factor f such that, for every type,
585 // the number of plugin inputs * f = the requested number of inputs
587 bool can_replicate = true;
588 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
589 // No inputs of this type
590 if (inputs.get(*t) == 0 && in.get(*t) == 0) {
593 // Plugin has more inputs than requested, can not replicate
594 } else if (inputs.get(*t) >= in.get(*t)) {
595 can_replicate = false;
598 // Plugin inputs is not a factor of requested inputs, can not replicate
599 } else if (inputs.get(*t) == 0 || in.get(*t) % inputs.get(*t) != 0) {
600 can_replicate = false;
603 // Potential factor not set yet
605 f = in.get(*t) / inputs.get(*t);;
608 // Factor for this type does not match another type, can not replicate
609 if (f != (in.get(*t) / inputs.get(*t))) {
610 can_replicate = false;
616 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
617 out.set (*t, outputs.get(*t) * f);
625 /* Number of plugin instances required to support a given channel configuration.
629 PluginInsert::count_for_configuration (ChanCount in, ChanCount /*out*/) const
631 if (_plugins.front()->reconfigurable_io()) {
632 /* plugin has flexible I/O, so the answer is always 1 */
633 /* this could change if we ever decide to replicate AU's */
637 // FIXME: take 'out' into consideration
639 ChanCount outputs = _plugins[0]->get_info()->n_outputs;
640 ChanCount inputs = _plugins[0]->get_info()->n_inputs;
642 if (inputs.n_total() == 0) {
643 /* instrument plugin, always legal, but throws away any existing streams */
647 if (inputs.n_total() == 1 && outputs == inputs
648 && ((inputs.n_audio() == 0 && in.n_audio() == 0)
649 || (inputs.n_midi() == 0 && in.n_midi() == 0))) {
650 /* mono plugin, replicate as needed to match in */
659 // assumes in is valid, so we must be replicating
660 if (inputs.n_total() < in.n_total()
661 && (in.n_total() % inputs.n_total() == 0)) {
663 return in.n_total() / inputs.n_total();
671 PluginInsert::get_state(void)
677 PluginInsert::state (bool full)
679 XMLNode& node = Processor::state (full);
681 node.add_property("type", _plugins[0]->state_node_name());
682 node.add_property("unique-id", _plugins[0]->unique_id());
683 node.add_property("count", string_compose("%1", _plugins.size()));
684 node.add_child_nocopy (_plugins[0]->get_state());
686 /* add port automation state */
687 XMLNode *autonode = new XMLNode(port_automation_node_name);
688 set<Evoral::Parameter> automatable = _plugins[0]->automatable();
690 for (set<Evoral::Parameter>::iterator x = automatable.begin(); x != automatable.end(); ++x) {
692 /*XMLNode* child = new XMLNode("port");
693 snprintf(buf, sizeof(buf), "%" PRIu32, *x);
694 child->add_property("number", string(buf));
696 child->add_child_nocopy (automation_list (*x).state (full));
697 autonode->add_child_nocopy (*child);
699 AutomationList* list = dynamic_cast<AutomationList*>(control(*x)->list().get());
700 autonode->add_child_nocopy (list->state (full));
703 node.add_child_nocopy (*autonode);
709 PluginInsert::set_state(const XMLNode& node, int version)
711 XMLNodeList nlist = node.children();
712 XMLNodeIterator niter;
713 XMLPropertyList plist;
714 const XMLProperty *prop;
715 ARDOUR::PluginType type;
717 if ((prop = node.property ("type")) == 0) {
718 error << _("XML node describing plugin is missing the `type' field") << endmsg;
722 if (prop->value() == X_("ladspa") || prop->value() == X_("Ladspa")) { /* handle old school sessions */
723 type = ARDOUR::LADSPA;
724 } else if (prop->value() == X_("lv2")) {
726 } else if (prop->value() == X_("vst")) {
728 } else if (prop->value() == X_("audiounit")) {
729 type = ARDOUR::AudioUnit;
731 error << string_compose (_("unknown plugin type %1 in plugin insert state"),
737 prop = node.property ("unique-id");
741 /* older sessions contain VST plugins with only an "id" field.
744 if (type == ARDOUR::VST) {
745 prop = node.property ("id");
751 error << _("Plugin has no unique ID field") << endmsg;
756 boost::shared_ptr<Plugin> plugin;
758 plugin = find_plugin (_session, prop->value(), type);
761 error << string_compose(_("Found a reference to a plugin (\"%1\") that is unknown.\n"
762 "Perhaps it was removed or moved since it was last used."), prop->value())
768 bool need_automatables = true;
770 if (_plugins.empty()) {
771 /* if we are adding the first plugin, we will need to set
772 up automatable controls.
774 need_automatables = true;
777 if ((prop = node.property ("count")) != 0) {
778 sscanf (prop->value().c_str(), "%u", &count);
781 if (_plugins.size() != count) {
783 _plugins.push_back (plugin);
785 for (uint32_t n = 1; n < count; ++n) {
786 _plugins.push_back (plugin_factory (plugin));
790 if (need_automatables) {
794 /* Handle the node list for this Processor (or Insert if an A2 session) */
795 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
797 if ((*niter)->name() == plugin->state_node_name()) {
799 for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
800 (*i)->set_state (**niter, version);
806 Processor::set_state (node, version);
808 if (version < 3000) {
810 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
811 if ((*niter)->name() == "Redirect") {
812 /* XXX do we need to tackle placement? i think not (pd; oct 16 2009) */
813 Processor::set_state (**niter, version);
818 set_parameter_state_2X (node, version);
822 set_parameter_state (node, version);
825 // The name of the PluginInsert comes from the plugin, nothing else
826 _name = plugin->get_info()->name;
828 /* catch up on I/O */
831 Glib::Mutex::Lock em (_session.engine().process_lock());
832 IO::PortCountChanged (max(input_streams(), output_streams()));
839 PluginInsert::set_parameter_state (const XMLNode& node, int version)
841 XMLNodeList nlist = node.children();
842 XMLNodeIterator niter;
844 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
846 if ((*niter)->name() != port_automation_node_name) {
852 XMLNodeConstIterator iter;
857 cnodes = (*niter)->children ("AutomationList");
859 for (iter = cnodes.begin(); iter != cnodes.end(); ++iter) {
863 /* XXX this code knows way too much about the internal details of an AutomationList state node */
865 if ((cprop = child->property("automation-id")) != 0) {
866 port = cprop->value().c_str();
868 warning << _("PluginInsert: Auto: no plugin parameter number seen") << endmsg;
872 if (sscanf (port, "parameter-%" PRIu32, &port_id) != 1) {
873 warning << _("PluginInsert: Auto: no parameter number found") << endmsg;
877 if (port_id >= _plugins[0]->parameter_count()) {
878 warning << _("PluginInsert: Auto: plugin parameter out of range") << endmsg;
882 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(
883 control(Evoral::Parameter(PluginAutomation, 0, port_id), true));
886 c->alist()->set_state (*child, version);
888 error << string_compose (_("PluginInsert: automatable control %1 not found - ignored"), port_id) << endmsg;
899 PluginInsert::set_parameter_state_2X (const XMLNode& node, int version)
901 XMLNodeList nlist = node.children();
902 XMLNodeIterator niter;
904 /* look for port automation node */
906 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
908 if ((*niter)->name() != port_automation_node_name) {
914 XMLNodeConstIterator iter;
919 cnodes = (*niter)->children ("port");
921 for (iter = cnodes.begin(); iter != cnodes.end(); ++iter){
925 if ((cprop = child->property("number")) != 0) {
926 port = cprop->value().c_str();
928 warning << _("PluginInsert: Auto: no ladspa port number") << endmsg;
932 sscanf (port, "%" PRIu32, &port_id);
934 if (port_id >= _plugins[0]->parameter_count()) {
935 warning << _("PluginInsert: Auto: port id out of range") << endmsg;
939 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(
940 control(Evoral::Parameter(PluginAutomation, 0, port_id), true));
943 if (!child->children().empty()) {
944 c->alist()->set_state (*child->children().front(), version);
947 error << string_compose (_("PluginInsert: automatable control %1 not found - ignored"), port_id) << endmsg;
959 PluginInsert::describe_parameter (Evoral::Parameter param)
961 if (param.type() != PluginAutomation)
962 return Automatable::describe_parameter(param);
964 return _plugins[0]->describe_parameter (param);
968 PluginInsert::signal_latency() const
971 return _user_latency;
974 return _plugins[0]->signal_latency ();
978 PluginInsert::type ()
980 return plugin()->get_info()->type;
983 PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> list)
984 : AutomationControl (p->session(), param, list, p->describe_parameter(param))
987 Plugin::ParameterDescriptor desc;
988 p->plugin(0)->get_parameter_descriptor (param.id(), desc);
989 _logarithmic = desc.logarithmic;
990 _toggled = desc.toggled;
994 PluginInsert::PluginControl::set_value (double val)
996 /* FIXME: probably should be taking out some lock here.. */
1006 /*const float range = _list->get_max_y() - _list->get_min_y();
1007 const float lower = _list->get_min_y();
1009 if (!_logarithmic) {
1010 val = lower + (range * val);
1012 float log_lower = 0.0f;
1014 log_lower = log(lower);
1017 val = exp(log_lower + log(range) * val);
1022 for (Plugins::iterator i = _plugin->_plugins.begin();
1023 i != _plugin->_plugins.end(); ++i) {
1024 (*i)->set_parameter (_list->parameter().id(), val);
1027 boost::shared_ptr<Plugin> iasp = _plugin->_impulseAnalysisPlugin.lock();
1029 iasp->set_parameter (_list->parameter().id(), val);
1032 AutomationControl::set_value(val);
1036 PluginInsert::PluginControl::get_value (void) const
1038 /* FIXME: probably should be taking out some lock here.. */
1040 double val = _plugin->get_parameter (_list->parameter());
1054 return ((val - lower) / range);
1058 boost::shared_ptr<Plugin>
1059 PluginInsert::get_impulse_analysis_plugin()
1061 boost::shared_ptr<Plugin> ret;
1062 if (_impulseAnalysisPlugin.expired()) {
1063 ret = plugin_factory(_plugins[0]);
1064 _impulseAnalysisPlugin = ret;
1066 ret = _impulseAnalysisPlugin.lock();
1073 PluginInsert::collect_signal_for_analysis(nframes_t nframes)
1075 // called from outside the audio thread, so this should be safe
1076 // only do audio as analysis is (currently) only for audio plugins
1077 _signal_analysis_inputs.ensure_buffers( DataType::AUDIO, input_streams().n_audio(), nframes);
1078 _signal_analysis_outputs.ensure_buffers( DataType::AUDIO, output_streams().n_audio(), nframes);
1080 _signal_analysis_collected_nframes = 0;
1081 _signal_analysis_collect_nframes_max = nframes;