diff options
-rw-r--r-- | libs/ardour/ardour/lua_api.h | 36 | ||||
-rw-r--r-- | libs/ardour/lua_api.cc | 67 | ||||
-rw-r--r-- | libs/ardour/luabindings.cc | 12 | ||||
-rw-r--r-- | libs/ardour/wscript | 1 |
4 files changed, 116 insertions, 0 deletions
diff --git a/libs/ardour/ardour/lua_api.h b/libs/ardour/ardour/lua_api.h new file mode 100644 index 0000000000..c69469f184 --- /dev/null +++ b/libs/ardour/ardour/lua_api.h @@ -0,0 +1,36 @@ +/* + * 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. + * + */ +#ifndef _ardour_lua_api_h_ +#define _ardour_lua_api_h_ + +#include <string> +#include <boost/shared_ptr.hpp> + +#include "ardour/libardour_visibility.h" + +#include "ardour/processor.h" +#include "ardour/session.h" + +namespace ARDOUR { namespace LuaAPI { + + boost::shared_ptr<ARDOUR::Processor> new_luaproc (ARDOUR::Session *s, const std::string&); + +} } /* namespace */ + +#endif // _ardour_lua_api_h_ 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)); +} diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index b202649229..ef7d450deb 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -29,6 +29,7 @@ #include "ardour/chan_mapping.h" #include "ardour/dB.h" #include "ardour/dsp_filter.h" +#include "ardour/lua_api.h" #include "ardour/luabindings.h" #include "ardour/meter.h" #include "ardour/midi_track.h" @@ -147,6 +148,12 @@ LuaBindings::common (lua_State* L) .addVoidConstructor () .endClass () + .beginNamespace ("Route") + .beginClass <Route::ProcessorStreams> ("ProcessorStreams") + .addVoidConstructor () + .endClass () + .endNamespace () + .beginNamespace ("Properties") // templated class definitions .beginClass <PBD::PropertyDescriptor<bool> > ("BoolProperty").endClass () @@ -186,6 +193,7 @@ LuaBindings::common (lua_State* L) .addFunction ("active", &Route::active) .addFunction ("set_active", &Route::set_active) .addFunction ("nth_plugin", &Route::nth_plugin) + .addFunction ("add_processor_by_index", &Route::add_processor_by_index) .endClass () .deriveWSPtrClass <Track, Route> ("Track") @@ -501,6 +509,10 @@ LuaBindings::common (lua_State* L) .endNamespace () // END Session enums + .beginNamespace ("LuaAPI") + .addFunction ("new_luaproc", ARDOUR::LuaAPI::new_luaproc) + .endNamespace () + .endNamespace ();// END ARDOUR } diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 5e44ccf687..5b7abaa9c8 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -112,6 +112,7 @@ libardour_sources = [ 'location_importer.cc', 'ltc_file_reader.cc', 'ltc_slave.cc', + 'lua_api.cc', 'luabindings.cc', 'luaproc.cc', 'luascripting.cc', |