From f6b59676b50d11dca38318c55a3ad38655cdb77d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 3 Oct 2016 18:10:39 +0200 Subject: cont'd work on Lua Vamp-plugin API --- libs/ardour/ardour/lua_api.h | 5 +++-- libs/ardour/lua_api.cc | 9 +++++---- libs/ardour/luabindings.cc | 4 ++++ 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/lua_api.h b/libs/ardour/ardour/lua_api.h index 7578fab03e..5974a96b6d 100644 --- a/libs/ardour/ardour/lua_api.h +++ b/libs/ardour/ardour/lua_api.h @@ -197,7 +197,7 @@ namespace ARDOUR { namespace LuaAPI { /** initialize the plugin for use with analyze(). * - * This is equivalent to plugin():initialise (1, 8192, 8192) + * This is equivalent to plugin():initialise (1, 512, 1024) * and prepares a plugin for analyze. * * Manual initialization is only required to set plugin-parameters @@ -206,7 +206,7 @@ namespace ARDOUR { namespace LuaAPI { * @code * vamp:reset () * vamp:initialize () - * vamp:plugin():setParameter (0, 1.5) + * vamp:plugin():setParameter (0, 1.5, nil) * vamp:analyze (r, 0) * @endcode */ @@ -218,6 +218,7 @@ namespace ARDOUR { namespace LuaAPI { ::Vamp::Plugin* _plugin; float _sample_rate; framecnt_t _bufsize; + framecnt_t _stepsize; bool _initialized; }; diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index a96263b482..f6df554fd2 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -543,7 +543,8 @@ void LuaTableRef::assign (luabridge::LuaRef* rv, T key, const LuaTableEntry& s) LuaAPI::Vamp::Vamp (const std::string& key, float sample_rate) : _plugin (0) , _sample_rate (sample_rate) - , _bufsize (8192) + , _bufsize (1024) + , _stepsize (512) , _initialized (false) { using namespace ::Vamp::HostExt; @@ -577,7 +578,7 @@ LuaAPI::Vamp::initialize () if (!_plugin || _plugin->getMinChannelCount() > 1) { return false; } - if (!_plugin->initialise (1, _bufsize, _bufsize)) { + if (!_plugin->initialise (1, _stepsize, _bufsize)) { return false; } _initialized = true; @@ -615,10 +616,10 @@ LuaAPI::Vamp::analyze (boost::shared_ptr r, uint32_t channel, features = _plugin->process (bufs, ::Vamp::RealTime::fromSeconds ((double) pos / _sample_rate)); if (cb.type () == LUA_TFUNCTION) { - cb (features, pos); + cb (&features, pos); } - pos += to_read; + pos += std::min (_stepsize, to_read); if (pos >= len) { break; diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 59e64d3a86..2f29cc9e80 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -446,9 +446,13 @@ LuaBindings::common (lua_State* L) .beginClass ("RealTime") .addConstructor () + .addData ("sec", &Vamp::RealTime::sec, false) + .addData ("nsec", &Vamp::RealTime::nsec, false) .addFunction ("usec", &Vamp::RealTime::usec) .addFunction ("msec", &Vamp::RealTime::msec) .addFunction ("toString", &Vamp::RealTime::toString) + .addStaticFunction ("realTime2Frame", &Vamp::RealTime::realTime2Frame) + .addStaticFunction ("frame2RealTime", &Vamp::RealTime::frame2RealTime) .endClass () .beginClass ("PluginBase") -- cgit v1.2.3