annotate vamp-test-plugin/vamp-test-plugin.cpp @ 21:ac94242cf562

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