cannam@198: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ cannam@198: cannam@198: /* cannam@198: Vamp cannam@198: cannam@198: An API for audio analysis and feature extraction plugins. cannam@198: cannam@198: Centre for Digital Music, Queen Mary, University of London. cannam@198: Copyright 2006-2008 Chris Cannam and QMUL. cannam@198: cannam@198: Permission is hereby granted, free of charge, to any person cannam@198: obtaining a copy of this software and associated documentation cannam@198: files (the "Software"), to deal in the Software without cannam@198: restriction, including without limitation the rights to use, copy, cannam@198: modify, merge, publish, distribute, sublicense, and/or sell copies cannam@198: of the Software, and to permit persons to whom the Software is cannam@198: furnished to do so, subject to the following conditions: cannam@198: cannam@198: The above copyright notice and this permission notice shall be cannam@198: included in all copies or substantial portions of the Software. cannam@198: cannam@198: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, cannam@198: EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF cannam@198: MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND cannam@198: NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR cannam@198: ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF cannam@198: CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION cannam@198: WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. cannam@198: cannam@198: Except as contained in this notice, the names of the Centre for cannam@198: Digital Music; Queen Mary, University of London; and Chris Cannam cannam@198: shall not be used in advertising or otherwise to promote the sale, cannam@198: use or other dealings in this Software without prior written cannam@198: authorization. cannam@198: */ cannam@198: cannam@198: #ifndef _FIXED_TEMPO_ESTIMATOR_PLUGIN_H_ cannam@198: #define _FIXED_TEMPO_ESTIMATOR_PLUGIN_H_ cannam@198: cannam@198: #include "vamp-sdk/Plugin.h" cannam@198: cannam@198: /** cannam@198: * Example plugin that estimates the tempo of a short fixed-tempo sample. cannam@198: */ cannam@198: cannam@198: class FixedTempoEstimator : public Vamp::Plugin cannam@198: { cannam@198: public: cannam@198: FixedTempoEstimator(float inputSampleRate); cannam@198: virtual ~FixedTempoEstimator(); cannam@198: cannam@198: bool initialise(size_t channels, size_t stepSize, size_t blockSize); cannam@198: void reset(); cannam@198: cannam@198: InputDomain getInputDomain() const { return FrequencyDomain; } cannam@198: cannam@198: std::string getIdentifier() const; cannam@198: std::string getName() const; cannam@198: std::string getDescription() const; cannam@198: std::string getMaker() const; cannam@198: int getPluginVersion() const; cannam@198: std::string getCopyright() const; cannam@198: cannam@198: size_t getPreferredStepSize() const; cannam@198: size_t getPreferredBlockSize() const; cannam@198: cannam@198: ParameterList getParameterDescriptors() const; cannam@198: float getParameter(std::string id) const; cannam@198: void setParameter(std::string id, float value); cannam@198: cannam@198: OutputList getOutputDescriptors() const; cannam@198: cannam@198: FeatureSet process(const float *const *inputBuffers, cannam@198: Vamp::RealTime timestamp); cannam@198: cannam@198: FeatureSet getRemainingFeatures(); cannam@198: cannam@198: protected: cannam@200: class D; cannam@200: D *m_d; cannam@200: cannam@198: size_t m_stepSize; cannam@198: size_t m_blockSize; cannam@198: cannam@198: float *m_priorMagnitudes; cannam@198: cannam@198: size_t m_dfsize; cannam@198: float *m_df; cannam@200: float *m_r; cannam@200: float *m_fr; cannam@204: float *m_t; cannam@198: size_t m_n; cannam@198: cannam@198: Vamp::RealTime m_start; cannam@198: Vamp::RealTime m_lasttime; cannam@198: cannam@200: void calculate(); cannam@200: FeatureSet assembleFeatures(); cannam@198: float lag2tempo(int); cannam@207: int tempo2lag(float); cannam@198: }; cannam@198: cannam@198: cannam@198: #endif