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@101
|
16 AutoPlugin(std::string serverName,
|
c@101
|
17 std::string pluginKey,
|
c@98
|
18 float inputSampleRate,
|
c@98
|
19 int adapterFlags) :
|
c@98
|
20 Vamp::Plugin(inputSampleRate),
|
c@101
|
21 m_transport(serverName),
|
c@98
|
22 m_client(&m_transport)
|
c@98
|
23 {
|
c@98
|
24 LoadRequest req;
|
c@98
|
25 req.pluginKey = pluginKey;
|
c@98
|
26 req.inputSampleRate = inputSampleRate;
|
c@98
|
27 req.adapterFlags = adapterFlags;
|
c@98
|
28 LoadResponse resp = m_client.loadPlugin(req);
|
c@98
|
29 m_plugin = resp.plugin;
|
c@98
|
30 }
|
c@98
|
31
|
c@98
|
32 virtual ~AutoPlugin() {
|
c@98
|
33 delete m_plugin;
|
c@98
|
34 }
|
c@98
|
35
|
c@98
|
36 bool isOK() const {
|
c@98
|
37 return (m_plugin != nullptr);
|
c@98
|
38 }
|
c@98
|
39
|
c@98
|
40 virtual std::string getIdentifier() const {
|
c@98
|
41 return getPlugin()->getIdentifier();
|
c@98
|
42 }
|
c@98
|
43
|
c@98
|
44 virtual std::string getName() const {
|
c@98
|
45 return getPlugin()->getName();
|
c@98
|
46 }
|
c@98
|
47
|
c@98
|
48 virtual std::string getDescription() const {
|
c@98
|
49 return getPlugin()->getDescription();
|
c@98
|
50 }
|
c@98
|
51
|
c@98
|
52 virtual std::string getMaker() const {
|
c@98
|
53 return getPlugin()->getMaker();
|
c@98
|
54 }
|
c@98
|
55
|
c@98
|
56 virtual std::string getCopyright() const {
|
c@98
|
57 return getPlugin()->getCopyright();
|
c@98
|
58 }
|
c@98
|
59
|
c@98
|
60 virtual int getPluginVersion() const {
|
c@98
|
61 return getPlugin()->getPluginVersion();
|
c@98
|
62 }
|
c@98
|
63
|
c@98
|
64 virtual ParameterList getParameterDescriptors() const {
|
c@98
|
65 return getPlugin()->getParameterDescriptors();
|
c@98
|
66 }
|
c@98
|
67
|
c@98
|
68 virtual float getParameter(std::string name) const {
|
c@98
|
69 return getPlugin()->getParameter(name);
|
c@98
|
70 }
|
c@98
|
71
|
c@98
|
72 virtual void setParameter(std::string name, float value) {
|
c@98
|
73 getPlugin()->setParameter(name, value);
|
c@98
|
74 }
|
c@98
|
75
|
c@98
|
76 virtual ProgramList getPrograms() const {
|
c@98
|
77 return getPlugin()->getPrograms();
|
c@98
|
78 }
|
c@98
|
79
|
c@98
|
80 virtual std::string getCurrentProgram() const {
|
c@98
|
81 return getPlugin()->getCurrentProgram();
|
c@98
|
82 }
|
c@98
|
83
|
c@98
|
84 virtual void selectProgram(std::string program) {
|
c@98
|
85 getPlugin()->selectProgram(program);
|
c@98
|
86 }
|
c@98
|
87
|
c@98
|
88 virtual bool initialise(size_t inputChannels,
|
c@98
|
89 size_t stepSize,
|
c@98
|
90 size_t blockSize) {
|
c@98
|
91 return getPlugin()->initialise(inputChannels, stepSize, blockSize);
|
c@98
|
92 }
|
c@98
|
93
|
c@98
|
94 virtual void reset() {
|
c@98
|
95 getPlugin()->reset();
|
c@98
|
96 }
|
c@98
|
97
|
c@98
|
98 virtual InputDomain getInputDomain() const {
|
c@98
|
99 return getPlugin()->getInputDomain();
|
c@98
|
100 }
|
c@98
|
101
|
c@98
|
102 virtual size_t getPreferredBlockSize() const {
|
c@98
|
103 return getPlugin()->getPreferredBlockSize();
|
c@98
|
104 }
|
c@98
|
105
|
c@98
|
106 virtual size_t getPreferredStepSize() const {
|
c@98
|
107 return getPlugin()->getPreferredStepSize();
|
c@98
|
108 }
|
c@98
|
109
|
c@98
|
110 virtual size_t getMinChannelCount() const {
|
c@98
|
111 return getPlugin()->getMinChannelCount();
|
c@98
|
112 }
|
c@98
|
113
|
c@98
|
114 virtual size_t getMaxChannelCount() const {
|
c@98
|
115 return getPlugin()->getMaxChannelCount();
|
c@98
|
116 }
|
c@98
|
117
|
c@98
|
118 virtual OutputList getOutputDescriptors() const {
|
c@98
|
119 return getPlugin()->getOutputDescriptors();
|
c@98
|
120 }
|
c@98
|
121
|
c@98
|
122 virtual FeatureSet process(const float *const *inputBuffers,
|
c@98
|
123 Vamp::RealTime timestamp) {
|
c@98
|
124 return getPlugin()->process(inputBuffers, timestamp);
|
c@98
|
125 }
|
c@98
|
126
|
c@98
|
127 virtual FeatureSet getRemainingFeatures() {
|
c@98
|
128 return getPlugin()->getRemainingFeatures();
|
c@98
|
129 }
|
c@98
|
130
|
c@98
|
131 private:
|
c@98
|
132 ProcessQtTransport m_transport;
|
c@98
|
133 CapnpRRClient m_client;
|
c@98
|
134 Vamp::Plugin *m_plugin;
|
c@98
|
135 Vamp::Plugin *getPlugin() const {
|
c@98
|
136 if (!m_plugin) {
|
c@98
|
137 throw std::logic_error
|
c@98
|
138 ("Plugin load failed (should have called AutoPlugin::isOK)");
|
c@98
|
139 }
|
c@98
|
140 return m_plugin;
|
c@98
|
141 }
|
c@98
|
142 };
|
c@98
|
143
|
c@98
|
144 }
|
c@98
|
145 }
|
c@98
|
146
|
c@98
|
147 #endif
|
c@98
|
148
|
c@98
|
149
|