X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Finstrument_selector.cc;h=8cb1890af57ede9aa77992d8db86f59234c356c9;hb=3dcb7bf3d3f4eca512c799b5f63fd412e5e3e233;hp=d4f89e2f63ec7fb125e198f4745d4d55d737969c;hpb=25f65d0b9009adc409972ee4b2591c611e8a48ec;p=ardour.git diff --git a/gtk2_ardour/instrument_selector.cc b/gtk2_ardour/instrument_selector.cc index d4f89e2f63..8cb1890af5 100644 --- a/gtk2_ardour/instrument_selector.cc +++ b/gtk2_ardour/instrument_selector.cc @@ -16,17 +16,20 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include "pbd/convert.h" +#include "pbd/enumwriter.h" #include "ardour/plugin_manager.h" #include "gtkmm2ext/gui_thread.h" #include "instrument_selector.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace Gtk; using namespace ARDOUR; InstrumentSelector::InstrumentSelector() : _reasonable_synth_id(0) + , _gmsynth_id(UINT32_MAX) { refill (); @@ -49,7 +52,11 @@ InstrumentSelector::refill() set_model(_instrument_list); pack_start(_instrument_list_columns.name); if (selected.empty ()) { - set_active(_reasonable_synth_id); + if (_gmsynth_id != UINT32_MAX) { + set_active(_gmsynth_id); + } else { + set_active(_reasonable_synth_id); + } } else { TreeModel::Children rows = _instrument_list->children(); TreeModel::Children::iterator i; @@ -64,6 +71,21 @@ InstrumentSelector::refill() set_button_sensitivity(Gtk::SENSITIVITY_AUTO); } +static bool +pluginsort (const PluginInfoPtr& a, const PluginInfoPtr& b) +{ + return PBD::downcase(a->name) < PBD::downcase(b->name); +} + +static bool +invalid_instrument (PluginInfoPtr p) { + const PluginManager& manager = PluginManager::instance(); + if (manager.get_status(p) == PluginManager::Hidden) { + return true; + } + return !p->is_instrument(); +} + void InstrumentSelector::build_instrument_list() { @@ -78,6 +100,9 @@ InstrumentSelector::build_instrument_list() #ifdef LXVST_SUPPORT all_plugs.insert(all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end()); #endif +#ifdef MACVST_SUPPORT + all_plugs.insert(all_plugs.end(), manager.mac_vst_plugin_info().begin(), manager.mac_vst_plugin_info().end()); +#endif #ifdef AUDIOUNIT_SUPPORT all_plugs.insert(all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end()); #endif @@ -85,6 +110,9 @@ InstrumentSelector::build_instrument_list() all_plugs.insert(all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end()); #endif + all_plugs.remove_if (invalid_instrument); + all_plugs.sort (pluginsort); + _instrument_list = ListStore::create(_instrument_list_columns); TreeModel::Row row = *(_instrument_list->append()); @@ -92,20 +120,43 @@ InstrumentSelector::build_instrument_list() row[_instrument_list_columns.name] = _("-none-"); uint32_t n = 1; - for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) { - if (manager.get_status(*i) == PluginManager::Hidden) { - continue; + std::string prev; + for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end();) { + PluginInfoPtr p = *i; + ++i; + bool suffix_type = prev == p->name; + if (!suffix_type && i != all_plugs.end() && (*i)->name == p->name) { + suffix_type = true; } - if ((*i)->is_instrument()) { - row = *(_instrument_list->append()); - row[_instrument_list_columns.name] = (*i)->name; - row[_instrument_list_columns.info_ptr] = *i; - if ((*i)->unique_id == "https://community.ardour.org/node/7596") { - _reasonable_synth_id = n; + row = *(_instrument_list->append()); + if (suffix_type) { + std::string pt; + switch (p->type) { + case AudioUnit: + pt = "AU"; + break; + case Windows_VST: + case LXVST: + case MacVST: + pt = "VST"; + break; + default: + pt = enum_2_string (p->type); } - n++; + row[_instrument_list_columns.name] = p->name + " (" + pt + ")"; + } else { + row[_instrument_list_columns.name] = p->name; + } + row[_instrument_list_columns.info_ptr] = p; + if (p->unique_id == "https://community.ardour.org/node/7596") { + _reasonable_synth_id = n; + } + if (p->unique_id == "http://gareus.org/oss/lv2/gmsynth") { + _gmsynth_id = n; } + prev = p->name; + n++; } }