cannam@0: cannam@0:
cannam@0:00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@0: 00002 cannam@0: 00003 /* cannam@0: 00004 Vamp cannam@0: 00005 cannam@0: 00006 An API for audio analysis and feature extraction plugins. cannam@0: 00007 cannam@0: 00008 Centre for Digital Music, Queen Mary, University of London. cannam@0: 00009 Copyright 2006 Chris Cannam. cannam@0: 00010 cannam@0: 00011 Permission is hereby granted, free of charge, to any person cannam@0: 00012 obtaining a copy of this software and associated documentation cannam@0: 00013 files (the "Software"), to deal in the Software without cannam@0: 00014 restriction, including without limitation the rights to use, copy, cannam@0: 00015 modify, merge, publish, distribute, sublicense, and/or sell copies cannam@0: 00016 of the Software, and to permit persons to whom the Software is cannam@0: 00017 furnished to do so, subject to the following conditions: cannam@0: 00018 cannam@0: 00019 The above copyright notice and this permission notice shall be cannam@0: 00020 included in all copies or substantial portions of the Software. cannam@0: 00021 cannam@0: 00022 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, cannam@0: 00023 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF cannam@0: 00024 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND cannam@0: 00025 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR cannam@0: 00026 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF cannam@0: 00027 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION cannam@0: 00028 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cannam@0: 00029 cannam@0: 00030 Except as contained in this notice, the names of the Centre for cannam@0: 00031 Digital Music; Queen Mary, University of London; and Chris Cannam cannam@0: 00032 shall not be used in advertising or otherwise to promote the sale, cannam@0: 00033 use or other dealings in this Software without prior written cannam@0: 00034 authorization. cannam@0: 00035 */ cannam@0: 00036 cannam@0: 00037 #ifndef _VAMP_PLUGIN_H_ cannam@0: 00038 #define _VAMP_PLUGIN_H_ cannam@0: 00039 cannam@0: 00040 #include "PluginBase.h" cannam@0: 00041 #include "RealTime.h" cannam@0: 00042 cannam@0: 00043 #include <string> cannam@0: 00044 #include <vector> cannam@0: 00045 #include <map> cannam@0: 00046 cannam@0: 00047 namespace Vamp { cannam@0: 00048 cannam@0: 00121 class Plugin : public PluginBase cannam@0: 00122 { cannam@0: 00123 public: cannam@0: 00124 virtual ~Plugin() { } cannam@0: 00125 cannam@0: 00138 virtual bool initialise(size_t inputChannels, cannam@0: 00139 size_t stepSize, cannam@0: 00140 size_t blockSize) = 0; cannam@0: 00141 cannam@0: 00147 virtual void reset() = 0; cannam@0: 00148 cannam@0: 00149 enum InputDomain { TimeDomain, FrequencyDomain }; cannam@0: 00150 cannam@0: 00161 virtual InputDomain getInputDomain() const = 0; cannam@0: 00162 cannam@0: 00171 virtual size_t getPreferredBlockSize() const { return 0; } cannam@0: 00172 cannam@0: 00186 virtual size_t getPreferredStepSize() const { return 0; } cannam@0: 00187 cannam@0: 00191 virtual size_t getMinChannelCount() const { return 1; } cannam@0: 00192 cannam@0: 00196 virtual size_t getMaxChannelCount() const { return 1; } cannam@0: 00197 cannam@0: 00198 struct OutputDescriptor cannam@0: 00199 { cannam@0: 00206 std::string identifier; cannam@0: 00207 cannam@0: 00212 std::string name; cannam@0: 00213 cannam@0: 00219 std::string description; cannam@0: 00220 cannam@0: 00224 std::string unit; cannam@0: 00225 cannam@0: 00231 bool hasFixedBinCount; cannam@0: 00232 cannam@0: 00239 size_t binCount; cannam@0: 00240 cannam@0: 00245 std::vector<std::string> binNames; cannam@0: 00246 cannam@0: 00252 bool hasKnownExtents; cannam@0: 00253 cannam@0: 00258 float minValue; cannam@0: 00259 cannam@0: 00264 float maxValue; cannam@0: 00265 cannam@0: 00270 bool isQuantized; cannam@0: 00271 cannam@0: 00277 float quantizeStep; cannam@0: 00278 cannam@0: 00279 enum SampleType { cannam@0: 00280 cannam@0: 00282 OneSamplePerStep, cannam@0: 00283 cannam@0: 00285 FixedSampleRate, cannam@0: 00286 cannam@0: 00288 VariableSampleRate cannam@0: 00289 }; cannam@0: 00290 cannam@0: 00294 SampleType sampleType; cannam@0: 00295 cannam@0: 00306 float sampleRate; cannam@0: 00307 }; cannam@0: 00308 cannam@0: 00309 typedef std::vector<OutputDescriptor> OutputList; cannam@0: 00310 cannam@0: 00316 virtual OutputList getOutputDescriptors() const = 0; cannam@0: 00317 cannam@0: 00318 struct Feature cannam@0: 00319 { cannam@0: 00325 bool hasTimestamp; cannam@0: 00326 cannam@0: 00332 RealTime timestamp; cannam@0: 00333 cannam@0: 00339 std::vector<float> values; cannam@0: 00340 cannam@0: 00344 std::string label; cannam@0: 00345 }; cannam@0: 00346 cannam@0: 00347 typedef std::vector<Feature> FeatureList; cannam@0: 00348 typedef std::map<int, FeatureList> FeatureSet; // key is output no cannam@0: 00349 cannam@0: 00377 virtual FeatureSet process(const float *const *inputBuffers, cannam@0: 00378 RealTime timestamp) = 0; cannam@0: 00379 cannam@0: 00384 virtual FeatureSet getRemainingFeatures() = 0; cannam@0: 00385 cannam@0: 00391 virtual std::string getType() const { return "Feature Extraction Plugin"; } cannam@0: 00392 cannam@0: 00393 protected: cannam@0: 00394 Plugin(float inputSampleRate) : cannam@0: 00395 m_inputSampleRate(inputSampleRate) { } cannam@0: 00396 cannam@0: 00397 float m_inputSampleRate; cannam@0: 00398 }; cannam@0: 00399 cannam@0: 00400 } cannam@0: 00401 cannam@0: 00402 #endif cannam@0: 00403 cannam@0: 00404 cannam@0: 00405 cannam@0: