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