2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2019-08-02 22:01:25 -04:00
|
|
|
* Copyright (C) 2007-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2009-2011 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2016 Tim Mayberry <mojofunk@gmail.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-07-12 20:26:28 -04:00
|
|
|
#ifdef WAF_BUILD
|
|
|
|
#include "libardour-config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
#include <string>
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "pbd/xml++.h"
|
2016-08-25 02:28:52 -04:00
|
|
|
#include "pbd/types_convert.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/automatable.h"
|
|
|
|
#include "ardour/chan_count.h"
|
2017-06-21 12:57:41 -04:00
|
|
|
#include "ardour/debug.h"
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/processor.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/types.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2011-11-21 12:42:29 -05:00
|
|
|
#ifdef WINDOWS_VST_SUPPORT
|
|
|
|
#include "ardour/windows_vst_plugin.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
#endif
|
|
|
|
|
2011-10-18 11:08:42 -04:00
|
|
|
#ifdef AUDIOUNIT_SUPPORT
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/audio_unit.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
#endif
|
|
|
|
|
2009-02-25 13:26:51 -05:00
|
|
|
#include "ardour/audioengine.h"
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/types.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
|
2012-05-24 02:09:29 -04:00
|
|
|
namespace ARDOUR { class Session; }
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
// Always saved as Processor, but may be IOProcessor or Send in legacy sessions
|
|
|
|
const string Processor::state_node_name = "Processor";
|
|
|
|
|
2023-07-21 11:56:42 -04:00
|
|
|
Processor::Processor(Session& session, const string& name, Temporal::TimeDomainProvider const & tdp)
|
2008-09-21 12:17:02 -04:00
|
|
|
: SessionObject(session, name)
|
2023-07-21 11:56:42 -04:00
|
|
|
, Automatable (session, tdp)
|
2009-07-21 10:39:21 -04:00
|
|
|
, _pending_active(false)
|
2008-06-02 17:41:35 -04:00
|
|
|
, _active(false)
|
|
|
|
, _next_ab_is_active(false)
|
|
|
|
, _configured(false)
|
2009-11-18 15:01:37 -05:00
|
|
|
, _display_to_user (true)
|
2010-05-17 19:28:13 -04:00
|
|
|
, _pre_fader (false)
|
2011-04-12 21:44:46 -04:00
|
|
|
, _ui_pointer (0)
|
2014-11-28 19:35:49 -05:00
|
|
|
, _window_proxy (0)
|
2016-03-27 15:34:32 -04:00
|
|
|
, _pinmgr_proxy (0)
|
2013-11-22 12:22:55 -05:00
|
|
|
, _owner (0)
|
2017-06-23 14:19:04 -04:00
|
|
|
, _input_latency (0)
|
2017-09-18 20:10:38 -04:00
|
|
|
, _output_latency (0)
|
2017-09-28 00:04:58 -04:00
|
|
|
, _capture_offset (0)
|
|
|
|
, _playback_offset (0)
|
2017-10-31 13:32:26 -04:00
|
|
|
, _loop_location (0)
|
2011-01-31 21:41:31 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Processor::Processor (const Processor& other)
|
2011-02-06 20:12:55 -05:00
|
|
|
: Evoral::ControlSet (other)
|
|
|
|
, SessionObject (other.session(), other.name())
|
2023-07-21 11:56:42 -04:00
|
|
|
, Automatable (other.session(), other)
|
2011-09-30 13:55:14 -04:00
|
|
|
, Latent (other)
|
2011-01-31 21:41:31 -05:00
|
|
|
, _pending_active(other._pending_active)
|
|
|
|
, _active(other._active)
|
|
|
|
, _next_ab_is_active(false)
|
|
|
|
, _configured(false)
|
|
|
|
, _display_to_user (true)
|
|
|
|
, _pre_fader (false)
|
2011-04-12 21:44:46 -04:00
|
|
|
, _ui_pointer (0)
|
2014-11-28 19:35:49 -05:00
|
|
|
, _window_proxy (0)
|
2016-03-27 15:34:32 -04:00
|
|
|
, _pinmgr_proxy (0)
|
2014-11-28 19:35:49 -05:00
|
|
|
, _owner (0)
|
2017-06-23 14:19:04 -04:00
|
|
|
, _input_latency (0)
|
2017-10-31 13:32:26 -04:00
|
|
|
, _output_latency (0)
|
|
|
|
, _capture_offset (0)
|
|
|
|
, _playback_offset (0)
|
|
|
|
, _loop_location (other._loop_location)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-06-21 12:57:41 -04:00
|
|
|
Processor::~Processor ()
|
|
|
|
{
|
|
|
|
DEBUG_TRACE (DEBUG::Destruction, string_compose ("processor %1 destructor\n", _name));
|
|
|
|
}
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
XMLNode&
|
2022-04-06 23:56:32 -04:00
|
|
|
Processor::get_state () const
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2017-10-03 18:35:29 -04:00
|
|
|
return state ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
/* NODE STRUCTURE
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
<Automation [optionally with visible="...." ]>
|
|
|
|
<parameter-N>
|
|
|
|
<AutomationList id=N>
|
|
|
|
<events>
|
|
|
|
X1 Y1
|
|
|
|
X2 Y2
|
|
|
|
....
|
|
|
|
</events>
|
|
|
|
</parameter-N>
|
|
|
|
<Automation>
|
|
|
|
*/
|
|
|
|
|
|
|
|
XMLNode&
|
2022-04-06 23:56:32 -04:00
|
|
|
Processor::state () const
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
XMLNode* node = new XMLNode (state_node_name);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2016-08-25 02:28:52 -04:00
|
|
|
node->set_property("id", id());
|
|
|
|
node->set_property("name", name());
|
|
|
|
node->set_property("active", active());
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
if (_extra_xml){
|
|
|
|
node->add_child_copy (*_extra_xml);
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-10-03 18:35:29 -04:00
|
|
|
if (!skip_saving_automation) {
|
2010-09-18 16:01:36 -04:00
|
|
|
XMLNode& automation = Automatable::get_automation_xml_state();
|
2011-06-11 11:35:34 -04:00
|
|
|
if (!automation.children().empty() || !automation.properties().empty()) {
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 02:30:50 -04:00
|
|
|
node->add_child_nocopy (automation);
|
2016-04-24 08:41:07 -04:00
|
|
|
} else {
|
|
|
|
delete &automation;
|
The great audio processing overhaul.
The vast majority of Route signal processing is now simply in the list of
processors. There are definitely regressions here, but there's also
a lot of things fixed. It's far too much work to let diverge anymore
regardless, so here it is.
The basic model is: A route has a fixed set of input channels (matching
its JACK input ports and diskstream). The first processor takes this
as input. The next processor is configured using the first processor's
output as input, and is allowed to choose whatever output it wants
given that input... and so on, and so on. Finally, the last processor's
requested output is used to set up the panner and create whatever Jack
ports are needed to output the data.
All 'special' internal processors (meter, fader, amp, insert, send) are
currently transparent: they read any input, and return the same set
of channels back (unmodified, except for amp).
User visible changes:
* LV2 Instrument support (tracks with both MIDI and audio channels)
* MIDI in/out plugin support
* Generic plugin replication (for MIDI plugins, MIDI/audio plugins)
* Movable meter point
Known Bugs:
* Things seem to get weird on loaded sessions
* Output delivery is sketchy
* 2.0 session loading was probably already broken...
but it's definitely broken now :)
Please test this and file bugs if you have any time...
git-svn-id: svn://localhost/ardour2/branches/3.0@5055 d708f5d6-7413-0410-9779-e7cbd77b26cf
2009-05-07 02:30:50 -04:00
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2019-02-15 18:13:30 -05:00
|
|
|
Latent::add_state (node);
|
2011-07-14 20:03:18 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2009-10-20 20:15:42 -04:00
|
|
|
Processor::set_state_2X (const XMLNode & node, int /*version*/)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
2009-10-14 20:57:55 -04:00
|
|
|
XMLProperty const * prop;
|
|
|
|
|
|
|
|
XMLNodeList children = node.children ();
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-10-14 20:57:55 -04:00
|
|
|
for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
|
|
|
|
|
|
|
|
if ((*i)->name() == X_("IO")) {
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-10-14 20:57:55 -04:00
|
|
|
if ((prop = (*i)->property ("name")) != 0) {
|
|
|
|
set_name (prop->value ());
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2011-10-18 09:18:47 -04:00
|
|
|
set_id (**i);
|
2009-10-14 20:57:55 -04:00
|
|
|
|
2015-03-05 13:48:30 -05:00
|
|
|
//note: in A2, active state was stored in the Redirect node, not the child IO node
|
|
|
|
/*
|
|
|
|
* if ((prop = (*i)->property ("active")) != 0) {
|
2010-08-07 19:31:33 -04:00
|
|
|
bool const a = string_is_affirmative (prop->value ());
|
|
|
|
if (_active != a) {
|
|
|
|
if (a) {
|
|
|
|
activate ();
|
|
|
|
} else {
|
|
|
|
deactivate ();
|
|
|
|
}
|
2009-10-14 20:57:55 -04:00
|
|
|
}
|
2015-03-05 13:48:30 -05:00
|
|
|
}*/
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2009-10-14 20:57:55 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
Processor::set_state (const XMLNode& node, int version)
|
|
|
|
{
|
|
|
|
if (version < 3000) {
|
|
|
|
return set_state_2X (node, version);
|
|
|
|
}
|
2011-06-01 12:50:12 -04:00
|
|
|
|
2016-08-25 02:28:52 -04:00
|
|
|
bool ignore_name;
|
|
|
|
// Only testing for the presence of the property not value
|
|
|
|
if (!node.get_property("ignore-name", ignore_name)) {
|
|
|
|
string name;
|
2012-03-13 16:14:55 -04:00
|
|
|
// may not exist for legacy 3.0 sessions
|
2016-08-25 02:28:52 -04:00
|
|
|
if (node.get_property ("name", name)) {
|
2012-03-13 16:14:55 -04:00
|
|
|
/* don't let derived classes have a crack at set_name,
|
|
|
|
as some (like Send) will screw with the one we suggest.
|
|
|
|
*/
|
2016-08-25 02:28:52 -04:00
|
|
|
Processor::set_name (name);
|
2012-03-13 16:14:55 -04:00
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2012-03-13 16:14:55 -04:00
|
|
|
set_id (node);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
XMLNodeList nlist = node.children();
|
|
|
|
XMLNodeIterator niter;
|
|
|
|
|
2011-06-11 11:35:34 -04:00
|
|
|
Stateful::save_extra_xml (node);
|
|
|
|
|
2016-08-25 02:28:52 -04:00
|
|
|
XMLProperty const * prop = 0;
|
|
|
|
XMLProperty const * legacy_active = 0;
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
|
|
|
|
|
|
|
|
if ((*niter)->name() == X_("Automation")) {
|
|
|
|
|
|
|
|
if ((prop = (*niter)->property ("path")) != 0) {
|
|
|
|
old_set_automation_state (*(*niter));
|
|
|
|
} else {
|
2010-09-18 16:01:36 -04:00
|
|
|
set_automation_xml_state (*(*niter), Evoral::Parameter(PluginAutomation));
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2008-07-16 15:49:19 -04:00
|
|
|
} else if ((*niter)->name() == "Redirect") {
|
|
|
|
if ( !(legacy_active = (*niter)->property("active"))) {
|
|
|
|
error << string_compose(_("No %1 property flag in element %2"), "active", (*niter)->name()) << endl;
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((prop = node.property ("active")) == 0) {
|
2008-07-16 15:49:19 -04:00
|
|
|
if (legacy_active) {
|
|
|
|
prop = legacy_active;
|
|
|
|
} else {
|
|
|
|
error << _("No child node with active property") << endmsg;
|
|
|
|
return -1;
|
|
|
|
}
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
2016-08-31 01:36:01 -04:00
|
|
|
bool const a = string_to<bool> (prop->value ()) && !_session.get_bypass_all_loaded_plugins();
|
2010-08-07 19:31:33 -04:00
|
|
|
if (_active != a) {
|
|
|
|
if (a) {
|
|
|
|
activate ();
|
|
|
|
} else {
|
|
|
|
deactivate ();
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2008-07-16 15:49:19 -04:00
|
|
|
|
2019-02-15 18:13:30 -05:00
|
|
|
Latent::set_state (node, version);
|
2011-07-14 20:03:18 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-05-25 06:15:54 -04:00
|
|
|
/** @pre Caller must hold process lock */
|
2008-09-10 11:03:30 -04:00
|
|
|
bool
|
|
|
|
Processor::configure_io (ChanCount in, ChanCount out)
|
|
|
|
{
|
2009-05-04 11:50:51 -04:00
|
|
|
/* This class assumes 1:1 input:output.static output stream count.
|
|
|
|
Derived classes must override and set _configured_output appropriately
|
2009-10-14 12:10:01 -04:00
|
|
|
if this is not the case
|
2009-06-09 16:21:19 -04:00
|
|
|
*/
|
2020-04-12 07:36:47 -04:00
|
|
|
bool changed = _configured_input != in || _configured_output != out;
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2009-10-14 12:10:01 -04:00
|
|
|
_configured_input = in;
|
|
|
|
_configured_output = out;
|
2008-09-10 11:03:30 -04:00
|
|
|
_configured = true;
|
|
|
|
|
2020-04-12 07:36:47 -04:00
|
|
|
if (changed) {
|
|
|
|
ConfigurationChanged (in, out); /* EMIT SIGNAL */
|
|
|
|
}
|
2009-05-04 13:05:55 -04:00
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
return true;
|
|
|
|
}
|
2009-11-18 15:01:37 -05:00
|
|
|
|
2017-11-01 10:46:23 -04:00
|
|
|
bool
|
|
|
|
Processor::map_loop_range (samplepos_t& start, samplepos_t& end) const
|
|
|
|
{
|
|
|
|
if (!_loop_location) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (start >= end) {
|
|
|
|
/* no backwards looping */
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-20 18:34:09 -04:00
|
|
|
const samplepos_t loop_end = _loop_location->end().samples ();
|
2017-11-01 10:46:23 -04:00
|
|
|
if (start < loop_end) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-09-20 18:34:09 -04:00
|
|
|
const samplepos_t loop_start = _loop_location->start().samples ();
|
2017-11-01 10:46:23 -04:00
|
|
|
const samplecnt_t looplen = loop_end - loop_start;
|
|
|
|
const sampleoffset_t start_off = (start - loop_start) % looplen;
|
|
|
|
const samplepos_t start_pos = loop_start + start_off;
|
|
|
|
|
|
|
|
assert (start >= start_pos);
|
|
|
|
end -= start - start_pos;
|
|
|
|
start = start_pos;
|
|
|
|
assert (end > start);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-11-18 15:01:37 -05:00
|
|
|
void
|
2011-06-01 12:50:12 -04:00
|
|
|
Processor::set_display_to_user (bool yn)
|
2009-11-18 15:01:37 -05:00
|
|
|
{
|
|
|
|
_display_to_user = yn;
|
|
|
|
}
|
|
|
|
|
2010-05-17 19:28:13 -04:00
|
|
|
void
|
|
|
|
Processor::set_pre_fader (bool p)
|
|
|
|
{
|
|
|
|
_pre_fader = p;
|
|
|
|
}
|
2011-01-31 21:41:31 -05:00
|
|
|
|
2013-10-14 11:12:50 -04:00
|
|
|
void
|
|
|
|
Processor::set_owner (SessionObject* o)
|
|
|
|
{
|
|
|
|
_owner = o;
|
|
|
|
}
|
|
|
|
|
|
|
|
SessionObject*
|
|
|
|
Processor::owner() const
|
|
|
|
{
|
|
|
|
return _owner;
|
|
|
|
}
|