summaryrefslogtreecommitdiff
path: root/libs/ardour/lua_api.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-03-18 22:52:19 +0100
committerRobin Gareus <robin@gareus.org>2016-03-18 22:52:19 +0100
commit79ea6c82487c47c377abff59ab8625f23b3b7809 (patch)
tree7e48a6c1c30ad9e39ce9346be8ca9ed036bd2871 /libs/ardour/lua_api.cc
parente4a4ef9a6bb49c956b2f4371df19e8c027ec9918 (diff)
start a dedicated ARDOUR lua function collection
Diffstat (limited to 'libs/ardour/lua_api.cc')
-rw-r--r--libs/ardour/lua_api.cc67
1 files changed, 67 insertions, 0 deletions
diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc
new file mode 100644
index 0000000000..bd7dc0e780
--- /dev/null
+++ b/libs/ardour/lua_api.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2016 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.
+ *
+ */
+#include <cstring>
+
+#include "pbd/error.h"
+#include "pbd/compose.h"
+
+#include "ardour/lua_api.h"
+#include "ardour/luaproc.h"
+#include "ardour/luascripting.h"
+#include "ardour/plugin.h"
+#include "ardour/plugin_insert.h"
+
+#include "i18n.h"
+
+using namespace ARDOUR;
+using namespace PBD;
+using namespace std;
+
+boost::shared_ptr<Processor>
+ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
+{
+ if (!s) {
+ return boost::shared_ptr<Processor> (0);
+ }
+
+ LuaScriptInfoPtr spi;
+ ARDOUR::LuaScriptList & _scripts (LuaScripting::instance ().scripts (LuaScriptInfo::DSP));
+ for (LuaScriptList::const_iterator s = _scripts.begin(); s != _scripts.end(); ++s) {
+ if (name == (*s)->name) {
+ spi = *s;
+ break;
+ }
+ }
+
+ if (!spi) {
+ warning << _("Script with given name was not found\n");
+ return boost::shared_ptr<Processor> (0);
+ }
+
+ PluginPtr p;
+ try {
+ LuaPluginInfoPtr lpi (new LuaPluginInfo(spi));
+ p = (lpi->load (*s));
+ } catch (...) {
+ warning << _("Failed to instantiate Lua Processor\n");
+ return boost::shared_ptr<Processor> (0);
+ }
+
+ return boost::shared_ptr<Processor> (new PluginInsert (*s, p));
+}