c@40
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
c@40
|
2 /*
|
c@40
|
3 Vamp Test Plugin
|
c@48
|
4 Copyright (c) 2013-2017 Queen Mary, University of London
|
c@40
|
5
|
c@40
|
6 Permission is hereby granted, free of charge, to any person
|
c@40
|
7 obtaining a copy of this software and associated documentation
|
c@40
|
8 files (the "Software"), to deal in the Software without
|
c@40
|
9 restriction, including without limitation the rights to use, copy,
|
c@40
|
10 modify, merge, publish, distribute, sublicense, and/or sell copies
|
c@40
|
11 of the Software, and to permit persons to whom the Software is
|
c@40
|
12 furnished to do so, subject to the following conditions:
|
c@40
|
13
|
c@40
|
14 The above copyright notice and this permission notice shall be
|
c@40
|
15 included in all copies or substantial portions of the Software.
|
c@40
|
16
|
c@40
|
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
c@40
|
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
c@40
|
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
c@40
|
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
c@40
|
21 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
|
c@40
|
22 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
c@40
|
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
c@40
|
24
|
c@40
|
25 Except as contained in this notice, the names of the Centre for
|
c@40
|
26 Digital Music and Queen Mary, University of London shall not be
|
c@40
|
27 used in advertising or otherwise to promote the sale, use or other
|
c@40
|
28 dealings in this Software without prior written authorization.
|
c@40
|
29 */
|
c@40
|
30
|
c@40
|
31 #include "PiperExport.h"
|
c@40
|
32
|
c@40
|
33 #include "VampTestPlugin.h"
|
c@40
|
34
|
c@40
|
35 using piper_vamp_js::PiperAdapter;
|
c@40
|
36 using piper_vamp_js::PiperAdapterBase;
|
c@40
|
37 using piper_vamp_js::PiperPluginLibrary;
|
c@40
|
38
|
c@48
|
39 static std::string libname("vamp-test-plugin");
|
c@40
|
40
|
c@40
|
41 /*
|
c@40
|
42 This is an example of a library that exports more than one "plugin"
|
c@40
|
43 from a single C++ class. The VampTestPlugin class is constructed
|
c@40
|
44 with an argument that determines whether it is a time- or
|
c@40
|
45 frequency-domain plugin, and the library offers both.
|
c@40
|
46
|
c@40
|
47 Where normally a library that offered two plugins would have two
|
c@40
|
48 static PiperAdapters specialised with the two plugin classes, here
|
c@40
|
49 we want two static PiperAdapters specialised with the same class
|
c@40
|
50 but different constructor arguments. This is one way to do that,
|
c@40
|
51 taking advantage of the fact that PiperAdapterBase exposes
|
c@40
|
52 createPlugin as a virtual method.
|
c@40
|
53
|
c@40
|
54 Note that a very similar mechanism is used in the standard Vamp
|
c@40
|
55 version of this plugin library.
|
c@40
|
56 */
|
c@40
|
57
|
c@40
|
58 class Adapter : public PiperAdapterBase<VampTestPlugin>
|
c@40
|
59 {
|
c@40
|
60 public:
|
c@40
|
61 Adapter(bool freq) :
|
c@48
|
62 PiperAdapterBase<VampTestPlugin>(libname, { "Development" }),
|
c@40
|
63 m_freq(freq) { }
|
c@40
|
64
|
c@40
|
65 protected:
|
c@40
|
66 bool m_freq;
|
c@40
|
67
|
c@40
|
68 Vamp::Plugin *createPlugin(float inputSampleRate) const {
|
c@40
|
69 return new VampTestPlugin(inputSampleRate, m_freq);
|
c@40
|
70 }
|
c@40
|
71 };
|
c@40
|
72
|
c@40
|
73 static Adapter timeAdapter(false);
|
c@40
|
74 static Adapter freqAdapter(true);
|
c@40
|
75
|
c@40
|
76 static PiperPluginLibrary library({
|
c@40
|
77 &timeAdapter,
|
c@40
|
78 &freqAdapter
|
c@40
|
79 });
|
c@40
|
80
|
c@40
|
81 PIPER_EXPORT_LIBRARY(library);
|
c@40
|
82
|