annotate vamp-client/AutoPlugin.h @ 100:bbb99f94e225

Serialisation, comments
author Chris Cannam <c.cannam@qmul.ac.uk>
date Fri, 14 Oct 2016 12:46:38 +0100
parents f55631599988
children 8c449824e08d
rev   line source
c@98 1
c@98 2 #ifndef PIPER_AUTO_PLUGIN_H
c@98 3 #define PIPER_AUTO_PLUGIN_H
c@98 4
c@98 5 #include "ProcessQtTransport.h"
c@98 6 #include "CapnpRRClient.h"
c@98 7
c@98 8 #include <cstdint>
c@98 9
c@98 10 namespace piper_vamp {
c@98 11 namespace client {
c@98 12
c@98 13 class AutoPlugin : public Vamp::Plugin
c@98 14 {
c@98 15 public:
c@98 16 AutoPlugin(std::string pluginKey,
c@98 17 float inputSampleRate,
c@98 18 int adapterFlags) :
c@98 19 Vamp::Plugin(inputSampleRate),
c@98 20 m_transport("../bin/piper-vamp-server"), //!!!*£*$&"$*"
c@98 21 m_client(&m_transport)
c@98 22 {
c@98 23 LoadRequest req;
c@98 24 req.pluginKey = pluginKey;
c@98 25 req.inputSampleRate = inputSampleRate;
c@98 26 req.adapterFlags = adapterFlags;
c@98 27 LoadResponse resp = m_client.loadPlugin(req);
c@98 28 m_plugin = resp.plugin;
c@98 29 }
c@98 30
c@98 31 virtual ~AutoPlugin() {
c@98 32 delete m_plugin;
c@98 33 }
c@98 34
c@98 35 bool isOK() const {
c@98 36 return (m_plugin != nullptr);
c@98 37 }
c@98 38
c@98 39 virtual std::string getIdentifier() const {
c@98 40 return getPlugin()->getIdentifier();
c@98 41 }
c@98 42
c@98 43 virtual std::string getName() const {
c@98 44 return getPlugin()->getName();
c@98 45 }
c@98 46
c@98 47 virtual std::string getDescription() const {
c@98 48 return getPlugin()->getDescription();
c@98 49 }
c@98 50
c@98 51 virtual std::string getMaker() const {
c@98 52 return getPlugin()->getMaker();
c@98 53 }
c@98 54
c@98 55 virtual std::string getCopyright() const {
c@98 56 return getPlugin()->getCopyright();
c@98 57 }
c@98 58
c@98 59 virtual int getPluginVersion() const {
c@98 60 return getPlugin()->getPluginVersion();
c@98 61 }
c@98 62
c@98 63 virtual ParameterList getParameterDescriptors() const {
c@98 64 return getPlugin()->getParameterDescriptors();
c@98 65 }
c@98 66
c@98 67 virtual float getParameter(std::string name) const {
c@98 68 return getPlugin()->getParameter(name);
c@98 69 }
c@98 70
c@98 71 virtual void setParameter(std::string name, float value) {
c@98 72 getPlugin()->setParameter(name, value);
c@98 73 }
c@98 74
c@98 75 virtual ProgramList getPrograms() const {
c@98 76 return getPlugin()->getPrograms();
c@98 77 }
c@98 78
c@98 79 virtual std::string getCurrentProgram() const {
c@98 80 return getPlugin()->getCurrentProgram();
c@98 81 }
c@98 82
c@98 83 virtual void selectProgram(std::string program) {
c@98 84 getPlugin()->selectProgram(program);
c@98 85 }
c@98 86
c@98 87 virtual bool initialise(size_t inputChannels,
c@98 88 size_t stepSize,
c@98 89 size_t blockSize) {
c@98 90 return getPlugin()->initialise(inputChannels, stepSize, blockSize);
c@98 91 }
c@98 92
c@98 93 virtual void reset() {
c@98 94 getPlugin()->reset();
c@98 95 }
c@98 96
c@98 97 virtual InputDomain getInputDomain() const {
c@98 98 return getPlugin()->getInputDomain();
c@98 99 }
c@98 100
c@98 101 virtual size_t getPreferredBlockSize() const {
c@98 102 return getPlugin()->getPreferredBlockSize();
c@98 103 }
c@98 104
c@98 105 virtual size_t getPreferredStepSize() const {
c@98 106 return getPlugin()->getPreferredStepSize();
c@98 107 }
c@98 108
c@98 109 virtual size_t getMinChannelCount() const {
c@98 110 return getPlugin()->getMinChannelCount();
c@98 111 }
c@98 112
c@98 113 virtual size_t getMaxChannelCount() const {
c@98 114 return getPlugin()->getMaxChannelCount();
c@98 115 }
c@98 116
c@98 117 virtual OutputList getOutputDescriptors() const {
c@98 118 return getPlugin()->getOutputDescriptors();
c@98 119 }
c@98 120
c@98 121 virtual FeatureSet process(const float *const *inputBuffers,
c@98 122 Vamp::RealTime timestamp) {
c@98 123 return getPlugin()->process(inputBuffers, timestamp);
c@98 124 }
c@98 125
c@98 126 virtual FeatureSet getRemainingFeatures() {
c@98 127 return getPlugin()->getRemainingFeatures();
c@98 128 }
c@98 129
c@98 130 private:
c@98 131 ProcessQtTransport m_transport;
c@98 132 CapnpRRClient m_client;
c@98 133 Vamp::Plugin *m_plugin;
c@98 134 Vamp::Plugin *getPlugin() const {
c@98 135 if (!m_plugin) {
c@98 136 throw std::logic_error
c@98 137 ("Plugin load failed (should have called AutoPlugin::isOK)");
c@98 138 }
c@98 139 return m_plugin;
c@98 140 }
c@98 141 };
c@98 142
c@98 143 }
c@98 144 }
c@98 145
c@98 146 #endif
c@98 147
c@98 148