c@249: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@249: c@243: /* c@249: * ClusterMeltSegmenter.h c@243: * c@249: * Created by Mark Levy on 23/03/2006. c@249: * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. c@249: * All rights reserved. c@243: */ c@243: c@243: #include c@243: c@243: #include "segment.h" c@243: #include "Segmenter.h" c@245: #include "hmm/hmm.h" c@245: #include "base/Window.h" c@243: c@243: using std::vector; c@243: c@249: class Decimator; c@249: class ConstantQ; c@251: class MFCC; c@249: c@249: class ClusterMeltSegmenterParams c@249: // defaults are sensible for 11025Hz with 0.2 second hopsize c@243: { c@243: public: c@249: ClusterMeltSegmenterParams() : c@249: featureType(FEATURE_TYPE_CONSTQ), c@249: hopSize(0.2), c@249: windowSize(0.6), c@249: fmin(62), c@249: fmax(16000), c@249: nbins(8), c@249: ncomponents(20), c@249: nHMMStates(40), c@249: nclusters(10), c@249: histogramLength(15), c@249: neighbourhoodLimit(20) { } c@249: feature_types featureType; c@249: double hopSize; // in secs c@249: double windowSize; // in secs c@249: int fmin; c@249: int fmax; c@249: int nbins; c@249: int ncomponents; c@249: int nHMMStates; c@249: int nclusters; c@249: int histogramLength; c@249: int neighbourhoodLimit; c@243: }; c@243: c@243: class ClusterMeltSegmenter : public Segmenter c@243: { c@243: public: c@249: ClusterMeltSegmenter(ClusterMeltSegmenterParams params); c@249: virtual ~ClusterMeltSegmenter(); c@249: virtual void initialise(int samplerate); c@249: virtual int getWindowsize(); c@249: virtual int getHopsize(); c@249: virtual void extractFeatures(const double* samples, int nsamples); c@249: void setFeatures(const vector >& f); // provide the features yourself c@249: virtual void segment(); // segment into default number of segment-types c@249: void segment(int m); // segment into m segment-types c@249: int getNSegmentTypes() { return nclusters; } c@249: c@243: protected: c@249: void makeSegmentation(int* q, int len); c@243: c@251: void extractFeaturesConstQ(const double *, int); c@251: void extractFeaturesMFCC(const double *, int); c@251: c@249: Window *window; c@251: ConstantQ* constq; c@251: MFCC* mfcc; c@249: model_t* model; // the HMM c@249: int* q; // the decoded HMM state sequence c@249: vector > histograms; c@249: c@249: feature_types featureType; c@249: double hopSize; // in seconds c@249: double windowSize; // in seconds c@249: c@249: // constant-Q parameters c@249: int fmin; c@249: int fmax; c@249: int nbins; c@249: int ncoeff; c@249: c@249: // PCA parameters c@249: int ncomponents; c@249: c@249: // HMM parameters c@249: int nHMMStates; c@249: c@249: // clustering parameters c@249: int nclusters; c@249: int histogramLength; c@249: int neighbourhoodLimit; c@249: c@249: Decimator *decimator; c@243: };