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