qm-dsp  1.8
ClusterMeltSegmenter.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  * ClusterMeltSegmenter.h
5  *
6  * Created by Mark Levy on 23/03/2006.
7  * Copyright 2006 Centre for Digital Music, Queen Mary, University of London.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14  */
15 
16 #include <vector>
17 
18 #include "segment.h"
19 #include "Segmenter.h"
20 #include "hmm/hmm.h"
21 #include "base/Window.h"
22 
23 using std::vector;
24 
25 class Decimator;
26 class ConstantQ;
27 class MFCC;
28 class FFTReal;
29 
31 // defaults are sensible for 11025Hz with 0.2 second hopsize
32 {
33 public:
36  hopSize(0.2),
37  windowSize(0.6),
38  fmin(62),
39  fmax(16000),
40  nbins(8),
41  ncomponents(20),
42  nHMMStates(40),
43  nclusters(10),
44  histogramLength(15),
45  neighbourhoodLimit(20) { }
47  double hopSize; // in secs
48  double windowSize; // in secs
49  int fmin;
50  int fmax;
51  int nbins;
54  int nclusters;
57 };
58 
60 {
61 public:
63  virtual ~ClusterMeltSegmenter();
64  virtual void initialise(int samplerate);
65  virtual int getWindowsize();
66  virtual int getHopsize();
67  virtual void extractFeatures(const double* samples, int nsamples);
68  void setFeatures(const vector<vector<double> >& f); // provide the features yourself
69  virtual void segment(); // segment into default number of segment-types
70  void segment(int m); // segment into m segment-types
71  int getNSegmentTypes() { return nclusters; }
72 
73 protected:
74  void makeSegmentation(int* q, int len);
75 
76  void extractFeaturesConstQ(const double *, int);
77  void extractFeaturesMFCC(const double *, int);
78 
83  model_t* model; // the HMM
84  int* q; // the decoded HMM state sequence
85  vector<vector<double> > histograms;
86 
88  double hopSize; // in seconds
89  double windowSize; // in seconds
90 
91  // constant-Q parameters
92  int fmin;
93  int fmax;
94  int nbins;
95  int ncoeff;
96 
97  // PCA parameters
99 
100  // HMM parameters
102 
103  // clustering parameters
107 
109 };
vector< vector< double > > histograms
feature_types
Definition: segment.h:37
Definition: FFT.h:46
Decimator carries out a fast downsample by a power-of-two factor.
Definition: Decimator.h:24
Window< double > * window
Definition: MFCC.h:35