annotate dsp/segmentation/ClusterMeltSegmenter.h @ 58:d72fcd34d9a7

* Fixes to problems shown up by vamp-plugin-tester. Still not all plugins pass all tests, though
author cannam
date Mon, 23 Mar 2009 16:28:53 +0000
parents d096a79fa772
children 6cb2b3cd5356
rev   line source
cannam@24 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
cannam@24 2
cannam@18 3 /*
cannam@24 4 * ClusterMeltSegmenter.h
cannam@18 5 *
cannam@24 6 * Created by Mark Levy on 23/03/2006.
cannam@24 7 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London.
cannam@24 8 * All rights reserved.
cannam@18 9 */
cannam@18 10
cannam@18 11 #include <vector>
cannam@18 12
cannam@18 13 #include "segment.h"
cannam@18 14 #include "Segmenter.h"
cannam@20 15 #include "hmm/hmm.h"
cannam@20 16 #include "base/Window.h"
cannam@18 17
cannam@18 18 using std::vector;
cannam@18 19
cannam@24 20 class Decimator;
cannam@24 21 class ConstantQ;
cannam@26 22 class MFCC;
cannam@24 23
cannam@24 24 class ClusterMeltSegmenterParams
cannam@24 25 // defaults are sensible for 11025Hz with 0.2 second hopsize
cannam@18 26 {
cannam@18 27 public:
cannam@24 28 ClusterMeltSegmenterParams() :
cannam@24 29 featureType(FEATURE_TYPE_CONSTQ),
cannam@24 30 hopSize(0.2),
cannam@24 31 windowSize(0.6),
cannam@24 32 fmin(62),
cannam@24 33 fmax(16000),
cannam@24 34 nbins(8),
cannam@24 35 ncomponents(20),
cannam@24 36 nHMMStates(40),
cannam@24 37 nclusters(10),
cannam@24 38 histogramLength(15),
cannam@24 39 neighbourhoodLimit(20) { }
cannam@24 40 feature_types featureType;
cannam@24 41 double hopSize; // in secs
cannam@24 42 double windowSize; // in secs
cannam@24 43 int fmin;
cannam@24 44 int fmax;
cannam@24 45 int nbins;
cannam@24 46 int ncomponents;
cannam@24 47 int nHMMStates;
cannam@24 48 int nclusters;
cannam@24 49 int histogramLength;
cannam@24 50 int neighbourhoodLimit;
cannam@18 51 };
cannam@18 52
cannam@18 53 class ClusterMeltSegmenter : public Segmenter
cannam@18 54 {
cannam@18 55 public:
cannam@24 56 ClusterMeltSegmenter(ClusterMeltSegmenterParams params);
cannam@24 57 virtual ~ClusterMeltSegmenter();
cannam@24 58 virtual void initialise(int samplerate);
cannam@24 59 virtual int getWindowsize();
cannam@24 60 virtual int getHopsize();
cannam@24 61 virtual void extractFeatures(const double* samples, int nsamples);
cannam@24 62 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
cannam@24 63 virtual void segment(); // segment into default number of segment-types
cannam@24 64 void segment(int m); // segment into m segment-types
cannam@24 65 int getNSegmentTypes() { return nclusters; }
cannam@24 66
cannam@18 67 protected:
cannam@24 68 void makeSegmentation(int* q, int len);
cannam@18 69
cannam@26 70 void extractFeaturesConstQ(const double *, int);
cannam@26 71 void extractFeaturesMFCC(const double *, int);
cannam@26 72
cannam@24 73 Window<double> *window;
cannam@26 74 ConstantQ* constq;
cannam@26 75 MFCC* mfcc;
cannam@24 76 model_t* model; // the HMM
cannam@24 77 int* q; // the decoded HMM state sequence
cannam@24 78 vector<vector<double> > histograms;
cannam@24 79
cannam@24 80 feature_types featureType;
cannam@24 81 double hopSize; // in seconds
cannam@24 82 double windowSize; // in seconds
cannam@24 83
cannam@24 84 // constant-Q parameters
cannam@24 85 int fmin;
cannam@24 86 int fmax;
cannam@24 87 int nbins;
cannam@24 88 int ncoeff;
cannam@24 89
cannam@24 90 // PCA parameters
cannam@24 91 int ncomponents;
cannam@24 92
cannam@24 93 // HMM parameters
cannam@24 94 int nHMMStates;
cannam@24 95
cannam@24 96 // clustering parameters
cannam@24 97 int nclusters;
cannam@24 98 int histogramLength;
cannam@24 99 int neighbourhoodLimit;
cannam@24 100
cannam@24 101 Decimator *decimator;
cannam@18 102 };