annotate dsp/segmentation/ClusterMeltSegmenter.h @ 24:2b74bd60c61f

* Various fixes to segmentation code
author cannam
date Thu, 10 Jan 2008 15:14:53 +0000
parents 8bdbda7fb893
children d096a79fa772
rev   line source
cannam@24 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@24 2
cannam@18 3 /*
cannam@24 4 * ClusterMeltSegmenter.h
cannam@18 5 *
cannam@24 6 * Created by Mark Levy on 23/03/2006.
cannam@24 7 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London.
cannam@24 8 * All rights reserved.
cannam@18 9 */
cannam@18 10
cannam@18 11 #include <vector>
cannam@18 12
cannam@18 13 #include "segment.h"
cannam@18 14 #include "Segmenter.h"
cannam@20 15 #include "hmm/hmm.h"
cannam@20 16 #include "base/Window.h"
cannam@18 17
cannam@18 18 using std::vector;
cannam@18 19
cannam@24 20 class Decimator;
cannam@24 21 class ConstantQ;
cannam@24 22
cannam@24 23 class ClusterMeltSegmenterParams
cannam@24 24 // defaults are sensible for 11025Hz with 0.2 second hopsize
cannam@18 25 {
cannam@18 26 public:
cannam@24 27 ClusterMeltSegmenterParams() :
cannam@24 28 featureType(FEATURE_TYPE_CONSTQ),
cannam@24 29 hopSize(0.2),
cannam@24 30 windowSize(0.6),
cannam@24 31 fmin(62),
cannam@24 32 fmax(16000),
cannam@24 33 nbins(8),
cannam@24 34 ncomponents(20),
cannam@24 35 nHMMStates(40),
cannam@24 36 nclusters(10),
cannam@24 37 histogramLength(15),
cannam@24 38 neighbourhoodLimit(20) { }
cannam@24 39 feature_types featureType;
cannam@24 40 double hopSize; // in secs
cannam@24 41 double windowSize; // in secs
cannam@24 42 int fmin;
cannam@24 43 int fmax;
cannam@24 44 int nbins;
cannam@24 45 int ncomponents;
cannam@24 46 int nHMMStates;
cannam@24 47 int nclusters;
cannam@24 48 int histogramLength;
cannam@24 49 int neighbourhoodLimit;
cannam@18 50 };
cannam@18 51
cannam@18 52 class ClusterMeltSegmenter : public Segmenter
cannam@18 53 {
cannam@18 54 public:
cannam@24 55 ClusterMeltSegmenter(ClusterMeltSegmenterParams params);
cannam@24 56 virtual ~ClusterMeltSegmenter();
cannam@24 57 virtual void initialise(int samplerate);
cannam@24 58 virtual int getWindowsize();
cannam@24 59 virtual int getHopsize();
cannam@24 60 virtual void extractFeatures(const double* samples, int nsamples);
cannam@24 61 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
cannam@24 62 virtual void segment(); // segment into default number of segment-types
cannam@24 63 void segment(int m); // segment into m segment-types
cannam@24 64 int getNSegmentTypes() { return nclusters; }
cannam@24 65
cannam@18 66 protected:
cannam@24 67 void makeSegmentation(int* q, int len);
cannam@18 68
cannam@24 69 Window<double> *window;
cannam@24 70 ConstantQ* constq;
cannam@24 71 model_t* model; // the HMM
cannam@24 72 int* q; // the decoded HMM state sequence
cannam@24 73 vector<vector<double> > histograms;
cannam@24 74
cannam@24 75 feature_types featureType;
cannam@24 76 double hopSize; // in seconds
cannam@24 77 double windowSize; // in seconds
cannam@24 78
cannam@24 79 // constant-Q parameters
cannam@24 80 int fmin;
cannam@24 81 int fmax;
cannam@24 82 int nbins;
cannam@24 83 int ncoeff;
cannam@24 84
cannam@24 85 // PCA parameters
cannam@24 86 int ncomponents;
cannam@24 87
cannam@24 88 // HMM parameters
cannam@24 89 int nHMMStates;
cannam@24 90
cannam@24 91 // clustering parameters
cannam@24 92 int nclusters;
cannam@24 93 int histogramLength;
cannam@24 94 int neighbourhoodLimit;
cannam@24 95
cannam@24 96 Decimator *decimator;
cannam@18 97 };