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
23using std::vector;
24
25class Decimator;
26class ConstantQ;
27class MFCC;
28class FFTReal;
29
31// defaults are sensible for 11025Hz with 0.2 second hopsize
32{
33public:
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),
45 neighbourhoodLimit(20) { }
47 double hopSize; // in secs
48 double windowSize; // in secs
49 int fmin;
50 int fmax;
51 int nbins;
57};
58
60{
61public:
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
73protected:
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};
virtual void extractFeatures(const double *samples, int nsamples)
virtual void initialise(int samplerate)
void extractFeaturesMFCC(const double *, int)
vector< vector< double > > histograms
void setFeatures(const vector< vector< double > > &f)
void extractFeaturesConstQ(const double *, int)
void makeSegmentation(int *q, int len)
Window< double > * window
Decimator carries out a fast downsample by a power-of-two factor.
Definition Decimator.h:25
Definition FFT.h:47
Definition MFCC.h:36
int samplerate
Definition Segmenter.h:59
Various shaped windows for sample frame conditioning, including cosine windows (Hann etc) and triangu...
Definition Window.h:41
feature_types
Definition segment.h:38
@ FEATURE_TYPE_CONSTQ
Definition segment.h:40