prototype [LV2]patch-change support for generic plugin UIs.
[ardour.git] / libs / ardour / ardour / lv2_plugin.h
index d62ddb140ef6b4b92bc8a01c0b93b42d34d0658c..85fec0acb626baa6f25b98c48d93fd3b8c7a4a6f 100644 (file)
 #include <set>
 #include <string>
 #include <vector>
+#include <boost/enable_shared_from_this.hpp>
 
 #include "ardour/plugin.h"
 #include "ardour/uri_map.h"
 #include "ardour/worker.h"
 #include "pbd/ringbuffer.h"
 
+#ifndef PATH_MAX
+#define PATH_MAX 1024
+#endif
+
+typedef struct LV2_Evbuf_Impl LV2_Evbuf;
+
 namespace ARDOUR {
 
 // a callback function for lilv_state_new_from_instance(). friend of LV2Plugin
@@ -41,7 +48,7 @@ const void* lv2plugin_get_port_value(const char* port_symbol,
 class AudioEngine;
 class Session;
 
-class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
+class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
 {
   public:
        LV2Plugin (ARDOUR::AudioEngine& engine,
@@ -75,6 +82,7 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        const void* c_ui_type();
 
        bool is_external_ui () const;
+       bool is_external_kx () const;
        bool ui_is_resizable () const;
 
        const char* port_symbol (uint32_t port) const;
@@ -138,6 +146,13 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
 
        Worker* worker() { return _worker; }
 
+       uint32_t     patch_count() const { return _patch_count; }
+       const char * patch_uri(const uint32_t p) const { if (p < _patch_count) return _patch_value_uri[p]; else return NULL; }
+       const char * patch_key(const uint32_t p) const { if (p < _patch_count) return _patch_value_key[p]; else return NULL; }
+       const char * patch_val(const uint32_t p) const { if (p < _patch_count) return _patch_value_cur[p]; else return NULL; }
+       bool         patch_set(const uint32_t p, const char * val);
+       PBD::Signal1<void,const uint32_t> PatchChanged;
+
        int work(uint32_t size, const void* data);
        int work_response(uint32_t size, const void* data);
 
@@ -148,6 +163,8 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
                uint32_t atom_Path;
                uint32_t atom_Sequence;
                uint32_t atom_eventTransfer;
+               uint32_t atom_URID;
+               uint32_t atom_Blank;
                uint32_t log_Error;
                uint32_t log_Note;
                uint32_t log_Warning;
@@ -160,6 +177,9 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
                uint32_t time_beatsPerMinute;
                uint32_t time_frame;
                uint32_t time_speed;
+               uint32_t patch_Set;
+               uint32_t patch_property;
+               uint32_t patch_value;
        };
 
        static URIDs urids;
@@ -183,6 +203,13 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        double        _next_cycle_speed;  ///< Expected start frame of next run cycle
        PBD::ID       _insert_id;
 
+       uint32_t      _patch_count;
+       char **       _patch_value_uri;
+       char **       _patch_value_key;
+       char          (*_patch_value_cur)[PATH_MAX]; ///< current value
+       char          (*_patch_value_set)[PATH_MAX]; ///< new value to set
+       Glib::Threads::Mutex _patch_set_lock;
+
        friend const void* lv2plugin_get_port_value(const char* port_symbol,
                                                    void*       user_data,
                                                    uint32_t*   size,
@@ -196,12 +223,14 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
                PORT_EVENT    = 1 << 4,  ///< Old event API event port
                PORT_SEQUENCE = 1 << 5,  ///< New atom API event port
                PORT_MIDI     = 1 << 6,  ///< Event port understands MIDI
-               PORT_POSITION = 1 << 7   ///< Event port understands position
+               PORT_POSITION = 1 << 7,  ///< Event port understands position
+               PORT_PATCHMSG = 1 << 8   ///< Event port supports patch:Message
        } PortFlag;
 
        typedef unsigned PortFlags;
 
        std::vector<PortFlags>         _port_flags;
+       std::vector<size_t>            _port_minimumSize;
        std::map<std::string,uint32_t> _port_indices;
 
        /// Message send to/from UI via ports
@@ -268,16 +297,16 @@ class LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
 };
 
 
-class LV2PluginInfo : public PluginInfo {
+class LIBARDOUR_API LV2PluginInfo : public PluginInfo , public boost::enable_shared_from_this<ARDOUR::LV2PluginInfo> {
 public:
-       LV2PluginInfo (const void* c_plugin);
+       LV2PluginInfo (const char* plugin_uri);
        ~LV2PluginInfo ();
 
        static PluginInfoList* discover ();
 
        PluginPtr load (Session& session);
 
-       const void* _c_plugin;
+       char * _plugin_uri;
 };
 
 typedef boost::shared_ptr<LV2PluginInfo> LV2PluginInfoPtr;