2014-12-24 18:39:15 -05:00
|
|
|
/*
|
2019-08-02 17:26:43 -04:00
|
|
|
* Copyright (C) 2016-2018 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
2014-12-24 18:39:15 -05:00
|
|
|
|
2016-10-06 07:57:58 -04:00
|
|
|
#include "pbd/convert.h"
|
2016-11-13 19:14:52 -05:00
|
|
|
#include "pbd/enumwriter.h"
|
2019-10-15 09:30:33 -04:00
|
|
|
|
2014-12-24 18:39:15 -05:00
|
|
|
#include "ardour/plugin_manager.h"
|
2016-04-18 13:15:53 -04:00
|
|
|
#include "gtkmm2ext/gui_thread.h"
|
2019-10-15 09:30:33 -04:00
|
|
|
|
2014-12-24 18:39:15 -05:00
|
|
|
#include "instrument_selector.h"
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2014-12-24 18:39:15 -05:00
|
|
|
|
|
|
|
using namespace Gtk;
|
|
|
|
using namespace ARDOUR;
|
|
|
|
|
2021-04-16 16:25:41 -04:00
|
|
|
InstrumentSelector::InstrumentSelector (bool allow_none)
|
|
|
|
: _reasonable_synth_id (0)
|
|
|
|
, _gmsynth_id (UINT32_MAX)
|
|
|
|
, _allow_none (allow_none)
|
2014-12-24 18:39:15 -05:00
|
|
|
{
|
2016-04-18 13:15:53 -04:00
|
|
|
refill ();
|
|
|
|
|
|
|
|
PluginManager::instance ().PluginListChanged.connect (_update_connection, invalidator (*this), boost::bind (&InstrumentSelector::refill, this), gui_context());
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
InstrumentSelector::refill()
|
|
|
|
{
|
|
|
|
TreeModel::iterator iter = get_active();
|
|
|
|
std::string selected;
|
|
|
|
if (iter) {
|
|
|
|
const TreeModel::Row& row = (*iter);
|
|
|
|
selected = row[_instrument_list_columns.name];
|
|
|
|
}
|
|
|
|
|
|
|
|
unset_model ();
|
|
|
|
clear ();
|
2014-12-24 18:39:15 -05:00
|
|
|
build_instrument_list();
|
|
|
|
set_model(_instrument_list);
|
|
|
|
pack_start(_instrument_list_columns.name);
|
2016-04-18 13:15:53 -04:00
|
|
|
if (selected.empty ()) {
|
2017-01-30 10:42:11 -05:00
|
|
|
if (_gmsynth_id != UINT32_MAX) {
|
|
|
|
set_active(_gmsynth_id);
|
|
|
|
} else {
|
|
|
|
set_active(_reasonable_synth_id);
|
|
|
|
}
|
2016-04-18 13:15:53 -04:00
|
|
|
} else {
|
|
|
|
TreeModel::Children rows = _instrument_list->children();
|
|
|
|
TreeModel::Children::iterator i;
|
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
|
|
|
std::string cn = (*i)[_instrument_list_columns.name];
|
|
|
|
if (cn == selected) {
|
|
|
|
set_active(*i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-24 18:39:15 -05:00
|
|
|
set_button_sensitivity(Gtk::SENSITIVITY_AUTO);
|
|
|
|
}
|
|
|
|
|
2016-10-06 07:57:58 -04:00
|
|
|
static bool
|
|
|
|
pluginsort (const PluginInfoPtr& a, const PluginInfoPtr& b)
|
|
|
|
{
|
|
|
|
return PBD::downcase(a->name) < PBD::downcase(b->name);
|
|
|
|
}
|
|
|
|
|
2016-11-13 19:14:52 -05:00
|
|
|
static bool
|
|
|
|
invalid_instrument (PluginInfoPtr p) {
|
|
|
|
const PluginManager& manager = PluginManager::instance();
|
|
|
|
if (manager.get_status(p) == PluginManager::Hidden) {
|
|
|
|
return true;
|
|
|
|
}
|
2020-09-28 16:35:15 -04:00
|
|
|
if (manager.get_status(p) == PluginManager::Concealed) {
|
|
|
|
return true;
|
|
|
|
}
|
2016-11-13 19:14:52 -05:00
|
|
|
return !p->is_instrument();
|
|
|
|
}
|
|
|
|
|
2014-12-24 18:39:15 -05:00
|
|
|
void
|
|
|
|
InstrumentSelector::build_instrument_list()
|
|
|
|
{
|
|
|
|
PluginManager& manager = PluginManager::instance();
|
|
|
|
|
|
|
|
PluginInfoList all_plugs;
|
|
|
|
all_plugs.insert(all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
|
2016-04-28 19:26:46 -04:00
|
|
|
all_plugs.insert(all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
|
2020-09-15 11:01:49 -04:00
|
|
|
all_plugs.insert(all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
|
2014-12-24 18:39:15 -05:00
|
|
|
#ifdef WINDOWS_VST_SUPPORT
|
|
|
|
all_plugs.insert(all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
|
|
|
|
#endif
|
|
|
|
#ifdef LXVST_SUPPORT
|
|
|
|
all_plugs.insert(all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end());
|
|
|
|
#endif
|
2016-11-13 10:32:30 -05:00
|
|
|
#ifdef MACVST_SUPPORT
|
|
|
|
all_plugs.insert(all_plugs.end(), manager.mac_vst_plugin_info().begin(), manager.mac_vst_plugin_info().end());
|
|
|
|
#endif
|
2014-12-24 18:39:15 -05:00
|
|
|
#ifdef AUDIOUNIT_SUPPORT
|
|
|
|
all_plugs.insert(all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end());
|
|
|
|
#endif
|
2019-11-02 23:11:27 -04:00
|
|
|
#ifdef VST3_SUPPORT
|
|
|
|
all_plugs.insert(all_plugs.end(), manager.vst3_plugin_info().begin(), manager.vst3_plugin_info().end());
|
|
|
|
#endif
|
2014-12-24 18:39:15 -05:00
|
|
|
|
2016-11-13 19:14:52 -05:00
|
|
|
all_plugs.remove_if (invalid_instrument);
|
2016-10-06 07:57:58 -04:00
|
|
|
all_plugs.sort (pluginsort);
|
|
|
|
|
2014-12-24 18:39:15 -05:00
|
|
|
_instrument_list = ListStore::create(_instrument_list_columns);
|
|
|
|
|
2021-04-16 16:25:41 -04:00
|
|
|
if (_allow_none) {
|
|
|
|
TreeModel::Row row = *(_instrument_list->append());
|
|
|
|
row[_instrument_list_columns.info_ptr] = PluginInfoPtr();
|
|
|
|
row[_instrument_list_columns.name] = _("-none-");
|
|
|
|
}
|
2014-12-24 18:39:15 -05:00
|
|
|
|
2021-04-16 16:25:41 -04:00
|
|
|
uint32_t n = _allow_none ? 1 : 0;
|
2016-11-13 19:14:52 -05:00
|
|
|
std::string prev;
|
2019-10-15 08:09:02 -04:00
|
|
|
for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i, ++n) {
|
2016-11-13 19:14:52 -05:00
|
|
|
PluginInfoPtr p = *i;
|
2019-10-13 14:26:44 -04:00
|
|
|
|
2019-10-15 08:09:02 -04:00
|
|
|
std::string suffix;
|
|
|
|
|
|
|
|
#ifdef MIXBUS
|
2019-10-15 08:52:40 -04:00
|
|
|
uint32_t n_outs = p->max_configurable_ouputs ();
|
2019-10-13 14:26:44 -04:00
|
|
|
if (n_outs > 2) {
|
2019-10-15 09:29:18 -04:00
|
|
|
if (p->reconfigurable_io ()) {
|
|
|
|
suffix = string_compose(_("\u2264 %1 outs"), n_outs);
|
|
|
|
} else {
|
|
|
|
suffix = string_compose(_("%1 outs"), n_outs);
|
|
|
|
}
|
2019-10-13 14:26:44 -04:00
|
|
|
}
|
2019-10-15 08:09:02 -04:00
|
|
|
#else
|
|
|
|
if (p->multichannel_name_ambiguity) {
|
2019-10-15 08:52:40 -04:00
|
|
|
uint32_t n_outs = p->max_configurable_ouputs ();
|
2019-10-15 08:09:02 -04:00
|
|
|
if (n_outs > 2) {
|
2019-10-15 09:29:18 -04:00
|
|
|
if (p->reconfigurable_io ()) {
|
|
|
|
suffix = string_compose(_("\u2264 %1 outs"), n_outs);
|
|
|
|
} else {
|
|
|
|
suffix = string_compose(_("%1 outs"), n_outs);
|
|
|
|
}
|
2019-10-15 08:09:02 -04:00
|
|
|
} else if (n_outs == 2) {
|
|
|
|
suffix = _("stereo");
|
|
|
|
}
|
2014-12-24 18:39:15 -05:00
|
|
|
}
|
2019-10-15 08:09:02 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
if (p->plugintype_name_ambiguity) {
|
2020-09-15 09:57:53 -04:00
|
|
|
std::string pt = PluginManager::plugin_type_name (p->type);
|
2019-10-15 08:09:02 -04:00
|
|
|
if (!suffix.empty ()) {
|
|
|
|
suffix += ", ";
|
|
|
|
}
|
|
|
|
suffix += pt;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string name = p->name;
|
|
|
|
if (!suffix.empty ()) {
|
|
|
|
name += " (" + suffix + ")";
|
2016-11-13 19:14:52 -05:00
|
|
|
}
|
2019-10-13 14:26:44 -04:00
|
|
|
|
2021-04-16 16:25:41 -04:00
|
|
|
TreeModel::Row row = *(_instrument_list->append());
|
2019-10-13 14:26:44 -04:00
|
|
|
row[_instrument_list_columns.name] = name;
|
|
|
|
|
2016-11-13 19:14:52 -05:00
|
|
|
row[_instrument_list_columns.info_ptr] = p;
|
|
|
|
if (p->unique_id == "https://community.ardour.org/node/7596") {
|
|
|
|
_reasonable_synth_id = n;
|
2014-12-24 18:39:15 -05:00
|
|
|
}
|
2017-01-30 10:42:11 -05:00
|
|
|
if (p->unique_id == "http://gareus.org/oss/lv2/gmsynth") {
|
2018-12-08 11:04:32 -05:00
|
|
|
_gmsynth_id = n;
|
2017-01-30 10:42:11 -05:00
|
|
|
}
|
2016-11-13 19:14:52 -05:00
|
|
|
prev = p->name;
|
2014-12-24 18:39:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginInfoPtr
|
2020-09-17 15:05:41 -04:00
|
|
|
InstrumentSelector::selected_instrument() const
|
2014-12-24 18:39:15 -05:00
|
|
|
{
|
|
|
|
TreeModel::iterator iter = get_active();
|
|
|
|
if (!iter) {
|
|
|
|
return PluginInfoPtr();
|
|
|
|
}
|
|
|
|
|
|
|
|
const TreeModel::Row& row = (*iter);
|
|
|
|
return row[_instrument_list_columns.info_ptr];
|
|
|
|
}
|
2020-09-17 15:05:41 -04:00
|
|
|
|
|
|
|
std::string
|
|
|
|
InstrumentSelector::selected_instrument_name () const
|
|
|
|
{
|
|
|
|
PluginInfoPtr pip = selected_instrument ();
|
|
|
|
if (!pip) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return pip->name;
|
|
|
|
}
|