2009-01-13 06:13:59 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
|
|
|
|
* Copyright (C) 2009-2012 David Robillard <d@drobilla.net>
|
|
|
|
* Copyright (C) 2009-2018 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2012-2016 Robin Gareus <robin@gareus.org>
|
|
|
|
* Copyright (C) 2016 Julien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2023-02-16 12:59:41 -05:00
|
|
|
#include <memory>
|
2009-01-30 15:18:31 -05:00
|
|
|
#include <cstring>
|
2023-02-16 12:59:41 -05:00
|
|
|
|
2010-12-10 11:31:14 -05:00
|
|
|
#include <boost/algorithm/string.hpp>
|
2009-01-30 15:18:31 -05:00
|
|
|
|
2010-08-01 06:26:19 -04:00
|
|
|
#include "midi++/mmc.h"
|
|
|
|
|
2022-07-25 19:58:11 -04:00
|
|
|
#include "pbd/natsort.h"
|
|
|
|
|
2020-04-09 16:01:41 -04:00
|
|
|
#include "ardour/audio_port.h"
|
2019-10-18 09:17:54 -04:00
|
|
|
#include "ardour/async_midi_port.h"
|
2009-01-13 06:13:59 -05:00
|
|
|
#include "ardour/audioengine.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/auditioner.h"
|
2009-01-20 09:46:00 -05:00
|
|
|
#include "ardour/bundle.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/control_protocol_manager.h"
|
2022-10-15 22:03:21 -04:00
|
|
|
#include "ardour/io_plug.h"
|
2009-01-30 15:18:31 -05:00
|
|
|
#include "ardour/io_processor.h"
|
2013-08-07 22:22:11 -04:00
|
|
|
#include "ardour/midi_port.h"
|
|
|
|
#include "ardour/midiport_manager.h"
|
2018-10-26 21:28:52 -04:00
|
|
|
#include "ardour/plugin_insert.h"
|
2015-12-03 12:43:54 -05:00
|
|
|
#include "ardour/port.h"
|
|
|
|
#include "ardour/profile.h"
|
2009-01-30 15:18:31 -05:00
|
|
|
#include "ardour/session.h"
|
2018-10-26 21:28:52 -04:00
|
|
|
#include "ardour/sidechain.h"
|
2020-04-09 16:01:41 -04:00
|
|
|
#include "ardour/transport_master.h"
|
|
|
|
#include "ardour/transport_master_manager.h"
|
2012-05-24 02:09:29 -04:00
|
|
|
#include "ardour/user_bundle.h"
|
2013-08-07 22:22:11 -04:00
|
|
|
|
2010-07-29 22:09:39 -04:00
|
|
|
#include "control_protocol/control_protocol.h"
|
2009-01-30 15:18:31 -05:00
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "gui_thread.h"
|
2009-01-30 15:18:31 -05:00
|
|
|
#include "port_group.h"
|
|
|
|
#include "port_matrix.h"
|
2009-07-17 09:18:58 -04:00
|
|
|
#include "time_axis_view.h"
|
|
|
|
#include "public_editor.h"
|
2009-01-30 15:18:31 -05:00
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2009-01-13 06:13:59 -05:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Gtk;
|
2009-06-09 16:21:19 -04:00
|
|
|
using namespace ARDOUR;
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
/** PortGroup constructor.
|
|
|
|
* @param n Name.
|
|
|
|
*/
|
|
|
|
PortGroup::PortGroup (std::string const & n)
|
2009-11-18 08:35:31 -05:00
|
|
|
: name (n)
|
2009-02-08 22:18:10 -05:00
|
|
|
{
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
PortGroup::~PortGroup()
|
|
|
|
{
|
|
|
|
for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
|
|
|
|
delete *i;
|
|
|
|
}
|
|
|
|
_bundles.clear ();
|
|
|
|
}
|
|
|
|
|
2009-11-14 18:08:17 -05:00
|
|
|
/** Add a bundle to a group.
|
|
|
|
* @param b Bundle.
|
|
|
|
* @param allow_dups true to allow the group to contain more than one bundle with the same port, otherwise false.
|
|
|
|
*/
|
2009-07-19 20:22:09 -04:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroup::add_bundle (std::shared_ptr<Bundle> b, bool allow_dups)
|
2009-07-19 20:22:09 -04:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
add_bundle_internal (b, std::shared_ptr<IO> (), false, Gdk::Color (), allow_dups);
|
2009-07-19 20:22:09 -04:00
|
|
|
}
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
/** Add a bundle to a group.
|
|
|
|
* @param b Bundle.
|
2009-11-14 18:08:17 -05:00
|
|
|
* @param io IO whose ports are in the bundle.
|
2009-01-20 09:46:00 -05:00
|
|
|
*/
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroup::add_bundle (std::shared_ptr<Bundle> b, std::shared_ptr<IO> io)
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-11-14 18:08:17 -05:00
|
|
|
add_bundle_internal (b, io, false, Gdk::Color (), false);
|
2009-07-17 09:18:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Add a bundle to a group.
|
|
|
|
* @param b Bundle.
|
2009-11-09 22:16:57 -05:00
|
|
|
* @param c Colour to represent the bundle with.
|
2009-07-17 09:18:58 -04:00
|
|
|
*/
|
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroup::add_bundle (std::shared_ptr<Bundle> b, std::shared_ptr<IO> io, Gdk::Color c)
|
2009-11-09 22:16:57 -05:00
|
|
|
{
|
2009-11-14 18:08:17 -05:00
|
|
|
add_bundle_internal (b, io, true, c, false);
|
2009-11-09 22:16:57 -05:00
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroup::BundleRecord::BundleRecord (std::shared_ptr<ARDOUR::Bundle> b, std::shared_ptr<ARDOUR::IO> iop, Gdk::Color c, bool has_c)
|
2009-12-17 13:24:23 -05:00
|
|
|
: bundle (b)
|
|
|
|
, io (iop)
|
|
|
|
, colour (c)
|
|
|
|
, has_colour (has_c)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-11-09 22:16:57 -05:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroup::add_bundle_internal (std::shared_ptr<Bundle> b, std::shared_ptr<IO> io, bool has_colour, Gdk::Color colour, bool allow_dups)
|
2009-07-17 09:18:58 -04:00
|
|
|
{
|
|
|
|
assert (b.get());
|
|
|
|
|
2009-11-14 18:08:17 -05:00
|
|
|
if (!allow_dups) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-11-14 18:08:17 -05:00
|
|
|
/* don't add this bundle if we already have one with the same ports */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-11-14 18:08:17 -05:00
|
|
|
BundleList::iterator i = _bundles.begin ();
|
2009-12-17 13:24:23 -05:00
|
|
|
while (i != _bundles.end() && b->has_same_ports ((*i)->bundle) == false) {
|
2009-11-14 18:08:17 -05:00
|
|
|
++i;
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-11-14 18:08:17 -05:00
|
|
|
if (i != _bundles.end ()) {
|
|
|
|
return;
|
|
|
|
}
|
2009-11-09 22:16:57 -05:00
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
BundleRecord* br = new BundleRecord (b, io, colour, has_colour);
|
2012-04-25 08:58:19 -04:00
|
|
|
b->Changed.connect (br->changed_connection, invalidator (*this), boost::bind (&PortGroup::bundle_changed, this, _1), gui_context());
|
2009-12-17 13:24:23 -05:00
|
|
|
_bundles.push_back (br);
|
2009-07-17 09:18:58 -04:00
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
Changed ();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-01-13 06:13:59 -05:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroup::remove_bundle (std::shared_ptr<Bundle> b)
|
2009-01-13 06:13:59 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
assert (b.get());
|
2009-01-30 10:08:09 -05:00
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
BundleList::iterator i = _bundles.begin ();
|
2009-12-17 13:24:23 -05:00
|
|
|
while (i != _bundles.end() && (*i)->bundle != b) {
|
2009-07-17 09:18:58 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
if (i == _bundles.end()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-17 13:24:23 -05:00
|
|
|
delete *i;
|
2009-02-08 22:18:10 -05:00
|
|
|
_bundles.erase (i);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-17 23:17:47 -04:00
|
|
|
Changed ();
|
2009-01-20 09:46:00 -05:00
|
|
|
}
|
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
void
|
2009-06-09 16:21:19 -04:00
|
|
|
PortGroup::bundle_changed (Bundle::Change c)
|
2009-02-08 22:18:10 -05:00
|
|
|
{
|
|
|
|
BundleChanged (c);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-20 09:46:00 -05:00
|
|
|
void
|
|
|
|
PortGroup::clear ()
|
|
|
|
{
|
2009-07-17 09:18:58 -04:00
|
|
|
for (BundleList::iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
|
2009-12-17 13:24:23 -05:00
|
|
|
delete *i;
|
2009-02-08 22:18:10 -05:00
|
|
|
}
|
2009-01-30 10:08:09 -05:00
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
_bundles.clear ();
|
2009-07-17 23:17:47 -04:00
|
|
|
Changed ();
|
2009-01-13 06:13:59 -05:00
|
|
|
}
|
|
|
|
|
2009-01-24 10:21:22 -05:00
|
|
|
bool
|
|
|
|
PortGroup::has_port (std::string const& p) const
|
|
|
|
{
|
2009-06-09 16:21:19 -04:00
|
|
|
for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
|
2009-12-17 13:24:23 -05:00
|
|
|
if ((*i)->bundle->offers_port_alone (p)) {
|
2009-01-24 10:21:22 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle>
|
2009-01-26 23:21:13 -05:00
|
|
|
PortGroup::only_bundle ()
|
|
|
|
{
|
|
|
|
assert (_bundles.size() == 1);
|
2009-12-17 13:24:23 -05:00
|
|
|
return _bundles.front()->bundle;
|
2009-01-26 23:21:13 -05:00
|
|
|
}
|
2009-01-24 10:21:22 -05:00
|
|
|
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2010-06-29 22:59:13 -04:00
|
|
|
ChanCount
|
2009-02-08 22:18:10 -05:00
|
|
|
PortGroup::total_channels () const
|
2009-01-13 06:13:59 -05:00
|
|
|
{
|
2010-06-29 22:59:13 -04:00
|
|
|
ChanCount n;
|
2009-06-09 16:21:19 -04:00
|
|
|
for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
|
2009-12-17 13:24:23 -05:00
|
|
|
n += (*i)->bundle->nchannels ();
|
2009-01-30 10:08:09 -05:00
|
|
|
}
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
return n;
|
2009-01-13 06:13:59 -05:00
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO>
|
|
|
|
PortGroup::io_from_bundle (std::shared_ptr<ARDOUR::Bundle> b) const
|
2009-07-19 20:22:09 -04:00
|
|
|
{
|
|
|
|
BundleList::const_iterator i = _bundles.begin ();
|
2009-12-17 13:24:23 -05:00
|
|
|
while (i != _bundles.end() && (*i)->bundle != b) {
|
2009-07-19 20:22:09 -04:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == _bundles.end()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
return std::shared_ptr<IO> ();
|
2009-07-19 20:22:09 -04:00
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO> io ((*i)->io.lock ());
|
2010-08-28 08:55:53 -04:00
|
|
|
return io;
|
2009-07-19 20:22:09 -04:00
|
|
|
}
|
|
|
|
|
2009-12-21 20:10:25 -05:00
|
|
|
/** Remove bundles whose channels are already represented by other, larger bundles */
|
|
|
|
void
|
|
|
|
PortGroup::remove_duplicates ()
|
|
|
|
{
|
|
|
|
BundleList::iterator i = _bundles.begin();
|
|
|
|
while (i != _bundles.end()) {
|
|
|
|
|
|
|
|
BundleList::iterator tmp = i;
|
|
|
|
++tmp;
|
|
|
|
|
|
|
|
bool remove = false;
|
|
|
|
|
|
|
|
for (BundleList::iterator j = _bundles.begin(); j != _bundles.end(); ++j) {
|
|
|
|
|
2009-12-21 20:13:22 -05:00
|
|
|
if ((*j)->bundle->nchannels() > (*i)->bundle->nchannels()) {
|
2009-12-21 20:10:25 -05:00
|
|
|
/* this bundle is larger */
|
|
|
|
|
|
|
|
uint32_t k = 0;
|
2010-06-29 22:59:13 -04:00
|
|
|
while (k < (*i)->bundle->nchannels().n_total()) {
|
2009-12-21 20:10:25 -05:00
|
|
|
/* see if this channel on *i has an equivalent on *j */
|
|
|
|
uint32_t l = 0;
|
2010-06-29 22:59:13 -04:00
|
|
|
while (l < (*j)->bundle->nchannels().n_total() && (*i)->bundle->channel_ports (k) != (*j)->bundle->channel_ports (l)) {
|
2009-12-21 20:10:25 -05:00
|
|
|
++l;
|
|
|
|
}
|
|
|
|
|
2010-06-29 22:59:13 -04:00
|
|
|
if (l == (*j)->bundle->nchannels().n_total()) {
|
2009-12-21 20:10:25 -05:00
|
|
|
/* it does not */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
++k;
|
|
|
|
}
|
|
|
|
|
2010-06-29 22:59:13 -04:00
|
|
|
if (k == (*i)->bundle->nchannels().n_total()) {
|
2009-12-21 20:10:25 -05:00
|
|
|
/* all channels on *i are represented by the larger bundle *j, so remove *i */
|
|
|
|
remove = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:10:25 -05:00
|
|
|
if (remove) {
|
|
|
|
_bundles.erase (i);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2009-12-21 20:10:25 -05:00
|
|
|
i = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-19 20:22:09 -04:00
|
|
|
|
2009-01-13 06:13:59 -05:00
|
|
|
/** PortGroupList constructor.
|
|
|
|
*/
|
2009-01-30 10:08:09 -05:00
|
|
|
PortGroupList::PortGroupList ()
|
2010-06-29 22:59:13 -04:00
|
|
|
: _signals_suspended (false), _pending_change (false), _pending_bundle_change ((Bundle::Change) 0)
|
2009-01-13 06:13:59 -05:00
|
|
|
{
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-13 06:13:59 -05:00
|
|
|
}
|
|
|
|
|
2011-06-01 13:00:29 -04:00
|
|
|
PortGroupList::~PortGroupList()
|
2009-12-17 13:24:23 -05:00
|
|
|
{
|
|
|
|
/* XXX need to clean up bundles, but ownership shared with PortGroups */
|
|
|
|
}
|
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
void
|
2024-05-30 00:27:55 -04:00
|
|
|
PortGroupList::maybe_add_processor_to_list (std::weak_ptr<Processor> wp, list<std::shared_ptr<IO> >* route_ios, bool inputs, set<std::shared_ptr<IO> >& used_io)
|
2009-06-09 16:21:19 -04:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Processor> p (wp.lock());
|
2009-06-09 16:21:19 -04:00
|
|
|
|
|
|
|
if (!p) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IOProcessor> iop = std::dynamic_pointer_cast<IOProcessor> (p);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
if (iop) {
|
2009-06-09 19:43:20 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO> io = inputs ? iop->input() : iop->output();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-06-09 19:43:20 -04:00
|
|
|
if (io && used_io.find (io) == used_io.end()) {
|
2010-07-20 22:17:57 -04:00
|
|
|
route_ios->push_back (io);
|
2009-06-09 19:43:20 -04:00
|
|
|
used_io.insert (io);
|
2009-06-09 16:21:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-20 22:17:57 -04:00
|
|
|
struct RouteIOs {
|
2023-02-16 18:33:28 -05:00
|
|
|
RouteIOs (std::shared_ptr<Route> r, std::shared_ptr<IO> i) {
|
2010-07-20 22:17:57 -04:00
|
|
|
route = r;
|
|
|
|
ios.push_back (i);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Route> route;
|
2010-08-28 08:55:53 -04:00
|
|
|
/* it's ok to use a shared_ptr here as RouteIOs structs are only used during ::gather () */
|
2023-02-16 18:33:28 -05:00
|
|
|
std::list<std::shared_ptr<IO> > ios;
|
2010-07-20 22:17:57 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class RouteIOsComparator {
|
|
|
|
public:
|
|
|
|
bool operator() (RouteIOs const & a, RouteIOs const & b) {
|
2016-06-03 15:15:30 -04:00
|
|
|
return a.route->presentation_info ().order() < b.route->presentation_info().order();
|
2010-07-20 22:17:57 -04:00
|
|
|
}
|
|
|
|
};
|
2009-06-09 16:21:19 -04:00
|
|
|
|
2010-07-29 15:25:26 -04:00
|
|
|
/** Gather ports from around the system and put them in this PortGroupList.
|
|
|
|
* @param type Type of ports to collect, or NIL for all types.
|
2012-05-20 17:56:28 -04:00
|
|
|
* @param use_session_bundles true to use the session's non-user bundles. Doing this will mean that
|
|
|
|
* hardware ports will be gathered into stereo pairs, as the session sets up bundles for these pairs.
|
|
|
|
* Not using the session bundles will mean that all hardware IO will be presented separately.
|
2010-06-30 21:14:14 -04:00
|
|
|
*/
|
2009-01-13 06:13:59 -05:00
|
|
|
void
|
2012-05-20 17:56:28 -04:00
|
|
|
PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inputs, bool allow_dups, bool use_session_bundles)
|
2009-01-13 06:13:59 -05:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
clear ();
|
|
|
|
|
2009-12-04 22:04:54 -05:00
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
2009-12-07 13:35:42 -05:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<PortGroup> bus (new PortGroup (_("Busses")));
|
2023-09-23 05:32:10 -04:00
|
|
|
std::shared_ptr<PortGroup> track (new PortGroup (_("Tracks")));
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<PortGroup> sidechain (new PortGroup (_("Sidechains")));
|
|
|
|
std::shared_ptr<PortGroup> iop_pre (new PortGroup (_("I/O Pre") ));
|
|
|
|
std::shared_ptr<PortGroup> iop_post (new PortGroup (_("I/O Post") ));
|
|
|
|
std::shared_ptr<PortGroup> system (new PortGroup (_("Hardware")));
|
|
|
|
std::shared_ptr<PortGroup> program (new PortGroup (string_compose (_("%1 Misc"), PROGRAM_NAME)));
|
|
|
|
std::shared_ptr<PortGroup> other (new PortGroup (_("External")));
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2010-07-20 22:17:57 -04:00
|
|
|
/* Find the IOs which have bundles for routes and their processors. We store
|
|
|
|
these IOs in a RouteIOs class so that we can then sort the results by route
|
|
|
|
order key.
|
|
|
|
*/
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2023-04-07 17:33:13 -04:00
|
|
|
std::shared_ptr<RouteList const> routes = session->get_routes ();
|
2010-07-20 22:17:57 -04:00
|
|
|
list<RouteIOs> route_ios;
|
2009-02-08 22:18:10 -05:00
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
for (RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
|
2009-01-27 13:36:40 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* we never show the monitor bus inputs */
|
2010-12-10 10:43:01 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
if (inputs && (*i)->is_monitor()) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-12-10 10:43:01 -05:00
|
|
|
|
2009-11-25 18:24:02 -05:00
|
|
|
/* keep track of IOs that we have taken bundles from,
|
|
|
|
so that we can avoid taking the same IO from both
|
2011-06-01 13:00:29 -04:00
|
|
|
Route::output() and the main_outs Delivery
|
2010-12-10 10:43:01 -05:00
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
set<std::shared_ptr<IO> > used_io;
|
|
|
|
std::shared_ptr<IO> io = inputs ? (*i)->input() : (*i)->output();
|
2009-06-09 19:43:20 -04:00
|
|
|
used_io.insert (io);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-07-20 22:17:57 -04:00
|
|
|
RouteIOs rb (*i, io);
|
|
|
|
(*i)->foreach_processor (boost::bind (&PortGroupList::maybe_add_processor_to_list, this, _1, &rb.ios, inputs, used_io));
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2010-07-20 22:17:57 -04:00
|
|
|
route_ios.push_back (rb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sort RouteIOs by the routes' editor order keys */
|
|
|
|
route_ios.sort (RouteIOsComparator ());
|
|
|
|
|
2016-07-18 20:03:44 -04:00
|
|
|
/* Now put the bundles that belong to these sorted RouteIOs into the PortGroup. */
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2024-05-30 00:35:38 -04:00
|
|
|
for (auto & rio : route_ios) {
|
|
|
|
TimeAxisView* tv = PublicEditor::instance().time_axis_view_from_stripable (rio.route);
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2010-07-20 22:17:57 -04:00
|
|
|
/* Work out which group to put these IOs' bundles in */
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<PortGroup> g;
|
2024-05-30 00:35:38 -04:00
|
|
|
if (std::dynamic_pointer_cast<Track> (rio.route)) {
|
2010-06-29 22:59:13 -04:00
|
|
|
g = track;
|
|
|
|
} else {
|
|
|
|
g = bus;
|
2009-10-14 12:10:01 -04:00
|
|
|
}
|
2010-07-29 15:25:26 -04:00
|
|
|
|
2024-05-30 00:35:38 -04:00
|
|
|
for (auto & io : rio.ios) {
|
2016-07-18 20:03:44 -04:00
|
|
|
/* Only add the bundle if there is at least one port
|
|
|
|
* with a type that's been asked for */
|
2024-05-30 00:35:38 -04:00
|
|
|
if (type == DataType::NIL || io->bundle()->nchannels().n(type) > 0) {
|
2016-07-18 20:03:44 -04:00
|
|
|
if (tv) {
|
2024-05-30 00:35:38 -04:00
|
|
|
g->add_bundle (io->bundle(), io, tv->color ());
|
2016-07-18 20:03:44 -04:00
|
|
|
} else {
|
2024-05-30 00:35:38 -04:00
|
|
|
g->add_bundle (io->bundle(), io);
|
2016-07-18 20:03:44 -04:00
|
|
|
}
|
2009-07-17 09:18:58 -04:00
|
|
|
}
|
2009-01-26 14:25:51 -05:00
|
|
|
}
|
2018-10-26 21:28:52 -04:00
|
|
|
|
|
|
|
/* When on input side, let's look for sidechains in the route's plugins
|
|
|
|
to display them right next to their route */
|
|
|
|
for (uint32_t n = 0; inputs; ++n) {
|
2024-05-30 00:35:38 -04:00
|
|
|
std::shared_ptr<Processor> p = (rio.route)->nth_plugin (n);
|
2018-10-26 21:28:52 -04:00
|
|
|
if (!p) {
|
|
|
|
break;
|
|
|
|
}
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<SideChain> sc = std::static_pointer_cast<PluginInsert> (p)->sidechain ();
|
2018-10-26 21:28:52 -04:00
|
|
|
|
|
|
|
if (sc) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO> io = sc->input();
|
2018-10-26 21:28:52 -04:00
|
|
|
if (tv) {
|
|
|
|
sidechain->add_bundle (io->bundle(), io, tv->color ());
|
|
|
|
} else {
|
|
|
|
sidechain->add_bundle (io->bundle(), io);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-13 06:13:59 -05:00
|
|
|
}
|
2009-01-20 09:46:00 -05:00
|
|
|
|
2009-11-09 22:16:57 -05:00
|
|
|
/* Bundles owned by the session; add user bundles first, then normal ones, so
|
|
|
|
that UserBundles that offer the same ports as a normal bundle get priority
|
|
|
|
*/
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2023-04-07 17:33:13 -04:00
|
|
|
std::shared_ptr<BundleList const> b = session->bundles ();
|
2009-11-09 22:16:57 -05:00
|
|
|
|
2023-04-07 17:33:13 -04:00
|
|
|
for (auto const& i : *b) {
|
|
|
|
if (std::dynamic_pointer_cast<UserBundle> (i) && i->ports_are_inputs() == inputs) {
|
|
|
|
system->add_bundle (i, allow_dups);
|
2009-01-25 01:47:11 -05:00
|
|
|
}
|
|
|
|
}
|
2009-01-26 14:25:51 -05:00
|
|
|
|
2012-05-20 17:56:28 -04:00
|
|
|
/* Only look for non-user bundles if instructed to do so */
|
|
|
|
if (use_session_bundles) {
|
2023-04-07 17:33:13 -04:00
|
|
|
for (auto const& i : *b) {
|
|
|
|
if (std::dynamic_pointer_cast<UserBundle> (i) == 0 && i->ports_are_inputs() == inputs) {
|
|
|
|
system->add_bundle (i, allow_dups);
|
2012-05-20 17:56:28 -04:00
|
|
|
}
|
2009-11-09 22:16:57 -05:00
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-12-03 12:43:54 -05:00
|
|
|
/* miscellany */
|
|
|
|
|
|
|
|
if (type == DataType::AUDIO || type == DataType::NIL) {
|
|
|
|
if (!inputs) {
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2024-04-02 20:01:11 -04:00
|
|
|
if (session->the_auditioner()) {
|
|
|
|
program->add_bundle (session->the_auditioner()->output()->bundle());
|
|
|
|
}
|
2022-08-04 18:41:37 -04:00
|
|
|
if (session->click_io()) {
|
|
|
|
program->add_bundle (session->click_io()->bundle());
|
|
|
|
}
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> ltc (new Bundle (_("LTC Out"), inputs));
|
2015-12-03 12:43:54 -05:00
|
|
|
ltc->add_channel (_("LTC Out"), DataType::AUDIO, session->engine().make_port_name_non_relative (session->ltc_output_port()->name()));
|
|
|
|
program->add_bundle (ltc);
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2015-12-03 12:43:54 -05:00
|
|
|
} else {
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> sync (new Bundle (_("Sync"), inputs));
|
2020-04-09 16:01:41 -04:00
|
|
|
AudioEngine* ae = AudioEngine::instance();
|
2024-05-30 00:36:03 -04:00
|
|
|
TransportMasterManager::TransportMasters const & tms (TransportMasterManager::instance().transport_masters());
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2024-05-30 00:36:03 -04:00
|
|
|
for (auto const & tm : tms) {
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2024-05-30 00:36:03 -04:00
|
|
|
std::shared_ptr<Port> port = tm->port ();
|
2020-04-09 16:01:41 -04:00
|
|
|
|
|
|
|
if (!port) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
if (!std::dynamic_pointer_cast<AudioPort> (port)) {
|
2020-04-09 16:01:41 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2024-05-30 00:36:03 -04:00
|
|
|
sync->add_channel (tm->name(), DataType::AUDIO, ae->make_port_name_non_relative (port->name()));
|
2020-04-09 16:01:41 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
program->add_bundle (sync);
|
2015-12-03 12:43:54 -05:00
|
|
|
}
|
2009-07-18 00:05:26 -04:00
|
|
|
}
|
2009-07-17 23:57:01 -04:00
|
|
|
|
2015-12-03 12:43:54 -05:00
|
|
|
/* our control surfaces */
|
2010-07-29 22:09:39 -04:00
|
|
|
|
2015-12-03 22:01:07 -05:00
|
|
|
/* XXX assume for now that all control protocols with ports use
|
|
|
|
* MIDI. If anyone created a control protocol that used audio ports,
|
|
|
|
* this will break.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ((type == DataType::MIDI || type == DataType::NIL)) {
|
|
|
|
ControlProtocolManager& m = ControlProtocolManager::instance ();
|
|
|
|
for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
|
|
|
|
if ((*i)->protocol) {
|
2023-02-16 18:33:28 -05:00
|
|
|
list<std::shared_ptr<Bundle> > b = (*i)->protocol->bundles ();
|
|
|
|
for (list<std::shared_ptr<Bundle> >::iterator j = b.begin(); j != b.end(); ++j) {
|
2015-12-03 22:01:07 -05:00
|
|
|
if ((*j)->ports_are_inputs() == inputs) {
|
|
|
|
program->add_bundle (*j);
|
|
|
|
}
|
2010-07-29 22:09:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-17 21:50:52 -04:00
|
|
|
/* virtual keyboard */
|
2019-10-18 09:17:54 -04:00
|
|
|
if (!inputs && (type == DataType::MIDI || type == DataType::NIL)) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<ARDOUR::Port> ap = std::dynamic_pointer_cast<ARDOUR::Port> (session->vkbd_output_port());
|
2019-10-17 21:50:52 -04:00
|
|
|
AudioEngine* ae = AudioEngine::instance();
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> vm (new Bundle (ap->pretty_name (), inputs));
|
2021-01-08 10:31:21 -05:00
|
|
|
vm->add_channel (ap->pretty_name (), DataType::MIDI, ae->make_port_name_non_relative (ap->name()));
|
2019-10-18 09:17:54 -04:00
|
|
|
program->add_bundle (vm);
|
2019-10-17 21:50:52 -04:00
|
|
|
}
|
|
|
|
|
2015-12-03 12:43:54 -05:00
|
|
|
/* our sync ports */
|
2010-08-01 06:26:19 -04:00
|
|
|
|
2013-08-07 22:22:11 -04:00
|
|
|
if ((type == DataType::MIDI || type == DataType::NIL)) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> sync (new Bundle (_("Sync"), inputs));
|
2013-08-07 22:22:11 -04:00
|
|
|
AudioEngine* ae = AudioEngine::instance();
|
2020-04-09 16:01:41 -04:00
|
|
|
TransportMasterManager::TransportMasters const & tm (TransportMasterManager::instance().transport_masters());
|
2012-10-12 05:45:22 -04:00
|
|
|
|
2010-08-01 06:26:19 -04:00
|
|
|
if (inputs) {
|
2020-04-09 16:01:41 -04:00
|
|
|
|
|
|
|
for (TransportMasterManager::TransportMasters::const_iterator i = tm.begin(); i != tm.end(); ++i) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Port> port = (*i)->port ();
|
2020-04-09 16:01:41 -04:00
|
|
|
if (!port) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
if (!std::dynamic_pointer_cast<MidiPort> (port)) {
|
2020-04-09 16:01:41 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sync->add_channel ((*i)->name(), DataType::MIDI, ae->make_port_name_non_relative (port->name()));
|
|
|
|
}
|
|
|
|
|
|
|
|
sync->add_channel (_("MMC in"), DataType::MIDI, ae->make_port_name_non_relative (session->mmc_input_port()->name()));
|
|
|
|
|
2010-08-01 06:26:19 -04:00
|
|
|
} else {
|
2020-04-09 16:01:41 -04:00
|
|
|
|
2010-08-01 06:26:19 -04:00
|
|
|
sync->add_channel (
|
2013-09-05 13:22:34 -04:00
|
|
|
_("MTC out"), DataType::MIDI, ae->make_port_name_non_relative (session->mtc_output_port()->name())
|
2010-08-01 06:26:19 -04:00
|
|
|
);
|
|
|
|
sync->add_channel (
|
2013-09-05 13:22:34 -04:00
|
|
|
_("MIDI clock out"), DataType::MIDI, ae->make_port_name_non_relative (session->midi_clock_output_port()->name())
|
2010-08-01 06:26:19 -04:00
|
|
|
);
|
|
|
|
sync->add_channel (
|
2013-09-05 13:22:34 -04:00
|
|
|
_("MMC out"), DataType::MIDI, ae->make_port_name_non_relative (session->mmc_output_port()->name())
|
2010-08-01 06:26:19 -04:00
|
|
|
);
|
|
|
|
}
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2015-12-03 12:43:54 -05:00
|
|
|
program->add_bundle (sync);
|
2010-08-01 06:26:19 -04:00
|
|
|
}
|
|
|
|
|
2022-10-15 22:03:21 -04:00
|
|
|
for (auto const& iop : *session->io_plugs ()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO> io = inputs ? iop->input() : iop->output();
|
2022-10-15 22:27:26 -04:00
|
|
|
if (io->n_ports().n_total () == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (type == DataType::NIL || io->n_ports().get (type) > 0) {
|
2022-10-20 19:22:27 -04:00
|
|
|
if (iop->is_pre ()) {
|
|
|
|
iop_pre->add_bundle (io->bundle(), io);
|
|
|
|
} else {
|
|
|
|
iop_post->add_bundle (io->bundle(), io);
|
|
|
|
}
|
2022-10-15 22:03:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-24 10:21:22 -05:00
|
|
|
/* Now find all other ports that we haven't thought of yet */
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2010-06-30 21:14:14 -04:00
|
|
|
std::vector<std::string> extra_system[DataType::num_types];
|
2015-12-03 12:43:54 -05:00
|
|
|
std::vector<std::string> extra_program[DataType::num_types];
|
2010-06-30 21:14:14 -04:00
|
|
|
std::vector<std::string> extra_other[DataType::num_types];
|
2009-02-08 22:18:10 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
string lpn (PROGRAM_NAME);
|
|
|
|
boost::to_lower (lpn);
|
|
|
|
string lpnc = lpn;
|
|
|
|
lpnc += ':';
|
2010-12-10 11:31:14 -05:00
|
|
|
|
2013-07-31 19:55:44 -04:00
|
|
|
vector<string> ports;
|
2016-04-27 20:52:05 -04:00
|
|
|
if (type == DataType::NIL) {
|
|
|
|
vector<string> p1;
|
|
|
|
AudioEngine::instance()->get_ports ("", DataType::AUDIO, inputs ? IsInput : IsOutput, ports);
|
|
|
|
AudioEngine::instance()->get_ports ("", DataType::MIDI, inputs ? IsInput : IsOutput, p1);
|
|
|
|
for (vector<string>::const_iterator s = p1.begin(); s != p1.end(); ++s) {
|
|
|
|
ports.push_back (*s);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
AudioEngine::instance()->get_ports ("", type, inputs ? IsInput : IsOutput, ports);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ports.size () > 0) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2022-07-25 19:58:11 -04:00
|
|
|
struct SortByPortName {
|
|
|
|
bool operator() (std::string const& lhs, std::string const& rhs) const {
|
|
|
|
return PBD::naturally_less (lhs.c_str (), rhs.c_str ());
|
|
|
|
}
|
|
|
|
} port_sorter;
|
|
|
|
|
|
|
|
std::sort (ports.begin (), ports.end (), port_sorter);
|
|
|
|
|
2021-06-24 11:20:28 -04:00
|
|
|
for (vector<string>::const_iterator s = ports.begin(); s != ports.end(); ++s) {
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2013-07-31 19:55:44 -04:00
|
|
|
std::string const p = *s;
|
2009-01-13 06:13:59 -05:00
|
|
|
|
2021-02-26 13:14:57 -05:00
|
|
|
if (allow_dups || (
|
|
|
|
!system->has_port(p)
|
|
|
|
&& !bus->has_port(p)
|
|
|
|
&& !track->has_port(p)
|
2022-10-20 19:22:27 -04:00
|
|
|
&& !iop_pre->has_port(p)
|
|
|
|
&& !iop_post->has_port(p)
|
2021-02-26 13:14:57 -05:00
|
|
|
&& !sidechain->has_port(p)
|
|
|
|
&& !program->has_port(p)
|
|
|
|
&& !other->has_port(p)
|
|
|
|
)
|
|
|
|
) {
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* special hack: ignore MIDI ports labelled Midi-Through. these
|
|
|
|
are basically useless and mess things up for default
|
|
|
|
connections.
|
|
|
|
*/
|
2010-06-26 09:45:59 -04:00
|
|
|
|
2016-07-08 17:10:08 -04:00
|
|
|
if (p.find ("Midi-Through") != string::npos || p.find ("Midi Through") != string::npos) {
|
2017-07-01 12:42:24 -04:00
|
|
|
continue;
|
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
/* special hack: ignore our monitor inputs (which show up here because
|
|
|
|
we excluded them earlier.
|
|
|
|
*/
|
2011-06-01 13:00:29 -04:00
|
|
|
|
2016-10-21 16:31:16 -04:00
|
|
|
string lp = p;
|
|
|
|
string monitor = _("Monitor");
|
|
|
|
|
|
|
|
boost::to_lower (lp);
|
2017-07-01 12:42:24 -04:00
|
|
|
boost::to_lower (monitor);
|
2010-12-10 11:31:14 -05:00
|
|
|
|
2017-07-01 12:42:24 -04:00
|
|
|
if ((lp.find (monitor) != string::npos) &&
|
|
|
|
(lp.find (lpn) != string::npos)) {
|
|
|
|
continue;
|
|
|
|
}
|
2010-12-10 11:31:14 -05:00
|
|
|
|
2015-12-03 12:43:54 -05:00
|
|
|
/* can't use the audio engine for this as we
|
|
|
|
* are looking at ports not owned by the
|
|
|
|
* application, and the audio engine/port
|
|
|
|
* manager doesn't seem them.
|
|
|
|
*/
|
2010-06-30 21:14:14 -04:00
|
|
|
|
2013-07-30 23:26:46 -04:00
|
|
|
PortEngine::PortHandle ph = AudioEngine::instance()->port_engine().get_port_by_name (p);
|
2016-07-08 17:10:08 -04:00
|
|
|
|
2016-10-21 16:31:16 -04:00
|
|
|
if (!ph) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
DataType t (AudioEngine::instance()->port_engine().port_data_type (ph));
|
|
|
|
|
|
|
|
if (t != DataType::NIL) {
|
|
|
|
|
2018-10-17 14:11:32 -04:00
|
|
|
PortFlags flags (AudioEngine::instance()->port_engine().get_port_flags (ph));
|
2016-10-21 16:31:16 -04:00
|
|
|
|
2021-02-01 17:48:51 -05:00
|
|
|
if (flags & Hidden ) {
|
|
|
|
continue;
|
|
|
|
} else if (port_has_prefix (p, lpnc)) {
|
2016-10-21 16:31:16 -04:00
|
|
|
|
|
|
|
/* we own this port (named after the program) */
|
|
|
|
|
2019-09-25 15:02:31 -04:00
|
|
|
/* Hide scene ports for now */
|
|
|
|
if (p.find (_("Scene ")) != string::npos) {
|
|
|
|
continue;
|
2010-06-30 21:14:14 -04:00
|
|
|
}
|
2016-10-21 16:31:16 -04:00
|
|
|
|
|
|
|
extra_program[t].push_back (p);
|
2018-10-17 14:11:32 -04:00
|
|
|
|
|
|
|
} else if (flags & IsPhysical) {
|
|
|
|
|
|
|
|
extra_system[t].push_back (p);
|
|
|
|
|
2016-10-21 16:31:16 -04:00
|
|
|
} else {
|
|
|
|
extra_other[t].push_back (p);
|
2010-06-30 21:14:14 -04:00
|
|
|
}
|
2009-01-13 06:13:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-30 21:14:14 -04:00
|
|
|
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
|
|
|
|
if (!extra_system[*i].empty()) {
|
2022-12-28 22:00:28 -05:00
|
|
|
add_bundles_for_ports (extra_system[*i], *i, inputs, allow_dups, system);
|
2010-06-30 21:14:14 -04:00
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
}
|
|
|
|
|
2015-12-03 11:49:18 -05:00
|
|
|
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
|
2015-12-03 12:43:54 -05:00
|
|
|
if (!extra_program[*i].empty()) {
|
2016-07-08 17:10:08 -04:00
|
|
|
/* used program name as bundle name */
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> b = make_bundle_from_ports (extra_program[*i], *i, inputs, lpn);
|
2015-12-03 12:43:54 -05:00
|
|
|
program->add_bundle (b);
|
2015-12-03 11:49:18 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-30 21:14:14 -04:00
|
|
|
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
|
2013-08-02 20:46:08 -04:00
|
|
|
if (extra_other[*i].empty()) continue;
|
2022-12-28 22:00:28 -05:00
|
|
|
add_bundles_for_ports (extra_other[*i], *i, inputs, allow_dups, other);
|
2009-02-08 22:18:10 -05:00
|
|
|
}
|
|
|
|
|
2009-12-21 20:10:25 -05:00
|
|
|
if (!allow_dups) {
|
|
|
|
system->remove_duplicates ();
|
|
|
|
}
|
|
|
|
|
2016-07-18 18:01:12 -04:00
|
|
|
add_group_if_not_empty (bus);
|
2009-11-18 08:35:31 -05:00
|
|
|
add_group_if_not_empty (track);
|
2018-10-26 21:28:52 -04:00
|
|
|
add_group_if_not_empty (sidechain);
|
2022-10-20 19:22:27 -04:00
|
|
|
add_group_if_not_empty (iop_pre);
|
|
|
|
add_group_if_not_empty (iop_post);
|
2015-12-03 12:43:54 -05:00
|
|
|
add_group_if_not_empty (program);
|
2022-10-20 19:33:04 -04:00
|
|
|
add_group_if_not_empty (other);
|
2010-01-05 13:40:50 -05:00
|
|
|
add_group_if_not_empty (system);
|
2009-01-26 23:21:13 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
emit_changed ();
|
|
|
|
}
|
|
|
|
|
2022-12-28 22:00:28 -05:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroupList::add_bundles_for_ports (std::vector<std::string> const & p, ARDOUR::DataType type, bool inputs, bool allow_dups, std::shared_ptr<PortGroup> group) const
|
2022-12-28 22:00:28 -05:00
|
|
|
{
|
|
|
|
bool has_colon = true, has_slash = true;
|
|
|
|
for (const auto& s : p) {
|
|
|
|
if (s.find('/') == std::string::npos) has_slash = false;
|
|
|
|
if (s.find(':') == std::string::npos) has_colon = false;
|
|
|
|
}
|
|
|
|
std::string sep = has_slash ? "/" : has_colon ? ":" : "";
|
|
|
|
if (sep.empty()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> b = make_bundle_from_ports (p, type, inputs);
|
2022-12-28 22:00:28 -05:00
|
|
|
group->add_bundle (b, allow_dups);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> nb;
|
|
|
|
std::string cp;
|
|
|
|
for (const auto& s : p) {
|
|
|
|
std::string pf = s.substr (0, s.find_first_of (sep) + 1);
|
|
|
|
if (pf != cp && !nb.empty()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> b = make_bundle_from_ports (nb, type, inputs);
|
2022-12-28 22:00:28 -05:00
|
|
|
group->add_bundle (b, allow_dups);
|
|
|
|
nb.clear();
|
|
|
|
}
|
|
|
|
cp = pf;
|
|
|
|
nb.push_back(s);
|
|
|
|
}
|
|
|
|
if (!nb.empty()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> b = make_bundle_from_ports (nb, type, inputs);
|
2022-12-28 22:00:28 -05:00
|
|
|
group->add_bundle (b, allow_dups);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle>
|
2015-12-03 12:43:54 -05:00
|
|
|
PortGroupList::make_bundle_from_ports (std::vector<std::string> const & p, ARDOUR::DataType type, bool inputs, std::string const& bundle_name) const
|
2009-02-08 22:18:10 -05:00
|
|
|
{
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<Bundle> b (new Bundle ("", inputs));
|
2009-02-08 22:18:10 -05:00
|
|
|
std::string const pre = common_prefix (p);
|
2015-12-03 12:43:54 -05:00
|
|
|
|
|
|
|
if (!bundle_name.empty()) {
|
|
|
|
b->set_name (bundle_name);
|
|
|
|
} else {
|
|
|
|
if (!pre.empty()) {
|
|
|
|
b->set_name (pre.substr (0, pre.length() - 1));
|
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
for (uint32_t j = 0; j < p.size(); ++j) {
|
2015-03-08 12:27:48 -04:00
|
|
|
std::string n = p[j].substr (pre.length());
|
|
|
|
std::string pn = AudioEngine::instance()->get_pretty_name_by_name (p[j]);
|
|
|
|
if (!pn.empty()) {
|
|
|
|
n = pn;
|
|
|
|
}
|
|
|
|
b->add_channel (n, type);
|
2009-02-08 22:18:10 -05:00
|
|
|
b->set_port (j, p[j]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return b;
|
2009-01-13 06:13:59 -05:00
|
|
|
}
|
|
|
|
|
2009-01-24 10:21:22 -05:00
|
|
|
bool
|
|
|
|
PortGroupList::port_has_prefix (const std::string& n, const std::string& p) const
|
|
|
|
{
|
|
|
|
return n.substr (0, p.length()) == p;
|
|
|
|
}
|
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
std::string
|
|
|
|
PortGroupList::common_prefix_before (std::vector<std::string> const & p, std::string const & s) const
|
2009-01-20 09:46:00 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
/* we must have some strings and the first must contain the separator string */
|
|
|
|
if (p.empty() || p[0].find_first_of (s) == std::string::npos) {
|
|
|
|
return "";
|
|
|
|
}
|
2009-01-23 16:24:11 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
/* prefix of the first string */
|
|
|
|
std::string const fp = p[0].substr (0, p[0].find_first_of (s) + 1);
|
2009-01-23 16:24:11 -05:00
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
/* see if the other strings also start with fp */
|
|
|
|
uint32_t j = 1;
|
|
|
|
while (j < p.size()) {
|
|
|
|
if (p[j].substr (0, fp.length()) != fp) {
|
|
|
|
break;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
++j;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (j != p.size()) {
|
|
|
|
return "";
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
return fp;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-23 16:24:11 -05:00
|
|
|
|
|
|
|
std::string
|
|
|
|
PortGroupList::common_prefix (std::vector<std::string> const & p) const
|
|
|
|
{
|
|
|
|
/* common prefix before '/' ? */
|
2009-02-08 22:18:10 -05:00
|
|
|
std::string cp = common_prefix_before (p, "/");
|
|
|
|
if (!cp.empty()) {
|
|
|
|
return cp;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
|
|
|
|
cp = common_prefix_before (p, ":");
|
|
|
|
if (!cp.empty()) {
|
|
|
|
return cp;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-01-30 10:08:09 -05:00
|
|
|
PortGroupList::clear ()
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-01-30 10:08:09 -05:00
|
|
|
_groups.clear ();
|
2009-12-17 13:24:23 -05:00
|
|
|
_bundle_changed_connections.drop_connections ();
|
2009-02-08 22:18:10 -05:00
|
|
|
emit_changed ();
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
|
2009-07-17 09:18:58 -04:00
|
|
|
PortGroup::BundleList const &
|
2009-01-30 10:08:09 -05:00
|
|
|
PortGroupList::bundles () const
|
2009-01-23 16:24:11 -05:00
|
|
|
{
|
2009-07-17 10:35:22 -04:00
|
|
|
_bundles.clear ();
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-07-17 10:35:22 -04:00
|
|
|
for (PortGroupList::List::const_iterator i = begin (); i != end (); ++i) {
|
2009-07-18 09:10:08 -04:00
|
|
|
std::copy ((*i)->bundles().begin(), (*i)->bundles().end(), std::back_inserter (_bundles));
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
return _bundles;
|
2009-01-23 16:24:11 -05:00
|
|
|
}
|
2009-01-25 01:47:11 -05:00
|
|
|
|
2010-06-29 22:59:13 -04:00
|
|
|
ChanCount
|
2009-11-18 08:35:31 -05:00
|
|
|
PortGroupList::total_channels () const
|
2009-01-25 01:47:11 -05:00
|
|
|
{
|
2010-06-29 22:59:13 -04:00
|
|
|
ChanCount n;
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
for (PortGroupList::List::const_iterator i = begin(); i != end(); ++i) {
|
2009-11-18 08:35:31 -05:00
|
|
|
n += (*i)->total_channels ();
|
2009-01-25 01:47:11 -05:00
|
|
|
}
|
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
return n;
|
2009-01-26 23:21:13 -05:00
|
|
|
}
|
|
|
|
|
2009-11-18 08:35:31 -05:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroupList::add_group_if_not_empty (std::shared_ptr<PortGroup> g)
|
2009-11-18 08:35:31 -05:00
|
|
|
{
|
|
|
|
if (!g->bundles().empty ()) {
|
|
|
|
add_group (g);
|
|
|
|
}
|
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroupList::add_group (std::shared_ptr<PortGroup> g)
|
2009-01-26 23:21:13 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
_groups.push_back (g);
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2010-03-30 11:18:43 -04:00
|
|
|
g->Changed.connect (_changed_connections, invalidator (*this), boost::bind (&PortGroupList::emit_changed, this), gui_context());
|
2012-04-25 08:58:19 -04:00
|
|
|
g->BundleChanged.connect (_bundle_changed_connections, invalidator (*this), boost::bind (&PortGroupList::emit_bundle_changed, this, _1), gui_context());
|
2009-02-08 22:18:10 -05:00
|
|
|
|
|
|
|
emit_changed ();
|
2009-01-30 10:08:09 -05:00
|
|
|
}
|
2009-01-26 23:21:13 -05:00
|
|
|
|
2009-01-30 10:08:09 -05:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
PortGroupList::remove_bundle (std::shared_ptr<Bundle> b)
|
2009-01-30 10:08:09 -05:00
|
|
|
{
|
2009-02-08 22:18:10 -05:00
|
|
|
for (List::iterator i = _groups.begin(); i != _groups.end(); ++i) {
|
|
|
|
(*i)->remove_bundle (b);
|
|
|
|
}
|
|
|
|
|
|
|
|
emit_changed ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortGroupList::emit_changed ()
|
|
|
|
{
|
|
|
|
if (_signals_suspended) {
|
|
|
|
_pending_change = true;
|
|
|
|
} else {
|
|
|
|
Changed ();
|
|
|
|
}
|
2009-01-25 01:47:11 -05:00
|
|
|
}
|
2009-10-14 12:10:01 -04:00
|
|
|
|
2009-11-07 15:33:41 -05:00
|
|
|
void
|
|
|
|
PortGroupList::emit_bundle_changed (Bundle::Change c)
|
|
|
|
{
|
|
|
|
if (_signals_suspended) {
|
|
|
|
_pending_bundle_change = c;
|
|
|
|
} else {
|
|
|
|
BundleChanged (c);
|
|
|
|
}
|
|
|
|
}
|
2009-02-08 22:18:10 -05:00
|
|
|
void
|
|
|
|
PortGroupList::suspend_signals ()
|
|
|
|
{
|
|
|
|
_signals_suspended = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortGroupList::resume_signals ()
|
|
|
|
{
|
|
|
|
if (_pending_change) {
|
|
|
|
Changed ();
|
|
|
|
_pending_change = false;
|
|
|
|
}
|
|
|
|
|
2009-11-07 15:33:41 -05:00
|
|
|
if (_pending_bundle_change != 0) {
|
|
|
|
BundleChanged (_pending_bundle_change);
|
|
|
|
_pending_bundle_change = (ARDOUR::Bundle::Change) 0;
|
|
|
|
}
|
|
|
|
|
2009-02-08 22:18:10 -05:00
|
|
|
_signals_suspended = false;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO>
|
|
|
|
PortGroupList::io_from_bundle (std::shared_ptr<ARDOUR::Bundle> b) const
|
2009-07-19 20:22:09 -04:00
|
|
|
{
|
|
|
|
List::const_iterator i = _groups.begin ();
|
|
|
|
while (i != _groups.end()) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::shared_ptr<IO> io = (*i)->io_from_bundle (b);
|
2009-07-19 20:22:09 -04:00
|
|
|
if (io) {
|
|
|
|
return io;
|
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2023-02-16 18:33:28 -05:00
|
|
|
return std::shared_ptr<IO> ();
|
2009-07-19 20:22:09 -04:00
|
|
|
}
|
|
|
|
|
2009-11-14 19:26:28 -05:00
|
|
|
bool
|
|
|
|
PortGroupList::empty () const
|
|
|
|
{
|
2011-08-13 16:19:39 -04:00
|
|
|
return _groups.empty ();
|
2009-11-14 19:26:28 -05:00
|
|
|
}
|