Mercurial > hg > piper-vamp-js
comparison examples/vamp-test-plugin.cpp @ 48:1ed825597b6f
Move some things around (have not yet updated builds)
author | Chris Cannam |
---|---|
date | Tue, 08 Nov 2016 12:02:57 +0000 |
parents | vamp-test-plugin.cpp@90bf9d9f9c95 |
children | 10d4f117a9a8 |
comparison
equal
deleted
inserted
replaced
47:cedcaa258e22 | 48:1ed825597b6f |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 /* | |
3 Vamp Test Plugin | |
4 Copyright (c) 2013-2016 Queen Mary, University of London | |
5 | |
6 Permission is hereby granted, free of charge, to any person | |
7 obtaining a copy of this software and associated documentation | |
8 files (the "Software"), to deal in the Software without | |
9 restriction, including without limitation the rights to use, copy, | |
10 modify, merge, publish, distribute, sublicense, and/or sell copies | |
11 of the Software, and to permit persons to whom the Software is | |
12 furnished to do so, subject to the following conditions: | |
13 | |
14 The above copyright notice and this permission notice shall be | |
15 included in all copies or substantial portions of the Software. | |
16 | |
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY | |
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | |
22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | |
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | |
24 | |
25 Except as contained in this notice, the names of the Centre for | |
26 Digital Music and Queen Mary, University of London shall not be | |
27 used in advertising or otherwise to promote the sale, use or other | |
28 dealings in this Software without prior written authorization. | |
29 */ | |
30 | |
31 #include "PiperAdapter.h" | |
32 #include "PiperPluginLibrary.h" | |
33 | |
34 #include "VampTestPlugin.h" | |
35 | |
36 using piper::PiperAdapter; | |
37 using piper::PiperAdapterBase; | |
38 using piper::PiperPluginLibrary; | |
39 | |
40 static std::string soname("vamp-test-plugin"); | |
41 | |
42 class Adapter : public PiperAdapterBase<VampTestPlugin> | |
43 { | |
44 public: | |
45 Adapter(bool freq) : | |
46 PiperAdapterBase<VampTestPlugin>(soname), | |
47 m_freq(freq) { } | |
48 | |
49 protected: | |
50 bool m_freq; | |
51 | |
52 Vamp::Plugin *createPlugin(float inputSampleRate) const { | |
53 return new VampTestPlugin(inputSampleRate, m_freq); | |
54 } | |
55 }; | |
56 | |
57 static Adapter timeAdapter(false); | |
58 static Adapter freqAdapter(true); | |
59 | |
60 static PiperPluginLibrary library({ | |
61 &timeAdapter, | |
62 &freqAdapter | |
63 }); | |
64 | |
65 extern "C" { | |
66 | |
67 const char *piperRequestJson(const char *request) { | |
68 return library.requestJson(request); | |
69 } | |
70 | |
71 const char *piperProcessRaw(int handle, | |
72 const float *const *inputBuffers, | |
73 int sec, | |
74 int nsec) { | |
75 return library.processRaw(handle, inputBuffers, sec, nsec); | |
76 } | |
77 | |
78 void piperFreeJson(const char *json) { | |
79 return library.freeJson(json); | |
80 } | |
81 | |
82 } | |
83 |