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