From 4e1464e70fc73b4b962c0cad02e301832b9901f6 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 22 Oct 2018 15:43:46 +0200 Subject: [PATCH] Sort VST factory presets This is more of a workaround than a fix. Simply by forcing the URI to be sortable (VST-user presets are sorted at the end). This eventually needs a deeper cleanup and API consolidation PluginInfo::get_presets(bool) returns an ordered std::vector. However this API is only used in a few cases where the plugin is not instantiated. PluginInfo::get_presets(bool). The problem is Plugin::get_presets(). The method returns information that was previously cached by Plugin::find_presets() in std::map --- libs/ardour/lxvst_plugin.cc | 4 ++-- libs/ardour/mac_vst_plugin.cc | 2 +- libs/ardour/vst_plugin.cc | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/ardour/lxvst_plugin.cc b/libs/ardour/lxvst_plugin.cc index 62fff3f8b8..8bfd5d61d3 100644 --- a/libs/ardour/lxvst_plugin.cc +++ b/libs/ardour/lxvst_plugin.cc @@ -125,11 +125,11 @@ LXVSTPluginInfo::get_presets (bool user_only) const int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0); for (int i = 0; i < plugin->numPrograms; ++i) { - Plugin::PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id, i), "", false); + Plugin::PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id, std::setw(4), std::setfill('0'), i), "", false); if (vst_version >= 2) { char buf[256]; if (plugin->dispatcher (plugin, 29, i, 0, buf, 0) == 1) { - r.label = buf; + r.label = string_compose (_("%1 - %2"), i, buf); } else { r.label = string_compose (_("Preset %1"), i); } diff --git a/libs/ardour/mac_vst_plugin.cc b/libs/ardour/mac_vst_plugin.cc index 0b52096e6a..240da414a0 100644 --- a/libs/ardour/mac_vst_plugin.cc +++ b/libs/ardour/mac_vst_plugin.cc @@ -132,7 +132,7 @@ MacVSTPluginInfo::get_presets (bool user_only) const int const vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0); for (int i = 0; i < plugin->numPrograms; ++i) { - Plugin::PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id, i), "", false); + Plugin::PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id, std::setw(4), std::setfill('0'), i), "", false); if (vst_version >= 2) { char buf[256]; if (plugin->dispatcher (plugin, 29, i, 0, buf, 0) == 1) { diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc index 6a29d9d5df..a85c9ca678 100644 --- a/libs/ardour/vst_plugin.cc +++ b/libs/ardour/vst_plugin.cc @@ -840,7 +840,8 @@ VSTPlugin::find_presets () int const vst_version = _plugin->dispatcher (_plugin, effGetVstVersion, 0, 0, NULL, 0); for (int i = 0; i < _plugin->numPrograms; ++i) { - PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), i), "", false); + + PresetRecord r (string_compose (X_("VST:%1:%2"), unique_id (), std::setw(4), std::setfill('0'), i), "", false); if (vst_version >= 2) { char buf[256];