annotate dsp/segmentation/ClusterMeltSegmenter.h @ 20:8bdbda7fb893

* First cut at properly integrating the segmenter and making it work right
author cannam
date Wed, 09 Jan 2008 16:50:04 +0000
parents 8e90a56b4b5f
children 2b74bd60c61f
rev   line source
cannam@18 1 /*
cannam@18 2 * ClusterMeltSegmenter.h
cannam@18 3 * soundbite
cannam@18 4 *
cannam@18 5 * Created by Mark Levy on 23/03/2006.
cannam@18 6 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. All rights reserved.
cannam@18 7 *
cannam@18 8 */
cannam@18 9
cannam@18 10 #include <vector>
cannam@18 11
cannam@18 12 #include "segment.h"
cannam@18 13 #include "Segmenter.h"
cannam@20 14 #include "hmm/hmm.h"
cannam@20 15 #include "base/Window.h"
cannam@20 16 #include "dsp/chromagram/ConstantQ.h"
cannam@18 17
cannam@18 18 using std::vector;
cannam@18 19
cannam@18 20 class ClusterMeltSegmenterParams // defaults are sensible for 11025Hz with 0.2 second hopsize
cannam@18 21 {
cannam@18 22 public:
cannam@18 23 ClusterMeltSegmenterParams() : featureType(FEATURE_TYPE_CONSTQ), hopSize(0.2), windowSize(0.6), fmin(62), fmax(16000),
cannam@18 24 nbins(8), ncomponents(20), nHMMStates(40), nclusters(10), histogramLength(15), neighbourhoodLimit(20) { }
cannam@18 25 feature_types featureType;
cannam@18 26 double hopSize; // in secs
cannam@18 27 double windowSize; // in secs
cannam@18 28 int fmin;
cannam@18 29 int fmax;
cannam@18 30 int nbins;
cannam@18 31 int ncomponents;
cannam@18 32 int nHMMStates;
cannam@18 33 int nclusters;
cannam@18 34 int histogramLength;
cannam@18 35 int neighbourhoodLimit;
cannam@18 36 };
cannam@18 37
cannam@18 38 class ClusterMeltSegmenter : public Segmenter
cannam@18 39 {
cannam@18 40 public:
cannam@18 41 ClusterMeltSegmenter(ClusterMeltSegmenterParams params);
cannam@18 42 virtual ~ClusterMeltSegmenter();
cannam@18 43 virtual void initialise(int samplerate);
cannam@20 44 virtual int getWindowsize();
cannam@20 45 virtual int getHopsize();
cannam@18 46 virtual void extractFeatures(double* samples, int nsamples);
cannam@18 47 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
cannam@18 48 virtual void segment(); // segment into default number of segment-types
cannam@18 49 void segment(int m); // segment into m segment-types
cannam@18 50 int getNSegmentTypes() { return nclusters; }
cannam@18 51 protected:
cannam@18 52 //void mpeg7ConstQ();
cannam@18 53 void makeSegmentation(int* q, int len);
cannam@18 54
cannam@20 55 Window<double> *window;
cannam@20 56 // int windowLength; // in samples
cannam@20 57 ConstantQ* constq;
cannam@18 58 model_t* model; // the HMM
cannam@18 59 //vector<int> stateSequence;
cannam@18 60 //vector<int> segmentTypeSequence;
cannam@18 61 int* q; // the decoded HMM state sequence
cannam@18 62 vector<vector<double> > histograms;
cannam@18 63
cannam@18 64 feature_types featureType;
cannam@18 65 double hopSize; // in seconds
cannam@18 66 double windowSize; // in seconds
cannam@18 67
cannam@18 68 // constant-Q parameters
cannam@18 69 int fmin;
cannam@18 70 int fmax;
cannam@18 71 int nbins;
cannam@18 72 int ncoeff;
cannam@18 73
cannam@18 74 // PCA parameters
cannam@18 75 int ncomponents;
cannam@18 76
cannam@18 77 // HMM parameters
cannam@18 78 int nHMMStates;
cannam@18 79
cannam@18 80 // clustering parameters
cannam@18 81 int nclusters;
cannam@18 82 int histogramLength;
cannam@18 83 int neighbourhoodLimit;
cannam@18 84 };