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@309
|
8
|
c@309
|
9 This program is free software; you can redistribute it and/or
|
c@309
|
10 modify it under the terms of the GNU General Public License as
|
c@309
|
11 published by the Free Software Foundation; either version 2 of the
|
c@309
|
12 License, or (at your option) any later version. See the file
|
c@309
|
13 COPYING included with this distribution for more information.
|
c@243
|
14 */
|
c@243
|
15
|
cannam@491
|
16 #ifndef QM_DSP_CLUSTER_MELT_SEGMENTER_H
|
cannam@491
|
17 #define QM_DSP_CLUSTER_MELT_SEGMENTER_H
|
cannam@491
|
18
|
c@243
|
19 #include <vector>
|
c@243
|
20
|
c@243
|
21 #include "segment.h"
|
c@243
|
22 #include "Segmenter.h"
|
c@245
|
23 #include "hmm/hmm.h"
|
c@245
|
24 #include "base/Window.h"
|
c@243
|
25
|
c@243
|
26 using std::vector;
|
c@243
|
27
|
c@249
|
28 class Decimator;
|
c@249
|
29 class ConstantQ;
|
c@251
|
30 class MFCC;
|
c@289
|
31 class FFTReal;
|
c@249
|
32
|
c@249
|
33 class ClusterMeltSegmenterParams
|
c@249
|
34 // defaults are sensible for 11025Hz with 0.2 second hopsize
|
c@243
|
35 {
|
c@243
|
36 public:
|
c@249
|
37 ClusterMeltSegmenterParams() :
|
c@249
|
38 featureType(FEATURE_TYPE_CONSTQ),
|
c@249
|
39 hopSize(0.2),
|
c@249
|
40 windowSize(0.6),
|
c@249
|
41 fmin(62),
|
c@249
|
42 fmax(16000),
|
c@249
|
43 nbins(8),
|
c@249
|
44 ncomponents(20),
|
cannam@480
|
45 nHMMStates(40),
|
c@249
|
46 nclusters(10),
|
c@249
|
47 histogramLength(15),
|
c@249
|
48 neighbourhoodLimit(20) { }
|
c@249
|
49 feature_types featureType;
|
cannam@480
|
50 double hopSize; // in secs
|
cannam@480
|
51 double windowSize; // in secs
|
c@249
|
52 int fmin;
|
c@249
|
53 int fmax;
|
c@249
|
54 int nbins;
|
c@249
|
55 int ncomponents;
|
c@249
|
56 int nHMMStates;
|
c@249
|
57 int nclusters;
|
c@249
|
58 int histogramLength;
|
c@249
|
59 int neighbourhoodLimit;
|
c@243
|
60 };
|
c@243
|
61
|
c@243
|
62 class ClusterMeltSegmenter : public Segmenter
|
c@243
|
63 {
|
c@243
|
64 public:
|
c@249
|
65 ClusterMeltSegmenter(ClusterMeltSegmenterParams params);
|
c@249
|
66 virtual ~ClusterMeltSegmenter();
|
c@249
|
67 virtual void initialise(int samplerate);
|
c@249
|
68 virtual int getWindowsize();
|
c@249
|
69 virtual int getHopsize();
|
c@249
|
70 virtual void extractFeatures(const double* samples, int nsamples);
|
cannam@480
|
71 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
|
cannam@480
|
72 virtual void segment(); // segment into default number of segment-types
|
cannam@480
|
73 void segment(int m); // segment into m segment-types
|
c@249
|
74 int getNSegmentTypes() { return nclusters; }
|
c@249
|
75
|
c@243
|
76 protected:
|
c@249
|
77 void makeSegmentation(int* q, int len);
|
cannam@480
|
78
|
c@251
|
79 void extractFeaturesConstQ(const double *, int);
|
c@251
|
80 void extractFeaturesMFCC(const double *, int);
|
c@251
|
81
|
c@249
|
82 Window<double> *window;
|
c@289
|
83 FFTReal *fft;
|
c@251
|
84 ConstantQ* constq;
|
c@251
|
85 MFCC* mfcc;
|
cannam@480
|
86 model_t* model; // the HMM
|
cannam@480
|
87 int* q; // the decoded HMM state sequence
|
cannam@480
|
88 vector<vector<double> > histograms;
|
c@249
|
89
|
cannam@480
|
90 feature_types featureType;
|
cannam@480
|
91 double hopSize; // in seconds
|
cannam@480
|
92 double windowSize; // in seconds
|
c@249
|
93
|
c@249
|
94 // constant-Q parameters
|
c@249
|
95 int fmin;
|
c@249
|
96 int fmax;
|
c@249
|
97 int nbins;
|
c@249
|
98 int ncoeff;
|
c@249
|
99
|
c@249
|
100 // PCA parameters
|
c@249
|
101 int ncomponents;
|
c@249
|
102
|
c@249
|
103 // HMM parameters
|
c@249
|
104 int nHMMStates;
|
c@249
|
105
|
c@249
|
106 // clustering parameters
|
c@249
|
107 int nclusters;
|
c@249
|
108 int histogramLength;
|
c@249
|
109 int neighbourhoodLimit;
|
c@249
|
110
|
c@249
|
111 Decimator *decimator;
|
c@243
|
112 };
|
cannam@491
|
113
|
cannam@491
|
114 #endif
|