X-Git-Url: https://git.aubio.org/?p=vamp-aubio-plugins.git;a=blobdiff_plain;f=libmain.cpp;h=4da65018065dbbc4f672e9072785cf1453528e0b;hp=007d209de8a65255cdb72780193bf36d01039f6c;hb=0f71f54cb950a29a759efe901d913548a60ffaf6;hpb=340474448bee6047ee27d4d7b80bd9f1477bc810 diff --git a/libmain.cpp b/libmain.cpp index 007d209..4da6501 100644 --- a/libmain.cpp +++ b/libmain.cpp @@ -6,11 +6,20 @@ Centre for Digital Music, Queen Mary, University of London. This file copyright 2006 Chris Cannam. - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. See the file - COPYING included with this distribution for more information. + This file is part of vamp-aubio-plugins. + + vamp-aubio is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + vamp-aubio is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with aubio. If not, see . */ @@ -22,59 +31,33 @@ #include "plugins/Notes.h" #include "plugins/Tempo.h" #include "plugins/Silence.h" - -template -class VersionedPluginAdapter : public Vamp::PluginAdapterBase -{ -public: - VersionedPluginAdapter(unsigned int v) : PluginAdapterBase(), m_v(v) { } - virtual ~VersionedPluginAdapter() { } - -protected: - Vamp::Plugin *createPlugin(float inputSampleRate) { - P *p = new P(inputSampleRate, m_v); - Vamp::Plugin *plugin = dynamic_cast(p); - return plugin; - } - unsigned int m_v; -}; +#include "plugins/Mfcc.h" +#include "plugins/MelEnergy.h" +#include "plugins/SpecDesc.h" static Vamp::PluginAdapter onsetAdapter; static Vamp::PluginAdapter pitchAdapter; +static Vamp::PluginAdapter notesAdapter; static Vamp::PluginAdapter tempoAdapter; - -// These two plugins both benefit from the Vamp v2 API if available -static VersionedPluginAdapter *notesAdapter = 0; -static VersionedPluginAdapter *silenceAdapter = 0; - -struct Tidy -{ - ~Tidy() { delete notesAdapter; delete silenceAdapter; } -}; -static Tidy tidy; +static Vamp::PluginAdapter silenceAdapter; +static Vamp::PluginAdapter mfccAdapter; +static Vamp::PluginAdapter melenergyAdapter; +static Vamp::PluginAdapter specdescAdapter; const VampPluginDescriptor *vampGetPluginDescriptor(unsigned int vampApiVersion, unsigned int index) { - if (vampApiVersion < 1) return 0; + if (vampApiVersion < 2) return 0; switch (index) { case 0: return onsetAdapter.getDescriptor(); case 1: return pitchAdapter.getDescriptor(); + case 2: return notesAdapter.getDescriptor(); case 3: return tempoAdapter.getDescriptor(); - - case 2: - if (!notesAdapter) { - notesAdapter = new VersionedPluginAdapter(vampApiVersion); - } - return notesAdapter->getDescriptor(); - - case 4: - if (!silenceAdapter) { - silenceAdapter = new VersionedPluginAdapter(vampApiVersion); - } - return silenceAdapter->getDescriptor(); - + case 4: return silenceAdapter.getDescriptor(); + case 5: return mfccAdapter.getDescriptor(); + case 6: return melenergyAdapter.getDescriptor(); + case 7: return specdescAdapter.getDescriptor(); default: return 0; } }