diff options
author | Robin Gareus <robin@gareus.org> | 2016-03-18 20:01:10 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-03-18 20:01:10 +0100 |
commit | c648adfe43a2c01ae74c1b8701cf7ee3f9b382f3 (patch) | |
tree | a6cf723edd8fcc2a22f25c2c596fe3b919fcaa14 /libs | |
parent | 4ef3e251853dec5e7e300618c5135ea33af9ff81 (diff) |
implement LuaProc inline display
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/luaproc.h | 8 | ||||
-rw-r--r-- | libs/ardour/luaproc.cc | 48 |
2 files changed, 56 insertions, 0 deletions
diff --git a/libs/ardour/ardour/luaproc.h b/libs/ardour/ardour/luaproc.h index e77449163f..d0560e9953 100644 --- a/libs/ardour/ardour/luaproc.h +++ b/libs/ardour/ardour/luaproc.h @@ -30,6 +30,7 @@ #include "ardour/types.h" #include "ardour/plugin.h" #include "ardour/luascripting.h" +#include "ardour/dsp_filter.h" #include "lua/luastate.h" #include "LuaBridge/LuaBridge.h" @@ -98,6 +99,8 @@ public: std::string do_save_preset (std::string) { return ""; } void do_remove_preset (std::string) { } + bool has_inline_display () { return _lua_has_inline_display; } + void setup_lua_inline_gui (LuaState *lua_gui); private: void find_presets () { } @@ -114,6 +117,11 @@ private: std::string _script; std::string _docs; bool _lua_does_channelmapping; + bool _lua_has_inline_display; + + void queue_draw () { QueueDraw(); /* EMIT SIGNAL */ } + DSP::DspShm* instance_shm () { return &lshm; } + DSP::DspShm lshm; void init (); bool load_script (); diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index 09e1cd652e..8a0653dedb 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -122,10 +122,22 @@ LuaProc::init () LuaBindings::common (L); LuaBindings::dsp (L); + luabridge::getGlobalNamespace (L) + .beginNamespace ("Ardour") + .beginClass <LuaProc> ("LuaProc") + .addFunction ("queue_draw", &LuaProc::queue_draw) + .addFunction ("shmem", &LuaProc::instance_shm) + .endClass () + .endNamespace (); + // add session to global lua namespace luabridge::push <Session *> (L, &_session); lua_setglobal (L, "Session"); + // instance + luabridge::push <LuaProc *> (L, this); + lua_setglobal (L, "self"); + // sandbox lua.do_command ("io = nil os = nil loadfile = nil require = nil dofile = nil package = nil debug = nil"); #if 0 @@ -206,6 +218,11 @@ LuaProc::load_script () _ctrl_params.clear (); + luabridge::LuaRef lua_render = luabridge::getGlobal (L, "render_inline"); + if (lua_render.isFunction ()) { + _lua_has_inline_display = true; + } + luabridge::LuaRef lua_params = luabridge::getGlobal (L, "dsp_params"); if (lua_params.isFunction ()) { @@ -842,6 +859,37 @@ LuaProc::get_scale_points (uint32_t port) const } +void +LuaProc::setup_lua_inline_gui (LuaState *lua_gui) +{ + lua_State* LG = lua_gui->getState (); + LuaBindings::stddef (LG); + LuaBindings::common (LG); + LuaBindings::dsp (LG); + +#ifndef NDEBUG + lua_gui->Print.connect (sigc::mem_fun (*this, &LuaProc::lua_print)); +#endif + + lua_gui->do_command ("function ardour () end"); + lua_gui->do_command (_script); + + // TODO think: use a weak-pointer here ? + // (the GUI itself uses a shared ptr to this plugin, so we should be good) + luabridge::getGlobalNamespace (LG) + .beginNamespace ("Ardour") + .beginClass <LuaProc> ("LuaProc") + .addFunction ("shmem", &LuaProc::instance_shm) + .endClass () + .endNamespace (); + + luabridge::push <LuaProc *> (LG, this); + lua_setglobal (LG, "self"); + + luabridge::push <float *> (LG, _shadow_data); + lua_setglobal (LG, "CtrlPorts"); +} + //////////////////////////////////////////////////////////////////////////////// #include <glibmm/miscutils.h> #include <glibmm/fileutils.h> |