From a51daedbe6cf59bb202496efc9bcba6867e6bb5e Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 4 Oct 2016 21:31:29 +0200 Subject: [PATCH] Vamp::Plugins::process Lua bindings --- libs/ardour/ardour/lua_api.h | 12 ++++++++++++ libs/ardour/lua_api.cc | 10 ++++++++++ libs/ardour/luabindings.cc | 8 ++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/lua_api.h b/libs/ardour/ardour/lua_api.h index 5974a96b6d..a049be2768 100644 --- a/libs/ardour/ardour/lua_api.h +++ b/libs/ardour/ardour/lua_api.h @@ -214,6 +214,18 @@ namespace ARDOUR { namespace LuaAPI { bool initialized () const { return _initialized; } + /** process given array of audio-samples. + * + * This is a lua-binding for vamp:plugin():process () + * + * @d audio-data, the vector must match the configured channel count + * and hold a complete buffer for every channel as set during + * plugin():initialise() + * @rt timestamp matching the provided buffer. + * @returns features extracted from that data (if the plugin is causal) + */ + ::Vamp::Plugin::FeatureSet process (const std::vector& d, ::Vamp::RealTime rt); + private: ::Vamp::Plugin* _plugin; float _sample_rate; diff --git a/libs/ardour/lua_api.cc b/libs/ardour/lua_api.cc index f6df554fd2..3fc5a5cf89 100644 --- a/libs/ardour/lua_api.cc +++ b/libs/ardour/lua_api.cc @@ -629,3 +629,13 @@ LuaAPI::Vamp::analyze (boost::shared_ptr r, uint32_t channel, delete [] data; return rv; } + +::Vamp::Plugin::FeatureSet +LuaAPI::Vamp::process (const std::vector& d, ::Vamp::RealTime rt) +{ + if (!_plugin || d.size() == 0) { + return ::Vamp::Plugin::FeatureSet (); + } + const float* const* bufs = &d[0]; + return _plugin->process (bufs, rt); +} diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index aa4e1543db..8e1063ba6c 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -265,6 +265,10 @@ LuaBindings::stddef (lua_State* L) // register float array (int32_t*) .registerArray ("IntArray") + // std::vector + .beginStdVector ("FloatArrayVector") + .endClass () + // TODO std::set .endNamespace (); } @@ -502,8 +506,7 @@ LuaBindings::common (lua_State* L) .endNamespace () // Vamp::PluginBase .deriveClass ("Plugin") - // TODO add wrapper std::vector - .addFunction ("process", &Vamp::Plugin::process) // XXX unusable due to float * const * + //.addFunction ("process", &Vamp::Plugin::process) // unusable due to float*const* -> LuaAPI::Vamp::process .addFunction ("getRemainingFeatures", &Vamp::Plugin::getRemainingFeatures) .endClass () @@ -1609,6 +1612,7 @@ LuaBindings::common (lua_State* L) .addFunction ("analyze", &ARDOUR::LuaAPI::Vamp::analyze) .addFunction ("reset", &ARDOUR::LuaAPI::Vamp::reset) .addFunction ("initialize", &ARDOUR::LuaAPI::Vamp::initialize) + .addFunction ("process", &ARDOUR::LuaAPI::Vamp::process) .endClass () .endNamespace () // end LuaAPI -- 2.30.2