PluginPtr load (Session& session);
std::vector<Plugin::PresetRecord> get_presets (bool user_only) const;
- bool is_instrument () const { return _is_instrument ; }
+ bool in_category (const std::string &c) const {
+ return (category == c);
+ }
+ bool is_instrument () const { return _is_instrument; }
bool reconfigurable_io() const { return true; }
bool _is_instrument;
static std::string type2str (const ScriptType t);
static ScriptType str2type (const std::string& str);
- LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p)
+ LuaScriptInfo (ScriptType t, const std::string &n, const std::string &p, const std::string &uid)
: type (t)
, name (n)
, path (p)
+ , unique_id (uid)
{ }
virtual ~LuaScriptInfo () { }
ScriptType type;
std::string name;
std::string path;
+ std::string unique_id;
std::string author;
std::string license;
ARDOUR::PluginInfoList &ladspa_plugin_info ();
ARDOUR::PluginInfoList &lv2_plugin_info ();
ARDOUR::PluginInfoList &au_plugin_info ();
+ ARDOUR::PluginInfoList &lua_plugin_info ();
void refresh (bool cache_only = false);
void cancel_plugin_scan();
ARDOUR::PluginInfoList* _ladspa_plugin_info;
ARDOUR::PluginInfoList* _lv2_plugin_info;
ARDOUR::PluginInfoList* _au_plugin_info;
+ ARDOUR::PluginInfoList* _lua_plugin_info;
std::map<uint32_t, std::string> rdf_type;
bool _cancel_timeout;
void ladspa_refresh ();
+ void lua_refresh ();
+ void lua_refresh_cb ();
void windows_vst_refresh (bool cache_only = false);
void lxvst_refresh (bool cache_only = false);
std::string get_ladspa_category (uint32_t id);
std::vector<uint32_t> ladspa_plugin_whitelist;
+ PBD::ScopedConnection lua_refresh_connection;
Glib::Threads::Mutex _lock;
static PluginManager* _instance; // singleton
PluginManager& manager = PluginManager::instance();
PluginInfoList all_plugs;
all_plugs.insert(all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
+ all_plugs.insert(all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
#ifdef WINDOWS_VST_SUPPORT
all_plugs.insert(all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
#endif
name = lsi->name;
creator = lsi->author;
category = lsi->category;
- unique_id = "luascript"; // the interpreter is not unique.
+ unique_id = lsi->unique_id;
n_inputs.set (DataType::AUDIO, 1);
n_outputs.set (DataType::AUDIO, 1);
#include "LuaBridge/LuaBridge.h"
#include "i18n.h"
+#include "sha1.c"
using namespace ARDOUR;
using namespace PBD;
"function ardour (entry)"
" ardourluainfo['type'] = assert(entry['type'])"
" ardourluainfo['name'] = assert(entry['name'])"
+ " ardourluainfo['category'] = entry['category'] or 'Unknown'"
" ardourluainfo['author'] = entry['author'] or 'Unknown'"
" ardourluainfo['license'] = entry['license'] or ''"
" ardourluainfo['description'] = entry['description'] or ''"
return LuaScriptInfoPtr();
}
- LuaScriptInfoPtr lsi (new LuaScriptInfo (type, name, fn));
+ char hash[41];
+ Sha1Digest s;
+ sha1_init (&s);
+
+ if (fn.empty()) {
+ sha1_write (&s, (const uint8_t *) sc.c_str(), sc.size ());
+ } else {
+ try {
+ std::string script = Glib::file_get_contents (fn);
+ sha1_write (&s, (const uint8_t *) script.c_str(), script.size ());
+ } catch (Glib::FileError err) {
+ return LuaScriptInfoPtr();
+ }
+ }
+ sha1_result_hash (&s, hash);
+
+
+ LuaScriptInfoPtr lsi (new LuaScriptInfo (type, name, fn, hash));
for (luabridge::Iterator i(nfo); !i.isNil (); ++i) {
if (!i.key().isString() || !i.value().isString()) {
if (key == "author") { lsi->author = val; }
if (key == "license") { lsi->license = val; }
if (key == "description") { lsi->description = val; }
+ if (key == "category") { lsi->category = val; }
}
-
return lsi;
}
switch (type) {
case ARDOUR::Lua:
- {
- PluginPtr plugin (new LuaProc (session.engine(), session, ""));
- return plugin;
- }
+ plugs = mgr.lua_plugin_info();
break;
case ARDOUR::LADSPA:
void
PluginInsert::set_sinks (const ChanCount& c)
{
- bool changed = (_custom_sinks != c) && _custom_cfg;
_custom_sinks = c;
/* no signal, change will only be visible after re-config */
}
}
#endif
+ if (plugin == 0 && type == ARDOUR::Lua) {
+ /* unique ID (sha1 of script) was not found,
+ * load the plugin from the serialized version in the
+ * session-file instead.
+ */
+ boost::shared_ptr<LuaProc> lp (new LuaProc (_session.engine(), _session, ""));
+ XMLNode *ls = node.child (lp->state_node_name().c_str());
+ if (ls && lp) {
+ lp->set_script_from_state (*ls);
+ plugin = lp;
+ }
+ }
+
if (plugin == 0) {
error << string_compose(
_("Found a reference to a plugin (\"%1\") that is unknown.\n"
return -1;
}
- if (type == ARDOUR::Lua) {
- XMLNode *ls = node.child (plugin->state_node_name().c_str());
- // we need to load the script to set the name and parameters.
- boost::shared_ptr<LuaProc> lp = boost::dynamic_pointer_cast<LuaProc>(plugin);
- if (ls && lp) {
- lp->set_script_from_state (*ls);
- }
- }
-
// The name of the PluginInsert comes from the plugin, nothing else
_name = plugin->get_info()->name;
#include "ardour/filesystem_paths.h"
#include "ardour/ladspa.h"
#include "ardour/ladspa_plugin.h"
+#include "ardour/luascripting.h"
+#include "ardour/luaproc.h"
#include "ardour/plugin.h"
#include "ardour/plugin_manager.h"
#include "ardour/rc_configuration.h"
, _ladspa_plugin_info(0)
, _lv2_plugin_info(0)
, _au_plugin_info(0)
+ , _lua_plugin_info(0)
, _cancel_scan(false)
, _cancel_timeout(false)
{
}
BootMessage (_("Discovering Plugins"));
+
+ LuaScripting::instance().scripts_changed.connect_same_thread (lua_refresh_connection, boost::bind (&PluginManager::lua_refresh_cb, this));
}
delete _ladspa_plugin_info;
delete _lv2_plugin_info;
delete _au_plugin_info;
+ delete _lua_plugin_info;
}
}
BootMessage (_("Scanning LADSPA Plugins"));
ladspa_refresh ();
+ BootMessage (_("Scanning Lua DSP Processors"));
+ lua_refresh ();
#ifdef LV2_SUPPORT
BootMessage (_("Scanning LV2 Plugins"));
lv2_refresh ();
#endif
}
+void
+PluginManager::lua_refresh ()
+{
+ if (_lua_plugin_info) {
+ _lua_plugin_info->clear ();
+ } else {
+ _lua_plugin_info = new ARDOUR::PluginInfoList ();
+ }
+ ARDOUR::LuaScriptList & _scripts (LuaScripting::instance ().scripts (LuaScriptInfo::DSP));
+ for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) {
+ LuaPluginInfoPtr lpi (new LuaPluginInfo(*s));
+ _lua_plugin_info->push_back (lpi);
+ }
+}
+
+void
+PluginManager::lua_refresh_cb ()
+{
+ Glib::Threads::Mutex::Lock lm (_lock, Glib::Threads::TRY_LOCK);
+ if (!lm.locked()) {
+ return;
+ }
+ lua_refresh ();
+ PluginListChanged (); /* EMIT SIGNAL */
+}
+
void
PluginManager::ladspa_refresh ()
{
ofs << "LXVST";
break;
case Lua:
- assert (0);
- continue;
+ ofs << "Lua";
break;
}
type = Windows_VST;
} else if (stype == "LXVST") {
type = LXVST;
+ } else if (stype == "Lua") {
+ type = Lua;
} else {
error << string_compose (_("unknown plugin type \"%1\" - ignored"), stype)
<< endmsg;
#endif
return _empty_plugin_info;
}
+
+ARDOUR::PluginInfoList&
+PluginManager::lua_plugin_info ()
+{
+ assert(_lua_plugin_info);
+ return *_lua_plugin_info;
+}