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@35: 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@35: 00169 virtual InputDomain getInputDomain() const = 0; cannam@35: 00170 cannam@35: 00179 virtual size_t getPreferredBlockSize() const { return 0; } cannam@35: 00180 cannam@35: 00194 virtual size_t getPreferredStepSize() const { return 0; } cannam@21: 00195 cannam@35: 00199 virtual size_t getMinChannelCount() const { return 1; } cannam@21: 00200 cannam@35: 00204 virtual size_t getMaxChannelCount() const { return 1; } cannam@35: 00205 cannam@35: 00206 struct OutputDescriptor cannam@35: 00207 { cannam@35: 00214 std::string identifier; cannam@35: 00215 cannam@35: 00220 std::string name; cannam@35: 00221 cannam@35: 00227 std::string description; cannam@21: 00228 cannam@35: 00232 std::string unit; cannam@35: 00233 cannam@35: 00239 bool hasFixedBinCount; cannam@35: 00240 cannam@35: 00247 size_t binCount; cannam@35: 00248 cannam@35: 00253 std::vector<std::string> binNames; cannam@35: 00254 cannam@35: 00260 bool hasKnownExtents; cannam@35: 00261 cannam@35: 00266 float minValue; cannam@35: 00267 cannam@35: 00272 float maxValue; cannam@35: 00273 cannam@35: 00278 bool isQuantized; cannam@35: 00279 cannam@35: 00285 float quantizeStep; cannam@21: 00286 cannam@35: 00287 enum SampleType { cannam@35: 00288 cannam@35: 00290 OneSamplePerStep, cannam@35: 00291 cannam@35: 00293 FixedSampleRate, cannam@35: 00294 cannam@35: 00296 VariableSampleRate cannam@35: 00297 }; cannam@21: 00298 cannam@35: 00302 SampleType sampleType; cannam@35: 00303 cannam@35: 00314 float sampleRate; cannam@35: 00315 cannam@35: 00320 bool hasDuration; cannam@21: 00321 cannam@35: 00322 OutputDescriptor() : // defaults for mandatory non-class-type members cannam@35: 00323 hasFixedBinCount(false), hasKnownExtents(false), isQuantized(false), cannam@35: 00324 sampleType(OneSamplePerStep), hasDuration(false) { } cannam@35: 00325 }; cannam@35: 00326 cannam@35: 00327 typedef std::vector<OutputDescriptor> OutputList; cannam@35: 00328 cannam@35: 00334 virtual OutputList getOutputDescriptors() const = 0; cannam@35: 00335 cannam@35: 00336 struct Feature cannam@35: 00337 { cannam@35: 00344 bool hasTimestamp; cannam@35: 00345 cannam@35: 00352 RealTime timestamp; cannam@35: 00353 cannam@35: 00360 bool hasDuration; cannam@35: 00361 cannam@35: 00367 RealTime duration; cannam@35: 00368 cannam@35: 00374 std::vector<float> values; cannam@21: 00375 cannam@35: 00379 std::string label; cannam@35: 00380 cannam@35: 00381 Feature() : // defaults for mandatory non-class-type members cannam@35: 00382 hasTimestamp(false), hasDuration(false) { } cannam@35: 00383 }; cannam@35: 00384 cannam@35: 00385 typedef std::vector<Feature> FeatureList; cannam@35: 00386 cannam@35: 00387 typedef std::map<int, FeatureList> FeatureSet; // key is output no cannam@35: 00388 cannam@35: 00416 virtual FeatureSet process(const float *const *inputBuffers, cannam@35: 00417 RealTime timestamp) = 0; cannam@35: 00418 cannam@35: 00423 virtual FeatureSet getRemainingFeatures() = 0; cannam@35: 00424 cannam@35: 00430 virtual std::string getType() const { return "Feature Extraction Plugin"; } cannam@35: 00431 cannam@35: 00432 protected: cannam@35: 00433 Plugin(float inputSampleRate) : cannam@35: 00434 m_inputSampleRate(inputSampleRate) { } cannam@21: 00435 cannam@35: 00436 float m_inputSampleRate; cannam@35: 00437 }; cannam@35: 00438 cannam@35: 00439 } cannam@21: 00440 cannam@35: 00441 _VAMP_SDK_PLUGSPACE_END(Plugin.h) cannam@35: 00442 cannam@35: 00443 #endif cannam@35: 00444 cannam@35: 00445 cannam@35: 00446 cannam@21: