Add API to format plugin-type

This commit is contained in:
Robin Gareus 2020-09-15 15:49:22 +02:00
parent 68b23b9f82
commit d72423fdc8
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 36 additions and 1 deletions

View File

@ -69,7 +69,12 @@ public:
const std::string get_default_lxvst_path() const { return lxvst_path; }
/* always return LXVST for any VST subtype */
static PluginType to_generic_vst (PluginType);
static PluginType to_generic_vst (const PluginType);
/* format plugin type to human readable name
* @param short use at most 4 chars (useful for ctrl-surface displays)
*/
static std::string plugin_type_name (const PluginType, bool short_name = true);
bool cancelled () { return _cancel_scan; }
bool no_timeout () { return _cancel_timeout; }

View File

@ -73,6 +73,7 @@
#include "ardour/playlist.h"
#include "ardour/plugin.h"
#include "ardour/plugin_insert.h"
#include "ardour/plugin_manager.h"
#include "ardour/polarity_processor.h"
#include "ardour/port_manager.h"
#include "ardour/progress.h"
@ -1887,6 +1888,7 @@ LuaBindings::common (lua_State* L)
/* libardour enums */
.beginNamespace ("PluginType")
.addFunction ("name", &PluginManager::plugin_type_name)
.addConst ("AudioUnit", ARDOUR::PluginType(AudioUnit))
.addConst ("LADSPA", ARDOUR::PluginType(LADSPA))
.addConst ("LV2", ARDOUR::PluginType(LV2))

View File

@ -1728,6 +1728,34 @@ PluginManager::to_generic_vst (const PluginType t)
return t;
}
std::string
PluginManager::plugin_type_name (const PluginType t, bool short_name)
{
#if defined WINDOWS_VST_SUPPORT && defined LXVST_SUPPORT
switch (t) {
case Windows_VST:
return short_name ? "VST" : "Windows-VST";
case LXVST:
return short_name ? "LXVST" : "Linux-VST";
default:
break;
}
#endif
switch (t) {
case Windows_VST:
case LXVST:
case MacVST:
return short_name ? "VST" : "VST2";
case AudioUnit:
return short_name ? "AU" : enum_2_string (t);
case LADSPA:
return short_name ? "LV1" : enum_2_string (t);
default:
return enum_2_string (t);
}
}
struct SortByTag {
bool operator() (std::string a, std::string b) {
return a.compare (b) < 0;