c@243: /* c@243: * SavedFeatureSegmenter.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: c@243: using std::vector; c@243: c@243: class SavedFeatureSegmenterParams c@243: { c@243: public: c@243: SavedFeatureSegmenterParams() : hopSize(0.2), windowSize(0.6), c@243: nHMMStates(40), nclusters(10), histogramLength(15), neighbourhoodLimit(20) { } c@243: double hopSize; // in secs c@243: double windowSize; // in secs c@243: int nHMMStates; c@243: int nclusters; c@243: int histogramLength; c@243: int neighbourhoodLimit; c@243: }; c@243: c@243: class SavedFeatureSegmenter : public Segmenter c@243: { c@243: public: c@243: SavedFeatureSegmenter(SavedFeatureSegmenterParams params); c@243: virtual ~SavedFeatureSegmenter(); 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 makeSegmentation(int* q, int len); c@243: c@243: model_t* model; // the HMM c@243: int* q; // the decoded HMM state sequence c@243: vector > histograms; c@243: c@243: double hopSize; // in seconds c@243: double windowSize; // in seconds 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: };