c@117
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@117
|
2
|
c@117
|
3 /*
|
c@117
|
4 Piper Vamp JSON Adapter
|
c@117
|
5
|
c@117
|
6 Centre for Digital Music, Queen Mary, University of London.
|
c@117
|
7 Copyright 2015-2016 QMUL.
|
c@117
|
8
|
c@117
|
9 Permission is hereby granted, free of charge, to any person
|
c@117
|
10 obtaining a copy of this software and associated documentation
|
c@117
|
11 files (the "Software"), to deal in the Software without
|
c@117
|
12 restriction, including without limitation the rights to use, copy,
|
c@117
|
13 modify, merge, publish, distribute, sublicense, and/or sell copies
|
c@117
|
14 of the Software, and to permit persons to whom the Software is
|
c@117
|
15 furnished to do so, subject to the following conditions:
|
c@117
|
16
|
c@117
|
17 The above copyright notice and this permission notice shall be
|
c@117
|
18 included in all copies or substantial portions of the Software.
|
c@117
|
19
|
c@117
|
20 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
c@117
|
21 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
c@117
|
22 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
c@117
|
23 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
|
c@117
|
24 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
c@117
|
25 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
c@117
|
26 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
c@117
|
27
|
c@117
|
28 Except as contained in this notice, the names of the Centre for
|
c@117
|
29 Digital Music; Queen Mary, University of London; and Chris Cannam
|
c@117
|
30 shall not be used in advertising or otherwise to promote the sale,
|
c@117
|
31 use or other dealings in this Software without prior written
|
c@117
|
32 authorization.
|
c@117
|
33 */
|
c@117
|
34
|
c@117
|
35 #ifndef PIPER_PLUGIN_LIBRARY_H
|
c@117
|
36 #define PIPER_PLUGIN_LIBRARY_H
|
c@117
|
37
|
c@117
|
38 #include "vamp-support/CountingPluginHandleMapper.h"
|
c@117
|
39 #include "vamp-support/PluginStaticData.h"
|
c@117
|
40 #include "vamp-support/RequestResponse.h"
|
c@117
|
41
|
c@117
|
42 #include <vector>
|
c@117
|
43 #include <string>
|
c@117
|
44 #include <cstring>
|
c@117
|
45
|
c@117
|
46 namespace piper_vamp_js {
|
c@117
|
47
|
c@117
|
48 class PiperAdapterInterface;
|
c@117
|
49
|
c@117
|
50 class PiperPluginLibrary
|
c@117
|
51 {
|
c@117
|
52 public:
|
c@117
|
53 PiperPluginLibrary(std::vector<PiperAdapterInterface *> pp);
|
c@117
|
54
|
c@117
|
55 const char *requestJson(const char *request) {
|
c@117
|
56 return strdup(requestJsonImpl(request).c_str());
|
c@117
|
57 }
|
c@117
|
58
|
c@117
|
59 const char *processRaw(int handle, const float *const *inputBuffers,
|
c@117
|
60 int sec, int nsec) {
|
c@117
|
61 return strdup(processRawImpl(handle, inputBuffers, sec, nsec).c_str());
|
c@117
|
62 }
|
c@117
|
63
|
c@117
|
64 void freeJson(const char *json) {
|
c@117
|
65 free(const_cast<char *>(json));
|
c@117
|
66 }
|
c@117
|
67
|
c@117
|
68 private:
|
c@117
|
69 std::string requestJsonImpl(std::string req);
|
c@117
|
70 std::string processRawImpl(int, const float *const *, int, int);
|
c@117
|
71
|
c@117
|
72 piper_vamp::ListResponse listPluginData(piper_vamp::ListRequest r) const;
|
c@117
|
73 piper_vamp::LoadResponse loadPlugin(piper_vamp::LoadRequest r,
|
c@117
|
74 std::string &err) const;
|
cannam@152
|
75 piper_vamp::ConfigurationResponse
|
cannam@152
|
76 configurePlugin(piper_vamp::ConfigurationRequest r,
|
cannam@152
|
77 const piper_vamp::PluginStaticData &psd,
|
cannam@152
|
78 std::string &err)
|
c@117
|
79 const;
|
c@117
|
80
|
c@117
|
81 // map from pluginKey -> adapter
|
c@117
|
82 std::map<std::string, PiperAdapterInterface *> m_adapters;
|
cannam@152
|
83
|
cannam@155
|
84 // map from plugin handle -> plugin static data. Added to when a
|
cannam@155
|
85 // plugin is loaded, removed from when finish() is called.
|
cannam@152
|
86 std::map<piper_vamp::PluginHandleMapper::Handle,
|
cannam@152
|
87 piper_vamp::PluginStaticData> m_pluginStaticData;
|
cannam@152
|
88
|
c@117
|
89 piper_vamp::CountingPluginHandleMapper m_mapper;
|
c@117
|
90 bool m_useBase64;
|
c@117
|
91 };
|
c@117
|
92
|
c@117
|
93 }
|
c@117
|
94
|
c@117
|
95 #endif
|