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