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