c@41: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@41: c@41: /* c@41: * SimilarityPlugin.h c@41: * c@41: * Copyright 2008 Centre for Digital Music, Queen Mary, University of London. c@135: c@135: This program is free software; you can redistribute it and/or c@135: modify it under the terms of the GNU General Public License as c@135: published by the Free Software Foundation; either version 2 of the c@135: License, or (at your option) any later version. See the file c@135: COPYING included with this distribution for more information. c@41: */ c@41: c@41: #ifndef _SIMILARITY_PLUGIN_H_ c@41: #define _SIMILARITY_PLUGIN_H_ c@41: c@41: #include c@41: #include c@41: c@47: #include c@47: #include c@47: c@41: class MFCC; c@42: class Chromagram; c@41: class Decimator; c@41: c@41: class SimilarityPlugin : public Vamp::Plugin c@41: { c@41: public: c@41: SimilarityPlugin(float inputSampleRate); c@41: virtual ~SimilarityPlugin(); c@41: c@41: bool initialise(size_t channels, size_t stepSize, size_t blockSize); c@41: void reset(); c@41: c@41: std::string getIdentifier() const; c@41: std::string getName() const; c@41: std::string getDescription() const; c@41: std::string getMaker() const; c@41: int getPluginVersion() const; c@41: std::string getCopyright() const; c@41: c@41: size_t getPreferredStepSize() const; c@41: size_t getPreferredBlockSize() const; c@41: InputDomain getInputDomain() const { return TimeDomain; } c@41: c@41: size_t getMinChannelCount() const; c@41: size_t getMaxChannelCount() const; c@41: c@41: SimilarityPlugin::ParameterList getParameterDescriptors() const; c@41: float getParameter(std::string param) const; c@41: void setParameter(std::string param, float value); c@41: c@41: OutputList getOutputDescriptors() const; c@41: c@41: FeatureSet process(const float *const *inputBuffers, Vamp::RealTime timestamp); c@41: c@41: FeatureSet getRemainingFeatures(); c@41: c@41: protected: c@41: int getDecimationFactor() const; c@41: c@42: enum Type { c@42: TypeMFCC, c@42: TypeChroma c@42: }; c@42: c@42: void calculateBlockSize() const; c@47: bool needRhythm() const { return m_rhythmWeighting > m_noRhythm; } c@47: bool needTimbre() const { return m_rhythmWeighting < m_allRhythm; } c@42: c@42: Type m_type; c@41: MFCC *m_mfcc; c@47: MFCC *m_rhythmfcc; c@42: Chromagram *m_chromagram; c@41: Decimator *m_decimator; c@42: int m_featureColumnSize; c@47: float m_rhythmWeighting; c@47: float m_rhythmClipDuration; c@47: float m_rhythmClipOrigin; c@47: int m_rhythmClipFrameSize; c@47: int m_rhythmClipFrames; c@47: int m_rhythmColumnSize; c@178: mutable int m_blockSize; // before decimation c@178: int m_fftSize; // after decimation c@41: int m_channels; c@47: int m_processRate; c@44: int m_frameNo; c@47: bool m_done; c@47: c@47: static const float m_noRhythm; c@47: static const float m_allRhythm; c@44: c@44: std::vector m_lastNonEmptyFrame; // per channel c@60: std::vector m_emptyFrameCount; // per channel c@41: c@43: mutable int m_distanceMatrixOutput; c@43: mutable int m_distanceVectorOutput; c@44: mutable int m_sortedVectorOutput; c@43: mutable int m_meansOutput; c@43: mutable int m_variancesOutput; c@47: mutable int m_beatSpectraOutput; c@43: c@42: typedef std::vector FeatureColumn; c@42: typedef std::vector FeatureMatrix; c@42: typedef std::vector FeatureMatrixSet; c@41: c@47: typedef std::deque FeatureColumnQueue; c@47: typedef std::vector FeatureQueueSet; c@47: c@42: FeatureMatrixSet m_values; c@47: FeatureQueueSet m_rhythmValues; c@47: c@47: FeatureMatrix calculateTimbral(FeatureSet &returnFeatures); c@47: FeatureMatrix calculateRhythmic(FeatureSet &returnFeatures); c@47: double getDistance(const FeatureMatrix &timbral, c@47: const FeatureMatrix &rhythmic, c@47: int i, int j); c@41: }; c@41: c@41: #endif c@41: