Chris@1: Chris@1: Chris@1:
Chris@1: Chris@3: Chris@1:
Chris@1: VampPluginSDK
Chris@3: 2.4
Chris@1:
Chris@1:
Chris@1: |
Chris@1:
Chris@1:
Chris@1:
Chris@1:
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@1: 00002 Chris@1: 00003 /* Chris@1: 00004 Vamp Chris@1: 00005 Chris@1: 00006 An API for audio analysis and feature extraction plugins. Chris@1: 00007 Chris@1: 00008 Centre for Digital Music, Queen Mary, University of London. Chris@1: 00009 Copyright 2006 Chris Cannam. Chris@1: 00010 Chris@1: 00011 Permission is hereby granted, free of charge, to any person Chris@1: 00012 obtaining a copy of this software and associated documentation Chris@1: 00013 files (the "Software"), to deal in the Software without Chris@1: 00014 restriction, including without limitation the rights to use, copy, Chris@1: 00015 modify, merge, publish, distribute, sublicense, and/or sell copies Chris@1: 00016 of the Software, and to permit persons to whom the Software is Chris@1: 00017 furnished to do so, subject to the following conditions: Chris@1: 00018 Chris@1: 00019 The above copyright notice and this permission notice shall be Chris@1: 00020 included in all copies or substantial portions of the Software. Chris@1: 00021 Chris@1: 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, Chris@1: 00023 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF Chris@1: 00024 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND Chris@1: 00025 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR Chris@1: 00026 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF Chris@1: 00027 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION Chris@1: 00028 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Chris@1: 00029 Chris@1: 00030 Except as contained in this notice, the names of the Centre for Chris@1: 00031 Digital Music; Queen Mary, University of London; and Chris Cannam Chris@1: 00032 shall not be used in advertising or otherwise to promote the sale, Chris@1: 00033 use or other dealings in this Software without prior written Chris@1: 00034 authorization. Chris@1: 00035 */ Chris@1: 00036 Chris@1: 00037 #ifndef _VAMP_SDK_PLUGIN_H_ Chris@1: 00038 #define _VAMP_SDK_PLUGIN_H_ Chris@1: 00039 Chris@1: 00040 #include <string> Chris@1: 00041 #include <vector> Chris@1: 00042 #include <map> Chris@1: 00043 Chris@1: 00044 #include "PluginBase.h" Chris@1: 00045 #include "RealTime.h" Chris@1: 00046 Chris@1: 00047 #include "plugguard.h" Chris@1: 00048 _VAMP_SDK_PLUGSPACE_BEGIN(Plugin.h) Chris@1: 00049 Chris@3: 00050 namespace Vamp { Chris@1: 00051 Chris@1: 00124 class Plugin : public PluginBase Chris@1: 00125 { Chris@1: 00126 public: Chris@1: 00127 virtual ~Plugin() { } Chris@1: 00128 Chris@1: 00141 virtual bool initialise(size_t inputChannels, Chris@1: 00142 size_t stepSize, Chris@1: 00143 size_t blockSize) = 0; Chris@1: 00144 Chris@1: 00150 virtual void reset() = 0; Chris@1: 00151 Chris@1: 00152 enum InputDomain { TimeDomain, FrequencyDomain }; Chris@1: 00153 Chris@1: 00169 virtual InputDomain getInputDomain() const = 0; Chris@1: 00170 Chris@1: 00179 virtual size_t getPreferredBlockSize() const { return 0; } Chris@1: 00180 Chris@1: 00194 virtual size_t getPreferredStepSize() const { return 0; } Chris@1: 00195 Chris@1: 00199 virtual size_t getMinChannelCount() const { return 1; } Chris@1: 00200 Chris@1: 00204 virtual size_t getMaxChannelCount() const { return 1; } Chris@1: 00205 Chris@1: 00206 struct OutputDescriptor Chris@1: 00207 { Chris@1: 00214 std::string identifier; Chris@1: 00215 Chris@1: 00220 std::string name; Chris@1: 00221 Chris@1: 00227 std::string description; Chris@1: 00228 Chris@1: 00232 std::string unit; Chris@1: 00233 Chris@1: 00239 bool hasFixedBinCount; Chris@1: 00240 Chris@1: 00247 size_t binCount; Chris@1: 00248 Chris@1: 00253 std::vector<std::string> binNames; Chris@1: 00254 Chris@1: 00260 bool hasKnownExtents; Chris@1: 00261 Chris@1: 00266 float minValue; Chris@1: 00267 Chris@1: 00272 float maxValue; Chris@1: 00273 Chris@1: 00278 bool isQuantized; Chris@1: 00279 Chris@1: 00285 float quantizeStep; Chris@1: 00286 Chris@1: 00287 enum SampleType { Chris@1: 00288 Chris@1: 00290 OneSamplePerStep, Chris@1: 00291 Chris@1: 00293 FixedSampleRate, Chris@1: 00294 Chris@1: 00296 VariableSampleRate Chris@1: 00297 }; Chris@1: 00298 Chris@1: 00302 SampleType sampleType; Chris@1: 00303 Chris@1: 00314 float sampleRate; Chris@1: 00315 Chris@1: 00320 bool hasDuration; Chris@1: 00321 Chris@1: 00322 OutputDescriptor() : // defaults for mandatory non-class-type members Chris@1: 00323 hasFixedBinCount(false), hasKnownExtents(false), isQuantized(false), Chris@1: 00324 sampleType(OneSamplePerStep), hasDuration(false) { } Chris@1: 00325 }; Chris@1: 00326 Chris@1: 00327 typedef std::vector<OutputDescriptor> OutputList; Chris@1: 00328 Chris@1: 00334 virtual OutputList getOutputDescriptors() const = 0; Chris@1: 00335 Chris@1: 00336 struct Feature Chris@1: 00337 { Chris@1: 00344 bool hasTimestamp; Chris@1: 00345 Chris@1: 00352 RealTime timestamp; Chris@1: 00353 Chris@1: 00360 bool hasDuration; Chris@1: 00361 Chris@1: 00367 RealTime duration; Chris@1: 00368 Chris@1: 00374 std::vector<float> values; Chris@1: 00375 Chris@1: 00379 std::string label; Chris@1: 00380 Chris@1: 00381 Feature() : // defaults for mandatory non-class-type members Chris@1: 00382 hasTimestamp(false), hasDuration(false) { } Chris@1: 00383 }; Chris@1: 00384 Chris@1: 00385 typedef std::vector<Feature> FeatureList; Chris@1: 00386 Chris@1: 00387 typedef std::map<int, FeatureList> FeatureSet; // key is output no Chris@1: 00388 Chris@1: 00416 virtual FeatureSet process(const float *const *inputBuffers, Chris@1: 00417 RealTime timestamp) = 0; Chris@1: 00418 Chris@1: 00423 virtual FeatureSet getRemainingFeatures() = 0; Chris@1: 00424 Chris@1: 00430 virtual std::string getType() const { return "Feature Extraction Plugin"; } Chris@1: 00431 Chris@1: 00432 protected: Chris@1: 00433 Plugin(float inputSampleRate) : Chris@1: 00434 m_inputSampleRate(inputSampleRate) { } Chris@1: 00435 Chris@1: 00436 float m_inputSampleRate; Chris@1: 00437 }; Chris@1: 00438 Chris@1: 00439 } Chris@1: 00440 Chris@1: 00441 _VAMP_SDK_PLUGSPACE_END(Plugin.h) Chris@1: 00442 Chris@1: 00443 #endif Chris@1: 00444 Chris@1: 00445 Chris@1: 00446 Chris@3: