annotate examples/vamp-test-plugin/vamp-test-plugin.cpp @ 176:eaf46e7647a0 tip master

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