comparison dsp/segmentation/SavedFeatureSegmenter.h @ 18:8e90a56b4b5f

* merge in segmentation code from soundbite plugin/library repository
author cannam
date Wed, 09 Jan 2008 10:46:25 +0000
parents
children 8bdbda7fb893
comparison
equal deleted inserted replaced
17:a120ac7b26b2 18:8e90a56b4b5f
1 /*
2 * SavedFeatureSegmenter.h
3 * soundbite
4 *
5 * Created by Mark Levy on 23/03/2006.
6 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. All rights reserved.
7 *
8 */
9
10 #include <vector>
11
12 #include "segment.h"
13 #include "Segmenter.h"
14 #include "hmm.h"
15
16 using std::vector;
17
18 class SavedFeatureSegmenterParams
19 {
20 public:
21 SavedFeatureSegmenterParams() : hopSize(0.2), windowSize(0.6),
22 nHMMStates(40), nclusters(10), histogramLength(15), neighbourhoodLimit(20) { }
23 double hopSize; // in secs
24 double windowSize; // in secs
25 int nHMMStates;
26 int nclusters;
27 int histogramLength;
28 int neighbourhoodLimit;
29 };
30
31 class SavedFeatureSegmenter : public Segmenter
32 {
33 public:
34 SavedFeatureSegmenter(SavedFeatureSegmenterParams params);
35 virtual ~SavedFeatureSegmenter();
36 virtual void initialise(int samplerate);
37 virtual int getWindowsize() { return static_cast<int>(windowSize * samplerate); }
38 virtual int getHopsize() { return static_cast<int>(hopSize * samplerate); }
39 virtual void extractFeatures(double* samples, int nsamples) { }
40 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
41 virtual void segment(); // segment into default number of segment-types
42 void segment(int m); // segment into m segment-types
43 int getNSegmentTypes() { return nclusters; }
44 protected:
45 void makeSegmentation(int* q, int len);
46
47 model_t* model; // the HMM
48 int* q; // the decoded HMM state sequence
49 vector<vector<double> > histograms;
50
51 double hopSize; // in seconds
52 double windowSize; // in seconds
53
54 // HMM parameters
55 int nHMMStates;
56
57 // clustering parameters
58 int nclusters;
59 int histogramLength;
60 int neighbourhoodLimit;
61 };