c@243: /* c@243: * ClusterMeltSegmenter.h c@243: * soundbite c@243: * c@243: * Created by Mark Levy on 23/03/2006. c@243: * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. All rights reserved. c@243: * c@243: */ c@243: c@243: #include c@243: c@243: #include "segment.h" c@243: #include "Segmenter.h" c@243: #include "hmm.h" c@243: #include "lib_constQ.h" c@243: c@243: using std::vector; c@243: c@243: class ClusterMeltSegmenterParams // defaults are sensible for 11025Hz with 0.2 second hopsize c@243: { c@243: public: c@243: ClusterMeltSegmenterParams() : featureType(FEATURE_TYPE_CONSTQ), hopSize(0.2), windowSize(0.6), fmin(62), fmax(16000), c@243: nbins(8), ncomponents(20), nHMMStates(40), nclusters(10), histogramLength(15), neighbourhoodLimit(20) { } c@243: feature_types featureType; c@243: double hopSize; // in secs c@243: double windowSize; // in secs c@243: int fmin; c@243: int fmax; c@243: int nbins; c@243: int ncomponents; c@243: int nHMMStates; c@243: int nclusters; c@243: int histogramLength; c@243: int neighbourhoodLimit; c@243: }; c@243: c@243: class ClusterMeltSegmenter : public Segmenter c@243: { c@243: public: c@243: ClusterMeltSegmenter(ClusterMeltSegmenterParams params); c@243: virtual ~ClusterMeltSegmenter(); c@243: virtual void initialise(int samplerate); c@243: virtual int getWindowsize() { return static_cast(windowSize * samplerate); } c@243: virtual int getHopsize() { return static_cast(hopSize * samplerate); } c@243: virtual void extractFeatures(double* samples, int nsamples); c@243: void setFeatures(const vector >& f); // provide the features yourself c@243: virtual void segment(); // segment into default number of segment-types c@243: void segment(int m); // segment into m segment-types c@243: int getNSegmentTypes() { return nclusters; } c@243: protected: c@243: //void mpeg7ConstQ(); c@243: void makeSegmentation(int* q, int len); c@243: c@243: double* window; c@243: int windowLength; // in samples c@243: constQ_t* constq; c@243: model_t* model; // the HMM c@243: //vector stateSequence; c@243: //vector segmentTypeSequence; c@243: int* q; // the decoded HMM state sequence c@243: vector > histograms; c@243: c@243: feature_types featureType; c@243: double hopSize; // in seconds c@243: double windowSize; // in seconds c@243: c@243: // constant-Q parameters c@243: int fmin; c@243: int fmax; c@243: int nbins; c@243: int ncoeff; c@243: c@243: // PCA parameters c@243: int ncomponents; c@243: c@243: // HMM parameters c@243: int nHMMStates; c@243: c@243: // clustering parameters c@243: int nclusters; c@243: int histogramLength; c@243: int neighbourhoodLimit; c@243: };