diff vamp-capnp/VampnProto.h @ 289:26027c3a99a0

Further wiring for ProgramParameters - should now be supported throughout
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 08 Apr 2020 15:02:24 +0100
parents 292ec9b50280
children
line wrap: on
line diff
--- a/vamp-capnp/VampnProto.h	Tue Apr 07 18:04:53 2020 +0100
+++ b/vamp-capnp/VampnProto.h	Wed Apr 08 15:02:24 2020 +0100
@@ -534,6 +534,37 @@
         c.framing.stepSize = r.getFraming().getStepSize();
         c.framing.blockSize = r.getFraming().getBlockSize();
     }
+
+    static void
+    buildProgramParameterMap(piper::LoadResponse::PPPair::Builder &b,
+                             const PluginProgramParameters &pparams,
+                             std::string program) {
+        b.setProgram(program);
+        if (pparams.programParameters.find(program) ==
+            pparams.programParameters.end()) {
+            b.initParameters(0);
+            return;
+        }
+        auto params = b.initParameters
+            (unsigned(pparams.programParameters.at(program).size()));
+        int i = 0;
+        for (auto pv: pparams.programParameters.at(program)) {
+            params[i].setParameter(pv.first);
+            params[i].setValue(pv.second);
+            ++i;
+        }
+    }
+    
+    static void
+    readProgramParameterMap(PluginProgramParameters &pparams,
+                            const piper::LoadResponse::PPPair::Reader &r) {
+
+        auto program = r.getProgram();
+        auto params = r.getParameters();
+        for (auto pv: params) {
+            pparams.programParameters[program][pv.getParameter()] = pv.getValue();
+        }
+    }
     
     static void
     buildListRequest(piper::ListRequest::Builder &r,
@@ -636,6 +667,16 @@
         buildExtractorStaticData(sd, resp.staticData);
         auto conf = b.initDefaultConfiguration();
         buildConfiguration(conf, resp.defaultConfiguration);
+
+        auto pp = b.initProgramParameters
+            (unsigned(resp.programParameters.programParameters.size()));
+
+        int i = 0;
+        for (auto prog: resp.programParameters.programParameters) {
+            auto pb = pp[i];
+            buildProgramParameterMap(pb, resp.programParameters, prog.first);
+            ++i;
+        }
     }
 
     static void
@@ -648,6 +689,10 @@
         readExtractorStaticData(resp.staticData, r.getStaticData());
         readConfiguration(resp.defaultConfiguration,
                           r.getDefaultConfiguration());
+
+        for (auto pp: r.getProgramParameters()) {
+            readProgramParameterMap(resp.programParameters, pp);
+        }
     }
 
     static void