comparison capnproto/VampnProto.h @ 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
comparison
equal deleted inserted replaced
13:1d13354ddc44 14:c35d0909a74e
543 Vamp::Plugin::OutputDescriptor desc; 543 Vamp::Plugin::OutputDescriptor desc;
544 readOutputDescriptor(desc, o); 544 readOutputDescriptor(desc, o);
545 cr.outputs.push_back(desc); 545 cr.outputs.push_back(desc);
546 } 546 }
547 } 547 }
548
549 static void
550 buildProcessInput(ProcessInput::Builder &b,
551 Vamp::RealTime timestamp,
552 const std::vector<std::vector<float> > &buffers) {
553
554 auto t = b.initTimestamp();
555 buildRealTime(t, timestamp);
556 auto vv = b.initInputBuffers(buffers.size());
557 for (size_t ch = 0; ch < buffers.size(); ++ch) {
558 const int n = int(buffers[ch].size());
559 vv.init(ch, n);
560 auto v = vv[ch];
561 for (int i = 0; i < n; ++i) {
562 v.set(i, buffers[ch][i]);
563 }
564 }
565 }
566
567 static void
568 readProcessInput(Vamp::RealTime &timestamp,
569 std::vector<std::vector<float> > &buffers,
570 const ProcessInput::Reader &b) {
571
572 readRealTime(timestamp, b.getTimestamp());
573 buffers.clear();
574 for (const auto &v: b.getInputBuffers()) {
575 std::vector<float> buf;
576 for (auto x: v) {
577 buf.push_back(x);
578 }
579 buffers.push_back(buf);
580 }
581 }
582
583 static void
584 buildProcessRequest(ProcessRequest::Builder &b,
585 const Vamp::HostExt::ProcessRequest &pr,
586 PluginHandleMapper &mapper) {
587
588 b.setPluginHandle(mapper.pluginToHandle(pr.plugin));
589 auto input = b.initInput();
590 buildProcessInput(input, pr.timestamp, pr.inputBuffers);
591 }
592
593 static void
594 readProcessRequest(Vamp::HostExt::ProcessRequest &pr,
595 const ProcessRequest::Reader &r,
596 PluginHandleMapper &mapper) {
597
598 auto h = r.getPluginHandle();
599 pr.plugin = mapper.handleToPlugin(h);
600 readProcessInput(pr.timestamp, pr.inputBuffers, r.getInput());
601 }
602
603 static void
604 buildVampListRequest(VampRequest::Builder &b) {
605 b.getRequest().setList();
606 }
607
608 static void
609 buildVampLoadRequest(VampRequest::Builder &b,
610 const Vamp::HostExt::LoadRequest &req) {
611 auto u = b.getRequest().initLoad();
612 buildLoadRequest(u, req);
613 }
614
615 static void
616 buildVampConfigureRequest(VampRequest::Builder &b,
617 const Vamp::HostExt::ConfigurationRequest &cr,
618 PluginHandleMapper &mapper) {
619 auto u = b.getRequest().initConfigure();
620 buildConfigurationRequest(u, cr, mapper);
621 }
622
623 static void
624 buildVampProcessRequest(VampRequest::Builder &b,
625 const Vamp::HostExt::ProcessRequest &pr,
626 PluginHandleMapper &mapper) {
627 auto u = b.getRequest().initProcess();
628 buildProcessRequest(u, pr, mapper);
629 }
630
631
632 //...!!! and responses
548 }; 633 };
549 634
550 } 635 }
551 636
552 637