annotate dsp/segmentation/ClusterMeltSegmenter.h @ 243:dc30e3864ceb

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