cannam@21: cannam@21:
cannam@21:00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@21: 00002 cannam@21: 00003 /* cannam@21: 00004 Vamp cannam@21: 00005 cannam@21: 00006 An API for audio analysis and feature extraction plugins. cannam@21: 00007 cannam@21: 00008 Centre for Digital Music, Queen Mary, University of London. cannam@21: 00009 Copyright 2006 Chris Cannam. cannam@21: 00010 cannam@21: 00011 Permission is hereby granted, free of charge, to any person cannam@21: 00012 obtaining a copy of this software and associated documentation cannam@21: 00013 files (the "Software"), to deal in the Software without cannam@21: 00014 restriction, including without limitation the rights to use, copy, cannam@21: 00015 modify, merge, publish, distribute, sublicense, and/or sell copies cannam@21: 00016 of the Software, and to permit persons to whom the Software is cannam@21: 00017 furnished to do so, subject to the following conditions: cannam@21: 00018 cannam@21: 00019 The above copyright notice and this permission notice shall be cannam@21: 00020 included in all copies or substantial portions of the Software. cannam@21: 00021 cannam@21: 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, cannam@21: 00023 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF cannam@21: 00024 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND cannam@21: 00025 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR cannam@21: 00026 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF cannam@21: 00027 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION cannam@21: 00028 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cannam@21: 00029 cannam@21: 00030 Except as contained in this notice, the names of the Centre for cannam@21: 00031 Digital Music; Queen Mary, University of London; and Chris Cannam cannam@21: 00032 shall not be used in advertising or otherwise to promote the sale, cannam@21: 00033 use or other dealings in this Software without prior written cannam@21: 00034 authorization. cannam@21: 00035 */ cannam@21: 00036 cannam@21: 00037 #ifndef _VAMP_SDK_PLUGIN_H_ cannam@21: 00038 #define _VAMP_SDK_PLUGIN_H_ cannam@21: 00039 cannam@21: 00040 #include <string> cannam@21: 00041 #include <vector> cannam@21: 00042 #include <map> cannam@21: 00043 cannam@21: 00044 #include "PluginBase.h" cannam@21: 00045 #include "RealTime.h" cannam@21: 00046 cannam@21: 00047 #include "plugguard.h" cannam@21: 00048 _VAMP_SDK_PLUGSPACE_BEGIN(Plugin.h) cannam@21: 00049 cannam@21: 00050 namespace Vamp { cannam@21: 00051 cannam@21: 00124 class Plugin : public PluginBase cannam@21: 00125 { cannam@21: 00126 public: cannam@21: 00127 virtual ~Plugin() { } cannam@21: 00128 cannam@21: 00141 virtual bool initialise(size_t inputChannels, cannam@21: 00142 size_t stepSize, cannam@21: 00143 size_t blockSize) = 0; cannam@21: 00144 cannam@21: 00150 virtual void reset() = 0; cannam@21: 00151 cannam@21: 00152 enum InputDomain { TimeDomain, FrequencyDomain }; cannam@21: 00153 cannam@21: 00164 virtual InputDomain getInputDomain() const = 0; cannam@21: 00165 cannam@21: 00174 virtual size_t getPreferredBlockSize() const { return 0; } cannam@21: 00175 cannam@21: 00189 virtual size_t getPreferredStepSize() const { return 0; } cannam@21: 00190 cannam@21: 00194 virtual size_t getMinChannelCount() const { return 1; } cannam@21: 00195 cannam@21: 00199 virtual size_t getMaxChannelCount() const { return 1; } cannam@21: 00200 cannam@21: 00201 struct OutputDescriptor cannam@21: 00202 { cannam@21: 00209 std::string identifier; cannam@21: 00210 cannam@21: 00215 std::string name; cannam@21: 00216 cannam@21: 00222 std::string description; cannam@21: 00223 cannam@21: 00227 std::string unit; cannam@21: 00228 cannam@21: 00234 bool hasFixedBinCount; cannam@21: 00235 cannam@21: 00242 size_t binCount; cannam@21: 00243 cannam@21: 00248 std::vector<std::string> binNames; cannam@21: 00249 cannam@21: 00255 bool hasKnownExtents; cannam@21: 00256 cannam@21: 00261 float minValue; cannam@21: 00262 cannam@21: 00267 float maxValue; cannam@21: 00268 cannam@21: 00273 bool isQuantized; cannam@21: 00274 cannam@21: 00280 float quantizeStep; cannam@21: 00281 cannam@21: 00282 enum SampleType { cannam@21: 00283 cannam@21: 00285 OneSamplePerStep, cannam@21: 00286 cannam@21: 00288 FixedSampleRate, cannam@21: 00289 cannam@21: 00291 VariableSampleRate cannam@21: 00292 }; cannam@21: 00293 cannam@21: 00297 SampleType sampleType; cannam@21: 00298 cannam@21: 00309 float sampleRate; cannam@21: 00310 cannam@21: 00315 bool hasDuration; cannam@21: 00316 cannam@21: 00317 OutputDescriptor() : // defaults for mandatory non-class-type members cannam@21: 00318 hasFixedBinCount(false), hasKnownExtents(false), isQuantized(false), cannam@21: 00319 sampleType(OneSamplePerStep), hasDuration(false) { } cannam@21: 00320 }; cannam@21: 00321 cannam@21: 00322 typedef std::vector<OutputDescriptor> OutputList; cannam@21: 00323 cannam@21: 00329 virtual OutputList getOutputDescriptors() const = 0; cannam@21: 00330 cannam@21: 00331 struct Feature cannam@21: 00332 { cannam@21: 00339 bool hasTimestamp; cannam@21: 00340 cannam@21: 00347 RealTime timestamp; cannam@21: 00348 cannam@21: 00355 bool hasDuration; cannam@21: 00356 cannam@21: 00362 RealTime duration; cannam@21: 00363 cannam@21: 00369 std::vector<float> values; cannam@21: 00370 cannam@21: 00374 std::string label; cannam@21: 00375 cannam@21: 00376 Feature() : // defaults for mandatory non-class-type members cannam@21: 00377 hasTimestamp(false), hasDuration(false) { } cannam@21: 00378 }; cannam@21: 00379 cannam@21: 00380 typedef std::vector<Feature> FeatureList; cannam@21: 00381 cannam@21: 00382 typedef std::map<int, FeatureList> FeatureSet; // key is output no cannam@21: 00383 cannam@21: 00411 virtual FeatureSet process(const float *const *inputBuffers, cannam@21: 00412 RealTime timestamp) = 0; cannam@21: 00413 cannam@21: 00418 virtual FeatureSet getRemainingFeatures() = 0; cannam@21: 00419 cannam@21: 00425 virtual std::string getType() const { return "Feature Extraction Plugin"; } cannam@21: 00426 cannam@21: 00427 protected: cannam@21: 00428 Plugin(float inputSampleRate) : cannam@21: 00429 m_inputSampleRate(inputSampleRate) { } cannam@21: 00430 cannam@21: 00431 float m_inputSampleRate; cannam@21: 00432 }; cannam@21: 00433 cannam@21: 00434 } cannam@21: 00435 cannam@21: 00436 _VAMP_SDK_PLUGSPACE_END(Plugin.h) cannam@21: 00437 cannam@21: 00438 #endif cannam@21: 00439 cannam@21: 00440 cannam@21: 00441 cannam@21: