# HG changeset patch # User Chris Cannam # Date 1463570483 -3600 # Node ID c35d0909a74ec890807dc66127ae73cfdbbb71b5 # Parent 1d13354ddc445567efb5045d1a12ba4c2417aecc Process requests diff -r 1d13354ddc44 -r c35d0909a74e capnproto/VampnProto.h --- 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 > &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 ×tamp, + std::vector > &buffers, + const ProcessInput::Reader &b) { + + readRealTime(timestamp, b.getTimestamp()); + buffers.clear(); + for (const auto &v: b.getInputBuffers()) { + std::vector 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 }; } diff -r 1d13354ddc44 -r c35d0909a74e capnproto/vamp.capnp --- 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 {