c@40: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@40: /* c@40: Vamp Test Plugin c@48: Copyright (c) 2013-2017 Queen Mary, University of London c@40: c@40: Permission is hereby granted, free of charge, to any person c@40: obtaining a copy of this software and associated documentation c@40: files (the "Software"), to deal in the Software without c@40: restriction, including without limitation the rights to use, copy, c@40: modify, merge, publish, distribute, sublicense, and/or sell copies c@40: of the Software, and to permit persons to whom the Software is c@40: furnished to do so, subject to the following conditions: c@40: c@40: The above copyright notice and this permission notice shall be c@40: included in all copies or substantial portions of the Software. c@40: c@40: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, c@40: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF c@40: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND c@40: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY c@40: CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF c@40: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION c@40: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. c@40: c@40: Except as contained in this notice, the names of the Centre for c@40: Digital Music and Queen Mary, University of London shall not be c@40: used in advertising or otherwise to promote the sale, use or other c@40: dealings in this Software without prior written authorization. c@40: */ c@40: c@40: #include "PiperExport.h" c@40: c@40: #include "VampTestPlugin.h" c@40: c@40: using piper_vamp_js::PiperAdapter; c@40: using piper_vamp_js::PiperAdapterBase; c@40: using piper_vamp_js::PiperPluginLibrary; c@40: c@48: static std::string libname("vamp-test-plugin"); c@40: c@40: /* c@40: This is an example of a library that exports more than one "plugin" c@40: from a single C++ class. The VampTestPlugin class is constructed c@40: with an argument that determines whether it is a time- or c@40: frequency-domain plugin, and the library offers both. c@40: c@40: Where normally a library that offered two plugins would have two c@40: static PiperAdapters specialised with the two plugin classes, here c@40: we want two static PiperAdapters specialised with the same class c@40: but different constructor arguments. This is one way to do that, c@40: taking advantage of the fact that PiperAdapterBase exposes c@40: createPlugin as a virtual method. c@40: c@40: Note that a very similar mechanism is used in the standard Vamp c@40: version of this plugin library. c@40: */ c@40: c@40: class Adapter : public PiperAdapterBase c@40: { c@40: public: c@40: Adapter(bool freq) : c@48: PiperAdapterBase(libname, { "Development" }), c@40: m_freq(freq) { } c@40: c@40: protected: c@40: bool m_freq; c@40: c@40: Vamp::Plugin *createPlugin(float inputSampleRate) const { c@40: return new VampTestPlugin(inputSampleRate, m_freq); c@40: } c@40: }; c@40: c@40: static Adapter timeAdapter(false); c@40: static Adapter freqAdapter(true); c@40: c@40: static PiperPluginLibrary library({ c@40: &timeAdapter, c@40: &freqAdapter c@40: }); c@40: c@40: PIPER_EXPORT_LIBRARY(library); c@40: