annotate dsp/segmentation/ClusterMeltSegmenter.h @ 18:8e90a56b4b5f

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