changeset 14:c35d0909a74e

Process requests
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 18 May 2016 12:21:23 +0100
parents 1d13354ddc44
children d907576aa299
files capnproto/VampnProto.h capnproto/vamp.capnp
diffstat 2 files changed, 86 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/capnproto/VampnProto.h	Tue May 17 16:18:24 2016 +0100
+++ b/capnproto/VampnProto.h	Wed May 18 12:21:23 2016 +0100
@@ -545,6 +545,91 @@
             cr.outputs.push_back(desc);
         }
     }
+
+    static void
+    buildProcessInput(ProcessInput::Builder &b,
+                      Vamp::RealTime timestamp,
+                      const std::vector<std::vector<float> > &buffers) {
+
+        auto t = b.initTimestamp();
+        buildRealTime(t, timestamp);
+        auto vv = b.initInputBuffers(buffers.size());
+        for (size_t ch = 0; ch < buffers.size(); ++ch) {
+            const int n = int(buffers[ch].size());
+            vv.init(ch, n);
+            auto v = vv[ch];
+            for (int i = 0; i < n; ++i) {
+                v.set(i, buffers[ch][i]);
+            }
+        }
+    }
+    
+    static void
+    readProcessInput(Vamp::RealTime &timestamp,
+                     std::vector<std::vector<float> > &buffers,
+                     const ProcessInput::Reader &b) {
+
+        readRealTime(timestamp, b.getTimestamp());
+        buffers.clear();
+        for (const auto &v: b.getInputBuffers()) {
+            std::vector<float> buf;
+            for (auto x: v) {
+                buf.push_back(x);
+            }
+            buffers.push_back(buf);
+        }
+    }
+    
+    static void
+    buildProcessRequest(ProcessRequest::Builder &b,
+                        const Vamp::HostExt::ProcessRequest &pr,
+                        PluginHandleMapper &mapper) {
+
+        b.setPluginHandle(mapper.pluginToHandle(pr.plugin));
+        auto input = b.initInput();
+        buildProcessInput(input, pr.timestamp, pr.inputBuffers);
+    }
+
+    static void
+    readProcessRequest(Vamp::HostExt::ProcessRequest &pr,
+                       const ProcessRequest::Reader &r,
+                       PluginHandleMapper &mapper) {
+
+        auto h = r.getPluginHandle();
+        pr.plugin = mapper.handleToPlugin(h);
+        readProcessInput(pr.timestamp, pr.inputBuffers, r.getInput());
+    }
+
+    static void
+    buildVampListRequest(VampRequest::Builder &b) {
+        b.getRequest().setList();
+    }
+
+    static void
+    buildVampLoadRequest(VampRequest::Builder &b,
+                         const Vamp::HostExt::LoadRequest &req) {
+        auto u = b.getRequest().initLoad();
+        buildLoadRequest(u, req);
+    }
+
+    static void
+    buildVampConfigureRequest(VampRequest::Builder &b,
+                              const Vamp::HostExt::ConfigurationRequest &cr,
+                              PluginHandleMapper &mapper) {
+        auto u = b.getRequest().initConfigure();
+        buildConfigurationRequest(u, cr, mapper);
+    }
+
+    static void
+    buildVampProcessRequest(VampRequest::Builder &b,
+                            const Vamp::HostExt::ProcessRequest &pr,
+                            PluginHandleMapper &mapper) {
+        auto u = b.getRequest().initProcess();
+        buildProcessRequest(u, pr, mapper);
+    }
+
+
+    //...!!! and responses
 };
 
 }
--- a/capnproto/vamp.capnp	Tue May 17 16:18:24 2016 +0100
+++ b/capnproto/vamp.capnp	Wed May 18 12:21:23 2016 +0100
@@ -137,8 +137,7 @@
 
 struct ProcessRequest {
     pluginHandle       @0  :Int32;
-    timestamp          @1  :RealTime;
-    input              @2  :List(List(Float32));
+    input              @1  :ProcessInput;
 }
 
 struct VampRequest {