annotate dsp/segmentation/ClusterMeltSegmenter.h @ 209:ccd2019190bf msvc

Some MSVC fixes, including (temporarily, probably) renaming the FFT source file to avoid getting it mixed up with the Vamp SDK one in our object dir
author Chris Cannam
date Thu, 01 Feb 2018 16:34:08 +0000
parents e5907ae6de17
children 175e51ae78eb
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.
Chris@84 8
Chris@84 9 This program is free software; you can redistribute it and/or
Chris@84 10 modify it under the terms of the GNU General Public License as
Chris@84 11 published by the Free Software Foundation; either version 2 of the
Chris@84 12 License, or (at your option) any later version. See the file
Chris@84 13 COPYING included with this distribution for more information.
cannam@18 14 */
cannam@18 15
cannam@18 16 #include <vector>
cannam@18 17
cannam@18 18 #include "segment.h"
cannam@18 19 #include "Segmenter.h"
cannam@20 20 #include "hmm/hmm.h"
cannam@20 21 #include "base/Window.h"
cannam@18 22
cannam@18 23 using std::vector;
cannam@18 24
cannam@24 25 class Decimator;
cannam@24 26 class ConstantQ;
cannam@26 27 class MFCC;
cannam@64 28 class FFTReal;
cannam@24 29
cannam@24 30 class ClusterMeltSegmenterParams
cannam@24 31 // defaults are sensible for 11025Hz with 0.2 second hopsize
cannam@18 32 {
cannam@18 33 public:
cannam@24 34 ClusterMeltSegmenterParams() :
cannam@24 35 featureType(FEATURE_TYPE_CONSTQ),
cannam@24 36 hopSize(0.2),
cannam@24 37 windowSize(0.6),
cannam@24 38 fmin(62),
cannam@24 39 fmax(16000),
cannam@24 40 nbins(8),
cannam@24 41 ncomponents(20),
cannam@24 42 nHMMStates(40),
cannam@24 43 nclusters(10),
cannam@24 44 histogramLength(15),
cannam@24 45 neighbourhoodLimit(20) { }
cannam@24 46 feature_types featureType;
cannam@24 47 double hopSize; // in secs
cannam@24 48 double windowSize; // in secs
cannam@24 49 int fmin;
cannam@24 50 int fmax;
cannam@24 51 int nbins;
cannam@24 52 int ncomponents;
cannam@24 53 int nHMMStates;
cannam@24 54 int nclusters;
cannam@24 55 int histogramLength;
cannam@24 56 int neighbourhoodLimit;
cannam@18 57 };
cannam@18 58
cannam@18 59 class ClusterMeltSegmenter : public Segmenter
cannam@18 60 {
cannam@18 61 public:
cannam@24 62 ClusterMeltSegmenter(ClusterMeltSegmenterParams params);
cannam@24 63 virtual ~ClusterMeltSegmenter();
cannam@24 64 virtual void initialise(int samplerate);
cannam@24 65 virtual int getWindowsize();
cannam@24 66 virtual int getHopsize();
cannam@24 67 virtual void extractFeatures(const double* samples, int nsamples);
cannam@24 68 void setFeatures(const vector<vector<double> >& f); // provide the features yourself
cannam@24 69 virtual void segment(); // segment into default number of segment-types
cannam@24 70 void segment(int m); // segment into m segment-types
cannam@24 71 int getNSegmentTypes() { return nclusters; }
cannam@24 72
cannam@18 73 protected:
cannam@24 74 void makeSegmentation(int* q, int len);
cannam@18 75
cannam@26 76 void extractFeaturesConstQ(const double *, int);
cannam@26 77 void extractFeaturesMFCC(const double *, int);
cannam@26 78
cannam@24 79 Window<double> *window;
cannam@64 80 FFTReal *fft;
cannam@26 81 ConstantQ* constq;
cannam@26 82 MFCC* mfcc;
cannam@24 83 model_t* model; // the HMM
cannam@24 84 int* q; // the decoded HMM state sequence
cannam@24 85 vector<vector<double> > histograms;
cannam@24 86
cannam@24 87 feature_types featureType;
cannam@24 88 double hopSize; // in seconds
cannam@24 89 double windowSize; // in seconds
cannam@24 90
cannam@24 91 // constant-Q parameters
cannam@24 92 int fmin;
cannam@24 93 int fmax;
cannam@24 94 int nbins;
cannam@24 95 int ncoeff;
cannam@24 96
cannam@24 97 // PCA parameters
cannam@24 98 int ncomponents;
cannam@24 99
cannam@24 100 // HMM parameters
cannam@24 101 int nHMMStates;
cannam@24 102
cannam@24 103 // clustering parameters
cannam@24 104 int nclusters;
cannam@24 105 int histogramLength;
cannam@24 106 int neighbourhoodLimit;
cannam@24 107
cannam@24 108 Decimator *decimator;
cannam@18 109 };