#ifdef LV2_SUPPORT
all_plugs.insert (all_plugs.end (), manager.lv2_plugin_info ().begin (), manager.lv2_plugin_info ().end ());
#endif
+ all_plugs.insert (all_plugs.end (), manager.lua_plugin_info ().begin (), manager.lua_plugin_info ().end ());
for (PluginInfoList::const_iterator i = all_plugs.begin (); i != all_plugs.end (); ++i) {
if (((*i)->name == name || (*i)->unique_id == name) && (*i)->type == type) {
return get_plugin_insert_param (pi, which, ok);
}
+bool
+ARDOUR::LuaAPI::reset_processor_to_default ( boost::shared_ptr<Processor> proc )
+{
+ boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (proc);
+ if (pi) {
+ pi->reset_parameters_to_default();
+ return true;
+ }
+ return false;
+}
+
int
ARDOUR::LuaAPI::plugin_automation (lua_State *L)
{
return 3;
}
+int
+ARDOUR::LuaAPI::sample_to_timecode (lua_State *L)
+{
+ int top = lua_gettop (L);
+ if (top < 3) {
+ return luaL_argerror (L, 1, "invalid number of arguments sample_to_timecode (TimecodeFormat, sample_rate, sample)");
+ }
+ typedef Timecode::TimecodeFormat T;
+ T tf = luabridge::Stack<T>::get (L, 1);
+ double sample_rate = luabridge::Stack<double>::get (L, 2);
+ int64_t sample = luabridge::Stack<int64_t>::get (L, 3);
+
+ Timecode::Time timecode;
+
+ Timecode::sample_to_timecode (
+ sample, timecode, false, false,
+ Timecode::timecode_to_frames_per_second (tf),
+ Timecode::timecode_has_drop_frames (tf),
+ sample_rate,
+ 0, false, 0);
+
+ luabridge::Stack<uint32_t>::push (L, timecode.hours);
+ luabridge::Stack<uint32_t>::push (L, timecode.minutes);
+ luabridge::Stack<uint32_t>::push (L, timecode.seconds);
+ luabridge::Stack<uint32_t>::push (L, timecode.frames);
+ return 4;
+}
+
+int
+ARDOUR::LuaAPI::timecode_to_sample (lua_State *L)
+{
+ int top = lua_gettop (L);
+ if (top < 6) {
+ return luaL_argerror (L, 1, "invalid number of arguments sample_to_timecode (TimecodeFormat, sample_rate, hh, mm, ss, ff)");
+ }
+ typedef Timecode::TimecodeFormat T;
+ T tf = luabridge::Stack<T>::get (L, 1);
+ double sample_rate = luabridge::Stack<double>::get (L, 2);
+ int hh = luabridge::Stack<int>::get (L, 3);
+ int mm = luabridge::Stack<int>::get (L, 4);
+ int ss = luabridge::Stack<int>::get (L, 5);
+ int ff = luabridge::Stack<int>::get (L, 6);
+
+ Timecode::Time timecode;
+ timecode.negative = false;
+ timecode.hours = hh;
+ timecode.minutes = mm;
+ timecode.seconds = ss;
+ timecode.frames = ff;
+ timecode.subframes = 0;
+ timecode.rate = Timecode::timecode_to_frames_per_second (tf);
+ timecode.drop = Timecode::timecode_has_drop_frames (tf);
+
+ int64_t sample;
+
+ Timecode::timecode_to_sample (
+ timecode, sample, false, false,
+ sample_rate, 0, false, 0);
+
+ luabridge::Stack<int64_t>::push (L, sample);
+ return 1;
+}
+
+int
+ARDOUR::LuaAPI::sample_to_timecode_lua (lua_State *L)
+{
+ int top = lua_gettop (L);
+ if (top < 2) {
+ return luaL_argerror (L, 1, "invalid number of arguments sample_to_timecode (sample)");
+ }
+ Session const* const s = luabridge::Userdata::get <Session> (L, 1, true);
+ int64_t sample = luabridge::Stack<int64_t>::get (L, 2);
+
+ Timecode::Time timecode;
+
+ Timecode::sample_to_timecode (
+ sample, timecode, false, false,
+ s->timecode_frames_per_second (),
+ s->timecode_drop_frames (),
+ s->frame_rate (),
+ 0, false, 0);
+
+ luabridge::Stack<uint32_t>::push (L, timecode.hours);
+ luabridge::Stack<uint32_t>::push (L, timecode.minutes);
+ luabridge::Stack<uint32_t>::push (L, timecode.seconds);
+ luabridge::Stack<uint32_t>::push (L, timecode.frames);
+ return 4;
+}
+int
+ARDOUR::LuaAPI::timecode_to_sample_lua (lua_State *L)
+{
+ int top = lua_gettop (L);
+ if (top < 5) {
+ return luaL_argerror (L, 1, "invalid number of arguments sample_to_timecode (hh, mm, ss, ff)");
+ }
+ Session const* const s = luabridge::Userdata::get <Session> (L, 1, true);
+ int hh = luabridge::Stack<int>::get (L, 2);
+ int mm = luabridge::Stack<int>::get (L, 3);
+ int ss = luabridge::Stack<int>::get (L, 4);
+ int ff = luabridge::Stack<int>::get (L, 5);
+
+ Timecode::Time timecode;
+ timecode.negative = false;
+ timecode.hours = hh;
+ timecode.minutes = mm;
+ timecode.seconds = ss;
+ timecode.frames = ff;
+ timecode.subframes = 0;
+ timecode.rate = s->timecode_frames_per_second ();
+ timecode.drop = s->timecode_drop_frames ();
+
+ int64_t sample;
+
+ Timecode::timecode_to_sample (
+ timecode, sample, false, false,
+ s->frame_rate (),
+ 0, false, 0);
+
+ luabridge::Stack<int64_t>::push (L, sample);
+ return 1;
+}
+
int
ARDOUR::LuaOSC::Address::send (lua_State *L)
{
return 4;
}
+int
+ARDOUR::LuaAPI::color_to_rgba (lua_State *L)
+{
+ int top = lua_gettop (L);
+ if (top < 1) {
+ return luaL_argerror (L, 1, "invalid number of arguments, color_to_rgba (uint32_t)");
+ }
+ uint32_t color = luabridge::Stack<uint32_t>::get (L, 1);
+ double r, g, b, a;
+
+ /* libardour is no user of libcanvas, otherwise
+ * we could just call
+ * ArdourCanvas::color_to_rgba (color, r, g, b, a);
+ */
+ r = ((color >> 24) & 0xff) / 255.0;
+ g = ((color >> 16) & 0xff) / 255.0;
+ b = ((color >> 8) & 0xff) / 255.0;
+ a = ((color >> 0) & 0xff) / 255.0;
+
+ luabridge::Stack <double>::push (L, r);
+ luabridge::Stack <double>::push (L, g);
+ luabridge::Stack <double>::push (L, b);
+ luabridge::Stack <double>::push (L, a);
+ return 4;
+}
+
int
ARDOUR::LuaAPI::build_filename (lua_State *L)
{
}
}
+std::vector<std::string>
+LuaAPI::Vamp::list_plugins ()
+{
+ using namespace ::Vamp::HostExt;
+ PluginLoader* loader (PluginLoader::getInstance());
+ return loader->listPlugins ();
+}
LuaAPI::Vamp::Vamp (const std::string& key, float sample_rate)
: _plugin (0)
, _sample_rate (sample_rate)
- , _bufsize (8192)
+ , _bufsize (1024)
+ , _stepsize (1024)
, _initialized (false)
{
using namespace ::Vamp::HostExt;
PBD::error << string_compose (_("VAMP Plugin \"%1\" could not be loaded"), key) << endmsg;
throw failed_constructor ();
}
+
+ size_t bs = _plugin->getPreferredBlockSize ();
+ size_t ss = _plugin->getPreferredStepSize ();
+
+ if (bs > 0 && ss > 0 && bs <= 8192 && ss <= 8192) {
+ _bufsize = bs;
+ _stepsize = bs;
+ }
}
LuaAPI::Vamp::~Vamp ()
if (!_plugin || _plugin->getMinChannelCount() > 1) {
return false;
}
- if (!_plugin->initialise (1, _bufsize, _bufsize)) {
+ if (!_plugin->initialise (1, _stepsize, _bufsize)) {
return false;
}
_initialized = true;
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;
delete [] data;
return rv;
}
+
+::Vamp::Plugin::FeatureSet
+LuaAPI::Vamp::process (const std::vector<float*>& d, ::Vamp::RealTime rt)
+{
+ if (!_plugin || d.size() == 0) {
+ return ::Vamp::Plugin::FeatureSet ();
+ }
+ const float* const* bufs = &d[0];
+ return _plugin->process (bufs, rt);
+}
+
+boost::shared_ptr<Evoral::Note<Evoral::Beats> >
+LuaAPI::new_noteptr (uint8_t chan, Evoral::Beats beat_time, Evoral::Beats length, uint8_t note, uint8_t velocity)
+{
+ return boost::shared_ptr<Evoral::Note<Evoral::Beats> > (new Evoral::Note<Evoral::Beats>(chan, beat_time, length, note, velocity));
+}
+
+std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > >
+LuaAPI::note_list (boost::shared_ptr<MidiModel> mm)
+{
+ typedef boost::shared_ptr<Evoral::Note<Evoral::Beats> > NotePtr;
+
+ std::list<NotePtr> note_ptr_list;
+
+ const MidiModel::Notes& notes = mm->notes();
+ for (MidiModel::Notes::const_iterator i = notes.begin(); i != notes.end(); ++i) {
+ note_ptr_list.push_back (*i);
+ }
+ return note_ptr_list;
+}