comparison examples/vamp-test-plugin/vamp-test-plugin.cpp @ 65:4a5295555574

Move examples to their own subdirs, tidy up a bit
author Chris Cannam
date Fri, 11 Nov 2016 17:02:33 +0000
parents examples/vamp-test-plugin.cpp@10d4f117a9a8
children
comparison
equal deleted inserted replaced
64:02efb2bbdaf7 65:4a5295555574
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 "PiperExport.h"
32
33 #include "VampTestPlugin.h"
34
35 using piper_vamp_js::PiperAdapter;
36 using piper_vamp_js::PiperAdapterBase;
37 using piper_vamp_js::PiperPluginLibrary;
38
39 static std::string soname("vamp-test-plugin");
40
41 /*
42 This is an example of a library that exports more than one "plugin"
43 from a single C++ class. The VampTestPlugin class is constructed
44 with an argument that determines whether it is a time- or
45 frequency-domain plugin, and the library offers both.
46
47 Where normally a library that offered two plugins would have two
48 static PiperAdapters specialised with the two plugin classes, here
49 we want two static PiperAdapters specialised with the same class
50 but different constructor arguments. This is one way to do that,
51 taking advantage of the fact that PiperAdapterBase exposes
52 createPlugin as a virtual method.
53
54 Note that a very similar mechanism is used in the standard Vamp
55 version of this plugin library.
56 */
57
58 class Adapter : public PiperAdapterBase<VampTestPlugin>
59 {
60 public:
61 Adapter(bool freq) :
62 PiperAdapterBase<VampTestPlugin>(soname),
63 m_freq(freq) { }
64
65 protected:
66 bool m_freq;
67
68 Vamp::Plugin *createPlugin(float inputSampleRate) const {
69 return new VampTestPlugin(inputSampleRate, m_freq);
70 }
71 };
72
73 static Adapter timeAdapter(false);
74 static Adapter freqAdapter(true);
75
76 static PiperPluginLibrary library({
77 &timeAdapter,
78 &freqAdapter
79 });
80
81 PIPER_EXPORT_LIBRARY(library);
82