[SCM] calf/master: + Framework: Moved URI map extension-related stuff to event_mixin where it belongs (actually, it belongs somewhere else, but this will do for now) + Testing: added a temporary Msg Read plugin (will be used for experiments related to work-in-progress message extension, and then possibly removed)

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:37:44 UTC 2013


The following commit has been merged in the master branch:
commit bf40bad21d1835a1eb14eb5c7b38b4e5c92a3a1d
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Tue Oct 14 22:47:26 2008 +0000

    + Framework: Moved URI map extension-related stuff to event_mixin where it belongs (actually, it belongs somewhere else, but this will do for now)
    + Testing: added a temporary Msg Read plugin (will be used for experiments related to work-in-progress message extension, and then possibly removed)
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@332 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/src/calf/lv2helpers.h b/src/calf/lv2helpers.h
index fe911eb..c65f059 100644
--- a/src/calf/lv2helpers.h
+++ b/src/calf/lv2helpers.h
@@ -23,18 +23,32 @@
 
 #if USE_LV2
 
-/// A mixin for adding the event feature to the small plugin
+/// A mixin for adding the event feature and URI map to the small plugin
 template<class T>
 class event_mixin: public T
 {
 public:
+    /// URI map feature pointer
+    LV2_URI_Map_Feature *uri_map;
     /// Event feature pointer
     LV2_Event_Feature *event_feature;
+    virtual uint32_t map_uri(const char *ns, const char *URI)
+    {
+        return uri_map->uri_to_id(uri_map->callback_data, ns, URI);
+    }
+    virtual void map_uris()
+    {
+    }
     virtual void use_feature(const char *URI, void *data) {
         if (!strcmp(URI, LV2_EVENT_URI))
         {
             event_feature = (LV2_Event_Feature *)data;
         }
+        if (!strcmp(URI, LV2_URI_MAP_URI))
+        {
+            uri_map = (LV2_URI_Map_Feature *)data;
+            map_uris();
+        }
         T::use_feature(URI, data);
     }
     /// Create a reference
@@ -45,22 +59,27 @@ public:
 
 /// A mixin for adding the URI map and MIDI event type retrieval to small plugins
 template<class T>
-class midi_mixin: public event_mixin<T>
+class midi_mixin: public virtual event_mixin<T>
 {
 public:
-    /// URI map feature pointer
-    LV2_URI_Map_Feature *uri_map;
     /// MIDI event ID, as resolved using the URI map feature
     uint32_t midi_event_type;
-    virtual void use_feature(const char *URI, void *data) {
-        if (!strcmp(URI, LV2_URI_MAP_URI))
-        {
-            uri_map = (LV2_URI_Map_Feature *)data;
-            midi_event_type = uri_map->uri_to_id(uri_map->callback_data, 
-                "http://lv2plug.in/ns/ext/event",
-                "http://lv2plug.in/ns/ext/midi#MidiEvent");
-        }
-        event_mixin<T>::use_feature(URI, data);
+    virtual void map_uris() {
+        midi_event_type = this->map_uri("http://lv2plug.in/ns/ext/event", "http://lv2plug.in/ns/ext/midi#MidiEvent");
+        printf("MIDI event type = %d\n", midi_event_type);
+    }
+};
+
+/// A mixin for adding the URI map and MIDI event type retrieval to small plugins
+template<class T>
+class message_mixin: public virtual event_mixin<T>
+{
+public:
+    /// MIDI event ID, as resolved using the URI map feature
+    uint32_t message_event_type;
+    virtual void map_uris() {
+        message_event_type = this->map_uri("http://lv2plug.in/ns/ext/event", "http://lv2plug.in/ns/dev/msg#MessageEvent");
+        printf("Message event type = %d\n", message_event_type);
     }
 };
 
diff --git a/src/calf/modulelist.h b/src/calf/modulelist.h
index 4c53787..db3f261 100644
--- a/src/calf/modulelist.h
+++ b/src/calf/modulelist.h
@@ -82,6 +82,7 @@
     PER_SMALL_MODULE_ITEM(mux4_c, "mux4_c")
     PER_SMALL_MODULE_ITEM(mux8_c, "mux8_c")
     PER_SMALL_MODULE_ITEM(mux16_c, "mux16_c")
+    PER_SMALL_MODULE_ITEM(msgread_e, "msgread_e")
 #endif
 #undef PER_SMALL_MODULE_ITEM
 #endif
\ No newline at end of file
diff --git a/src/modules_small.cpp b/src/modules_small.cpp
index 6667d05..4d294b4 100644
--- a/src/modules_small.cpp
+++ b/src/modules_small.cpp
@@ -1745,6 +1745,50 @@ public:
         port_info(pii, "gate", "Gate");
     }
 };
+
+class msgread_e_audio_module: public message_mixin<small_audio_module_base<1, 1> >
+{
+public:
+    uint32_t set_float_msg, float_type;
+    static void plugin_info(plugin_info_iface *pii)
+    {
+        pii->names("msgread_e", "Msg Read", "lv2:UtilityPlugin");
+        pii->event_port("in", "In").input();
+        pii->control_port("out", "Out", 0).output();
+    }
+    virtual void map_uris()
+    {
+        message_mixin<small_audio_module_base<1, 1> >::map_uris();
+        set_float_msg = map_uri("http://lv2plug.in/ns/dev/msg", "http://foltman.com/garbage/setFloat");
+        float_type = map_uri("http://lv2plug.in/ns/dev/types", "http://lv2plug.in/ns/dev/types#float");
+    }
+    void process(uint32_t count)
+    {
+        event_port_read_iterator ri((const LV2_Event_Buffer *)ins[0]);
+        while(ri)
+        {
+            const lv2_event *event = &*ri++;
+            if (event->type == message_event_type)
+            {
+                struct payload {
+                    uint32_t selector;
+                    uint32_t parg_count;
+                    uint32_t data_type;
+                    float data_value;
+                    uint32_t narg_count;
+                };
+                const payload *p = (const payload *)event->data;
+                if (p->selector == set_float_msg) {
+                    assert(p->parg_count == 1);
+                    assert(p->data_type == float_type);
+                    *outs[0] = p->data_value;
+                    assert(p->narg_count == 0); // this is just for testing - passing 
+                }
+            }
+        }
+    }
+};
+
 };
 
 #define PER_SMALL_MODULE_ITEM(name, id) SMALL_WRAPPERS(name, id)

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list