comparison vamp-test-plugin.cpp @ 20:44826e1782c1

Add Vamp Test Plugin build
author Chris Cannam
date Wed, 14 Sep 2016 17:58:51 +0100
parents
children a734a7e976fa
comparison
equal deleted inserted replaced
19:0e1909abe921 20:44826e1782c1
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 "VamPipeAdapter.h"
32 #include "VamPipePluginLibrary.h"
33
34 #include "VampTestPlugin.h"
35
36 using vampipe::VamPipeAdapter;
37 using vampipe::VamPipeAdapterBase;
38 using vampipe::VamPipePluginLibrary;
39
40 static std::string soname("vamp-test-plugin");
41
42 class Adapter : public VamPipeAdapterBase<VampTestPlugin>
43 {
44 public:
45 Adapter(bool freq) :
46 VamPipeAdapterBase<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 VamPipePluginLibrary library({
61 &timeAdapter,
62 &freqAdapter
63 });
64
65 extern "C" {
66
67 const char *vampipeRequestJson(const char *request) {
68 return library.requestJson(request);
69 }
70
71 const char *vampipeProcessRaw(int pluginHandle,
72 const float *const *inputBuffers,
73 int sec,
74 int nsec) {
75 return library.processRaw(pluginHandle, inputBuffers, sec, nsec);
76 }
77
78 void vampipeFreeJson(const char *json) {
79 return library.freeJson(json);
80 }
81
82 }
83