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@249
|
26 class Decimator;
|
c@249
|
27 class ConstantQ;
|
c@251
|
28 class MFCC;
|
c@289
|
29 class FFTReal;
|
c@249
|
30
|
c@249
|
31 class ClusterMeltSegmenterParams
|
c@249
|
32 // defaults are sensible for 11025Hz with 0.2 second hopsize
|
c@243
|
33 {
|
c@243
|
34 public:
|
c@249
|
35 ClusterMeltSegmenterParams() :
|
c@249
|
36 featureType(FEATURE_TYPE_CONSTQ),
|
c@249
|
37 hopSize(0.2),
|
c@249
|
38 windowSize(0.6),
|
c@249
|
39 fmin(62),
|
c@249
|
40 fmax(16000),
|
c@249
|
41 nbins(8),
|
c@249
|
42 ncomponents(20),
|
cannam@480
|
43 nHMMStates(40),
|
c@249
|
44 nclusters(10),
|
c@249
|
45 histogramLength(15),
|
c@249
|
46 neighbourhoodLimit(20) { }
|
c@249
|
47 feature_types featureType;
|
cannam@480
|
48 double hopSize; // in secs
|
cannam@480
|
49 double windowSize; // in secs
|
c@249
|
50 int fmin;
|
c@249
|
51 int fmax;
|
c@249
|
52 int nbins;
|
c@249
|
53 int ncomponents;
|
c@249
|
54 int nHMMStates;
|
c@249
|
55 int nclusters;
|
c@249
|
56 int histogramLength;
|
c@249
|
57 int neighbourhoodLimit;
|
c@243
|
58 };
|
c@243
|
59
|
c@243
|
60 class ClusterMeltSegmenter : public Segmenter
|
c@243
|
61 {
|
c@243
|
62 public:
|
c@249
|
63 ClusterMeltSegmenter(ClusterMeltSegmenterParams params);
|
c@249
|
64 virtual ~ClusterMeltSegmenter();
|
c@249
|
65 virtual void initialise(int samplerate);
|
c@249
|
66 virtual int getWindowsize();
|
c@249
|
67 virtual int getHopsize();
|
c@249
|
68 virtual void extractFeatures(const double* samples, int nsamples);
|
cannam@493
|
69 void setFeatures(const std::vector<std::vector<double> >& f); // provide the features yourself
|
cannam@480
|
70 virtual void segment(); // segment into default number of segment-types
|
cannam@480
|
71 void segment(int m); // segment into m segment-types
|
c@249
|
72 int getNSegmentTypes() { return nclusters; }
|
c@249
|
73
|
c@243
|
74 protected:
|
c@249
|
75 void makeSegmentation(int* q, int len);
|
cannam@480
|
76
|
c@251
|
77 void extractFeaturesConstQ(const double *, int);
|
c@251
|
78 void extractFeaturesMFCC(const double *, int);
|
c@251
|
79
|
c@249
|
80 Window<double> *window;
|
c@289
|
81 FFTReal *fft;
|
c@251
|
82 ConstantQ* constq;
|
c@251
|
83 MFCC* mfcc;
|
cannam@480
|
84 model_t* model; // the HMM
|
cannam@480
|
85 int* q; // the decoded HMM state sequence
|
cannam@493
|
86 std::vector<std::vector<double> > histograms;
|
c@249
|
87
|
cannam@480
|
88 feature_types featureType;
|
cannam@480
|
89 double hopSize; // in seconds
|
cannam@480
|
90 double windowSize; // in seconds
|
c@249
|
91
|
c@249
|
92 // constant-Q parameters
|
c@249
|
93 int fmin;
|
c@249
|
94 int fmax;
|
c@249
|
95 int nbins;
|
c@249
|
96 int ncoeff;
|
c@249
|
97
|
c@249
|
98 // PCA parameters
|
c@249
|
99 int ncomponents;
|
c@249
|
100
|
c@249
|
101 // HMM parameters
|
c@249
|
102 int nHMMStates;
|
c@249
|
103
|
c@249
|
104 // clustering parameters
|
c@249
|
105 int nclusters;
|
c@249
|
106 int histogramLength;
|
c@249
|
107 int neighbourhoodLimit;
|
c@249
|
108
|
c@249
|
109 Decimator *decimator;
|
c@243
|
110 };
|
cannam@491
|
111
|
cannam@491
|
112 #endif
|