diff json/VampJson.h @ 16:913fc1d3710a

Create process request in JSON version, plus a fix
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 18 May 2016 14:38:27 +0100
parents 1d13354ddc44
children 3ef01276e15e
line wrap: on
line diff
--- a/json/VampJson.h	Wed May 18 13:54:33 2016 +0100
+++ b/json/VampJson.h	Wed May 18 14:38:27 2016 +0100
@@ -759,6 +759,29 @@
 
         return cr;
     }
+
+    static json11::Json
+    fromProcessRequest(const Vamp::HostExt::ProcessRequest &r,
+                       PluginHandleMapper &mapper) {
+
+        json11::Json::object jo;
+        jo["pluginHandle"] = mapper.pluginToHandle(r.plugin);
+
+        json11::Json::object io;
+        io["timestamp"] = fromRealTime(r.timestamp);
+
+        json11::Json::array chans;
+        for (size_t i = 0; i < r.inputBuffers.size(); ++i) {
+            json11::Json::object c;
+            c["b64values"] = fromFloatBuffer(r.inputBuffers[i].data(),
+                                             r.inputBuffers[i].size());
+            chans.push_back(c);
+        }
+        io["inputBuffers"] = chans;
+        
+        jo["processInput"] = io;
+        return json11::Json(jo);
+    }
 };
 
 }