Optimize plugin-processing for non-automated params
[ardour.git] / libs / ardour / lua_api.cc
index 98de7687600fe086cc1321fad97250041217ce8d..d4e2bb23b45a88f2cc7242231fedb757a039d160 100644 (file)
@@ -103,6 +103,33 @@ ARDOUR::LuaAPI::new_luaproc (Session *s, const string& name)
        return boost::shared_ptr<Processor> (new PluginInsert (*s, p));
 }
 
+PluginInfoList
+ARDOUR::LuaAPI::list_plugins ()
+{
+       PluginManager& manager = PluginManager::instance ();
+       PluginInfoList all_plugs;
+       all_plugs.insert (all_plugs.end (), manager.ladspa_plugin_info ().begin (), manager.ladspa_plugin_info ().end ());
+       all_plugs.insert (all_plugs.end (), manager.lua_plugin_info ().begin (), manager.lua_plugin_info ().end ());
+#ifdef WINDOWS_VST_SUPPORT
+       all_plugs.insert (all_plugs.end (), manager.windows_vst_plugin_info ().begin (), manager.windows_vst_plugin_info ().end ());
+#endif
+#ifdef MACVST_SUPPORT
+       all_plugs.insert (all_plugs.end (), manager.mac_vst_plugin_info ().begin (), manager.mac_vst_plugin_info ().end ());
+#endif
+#ifdef LXVST_SUPPORT
+       all_plugs.insert (all_plugs.end (), manager.lxvst_plugin_info ().begin (), manager.lxvst_plugin_info ().end ());
+#endif
+#ifdef AUDIOUNIT_SUPPORT
+       all_plugs.insert (all_plugs.end (), manager.au_plugin_info ().begin (), manager.au_plugin_info ().end ());
+#endif
+#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 ());
+
+       return all_plugs;
+}
+
 PluginInfoPtr
 ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
 {
@@ -113,6 +140,9 @@ ARDOUR::LuaAPI::new_plugin_info (const string& name, ARDOUR::PluginType type)
 #ifdef WINDOWS_VST_SUPPORT
        all_plugs.insert (all_plugs.end (), manager.windows_vst_plugin_info ().begin (), manager.windows_vst_plugin_info ().end ());
 #endif
+#ifdef MACVST_SUPPORT
+       all_plugs.insert (all_plugs.end (), manager.mac_vst_plugin_info ().begin (), manager.mac_vst_plugin_info ().end ());
+#endif
 #ifdef LXVST_SUPPORT
        all_plugs.insert (all_plugs.end (), manager.lxvst_plugin_info ().begin (), manager.lxvst_plugin_info ().end ());
 #endif
@@ -343,7 +373,7 @@ ARDOUR::LuaAPI::sample_to_timecode_lua (lua_State *L)
                        sample, timecode, false, false,
                        s->timecode_frames_per_second (),
                        s->timecode_drop_frames (),
-                       s->frame_rate (),
+                       s->sample_rate (),
                        0, false, 0);
 
        luabridge::Stack<uint32_t>::push (L, timecode.hours);
@@ -379,7 +409,7 @@ ARDOUR::LuaAPI::timecode_to_sample_lua (lua_State *L)
 
        Timecode::timecode_to_sample (
                        timecode, sample, false, false,
-                       s->frame_rate (),
+                       s->sample_rate (),
                        0, false, 0);
 
        luabridge::Stack<int64_t>::push (L, sample);
@@ -503,6 +533,14 @@ ARDOUR::LuaAPI::hsla_to_rgba (lua_State *L)
        return 4;
 }
 
+std::string
+ARDOUR::LuaAPI::ascii_dtostr (const double d)
+{
+       gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
+       g_ascii_dtostr (buf, sizeof(buf), d);
+       return std::string (buf);
+}
+
 int
 ARDOUR::LuaAPI::color_to_rgba (lua_State *L)
 {
@@ -643,10 +681,11 @@ LuaTableRef::set (lua_State* L)
                                        }
                                        // invalid userdata -- fall through
                                }
-                               // no break
+                               /* fall through */
                        case LUA_TFUNCTION: // no support -- we could... string.format("%q", string.dump(value, true))
+                               /* fall through */
                        case LUA_TTABLE: // no nested tables, sorry.
-                       case LUA_TNIL: // fallthrough
+                       case LUA_TNIL:
                        default:
                                // invalid value
                                lua_pop (L, 2);
@@ -774,12 +813,12 @@ LuaAPI::Vamp::analyze (boost::shared_ptr<ARDOUR::Readable> r, uint32_t channel,
        float* data = new float[_bufsize];
        float* bufs[1] = { data };
 
-       framecnt_t len = r->readable_length();
-       framepos_t pos = 0;
+       samplecnt_t len = r->readable_length();
+       samplepos_t pos = 0;
 
        int rv = 0;
        while (1) {
-               framecnt_t to_read = std::min ((len - pos), _bufsize);
+               samplecnt_t to_read = std::min ((len - pos), _bufsize);
                if (r->read (data, pos, to_read, channel) != to_read) {
                        rv = -1;
                        break;
@@ -815,16 +854,16 @@ LuaAPI::Vamp::process (const std::vector<float*>& d, ::Vamp::RealTime rt)
        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)
+boost::shared_ptr<Evoral::Note<Temporal::Beats> >
+LuaAPI::new_noteptr (uint8_t chan, Temporal::Beats beat_time, Temporal::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));
+       return boost::shared_ptr<Evoral::Note<Temporal::Beats> > (new Evoral::Note<Temporal::Beats>(chan, beat_time, length, note, velocity));
 }
 
-std::list<boost::shared_ptr<Evoral::Note<Evoral::Beats> > >
+std::list<boost::shared_ptr<Evoral::Note<Temporal::Beats> > >
 LuaAPI::note_list (boost::shared_ptr<MidiModel> mm)
 {
-       typedef boost::shared_ptr<Evoral::Note<Evoral::Beats> > NotePtr;
+       typedef boost::shared_ptr<Evoral::Note<Temporal::Beats> > NotePtr;
 
        std::list<NotePtr> note_ptr_list;