c@249: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ c@249: c@243: /* c@249: * ClusterMeltSegmenter.h c@243: * c@249: * Created by Mark Levy on 23/03/2006. c@249: * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. c@309: c@309: This program is free software; you can redistribute it and/or c@309: modify it under the terms of the GNU General Public License as c@309: published by the Free Software Foundation; either version 2 of the c@309: License, or (at your option) any later version. See the file c@309: COPYING included with this distribution for more information. c@243: */ c@243: cannam@491: #ifndef QM_DSP_CLUSTER_MELT_SEGMENTER_H cannam@491: #define QM_DSP_CLUSTER_MELT_SEGMENTER_H cannam@491: c@243: #include c@243: c@243: #include "segment.h" c@243: #include "Segmenter.h" c@245: #include "hmm/hmm.h" c@245: #include "base/Window.h" c@243: c@249: class Decimator; c@249: class ConstantQ; c@251: class MFCC; c@289: class FFTReal; c@249: c@249: class ClusterMeltSegmenterParams c@249: // defaults are sensible for 11025Hz with 0.2 second hopsize c@243: { c@243: public: c@249: ClusterMeltSegmenterParams() : c@249: featureType(FEATURE_TYPE_CONSTQ), c@249: hopSize(0.2), c@249: windowSize(0.6), c@249: fmin(62), c@249: fmax(16000), c@249: nbins(8), c@249: ncomponents(20), cannam@480: nHMMStates(40), c@249: nclusters(10), c@249: histogramLength(15), c@249: neighbourhoodLimit(20) { } c@249: feature_types featureType; cannam@480: double hopSize; // in secs cannam@480: double windowSize; // in secs c@249: int fmin; c@249: int fmax; c@249: int nbins; c@249: int ncomponents; c@249: int nHMMStates; c@249: int nclusters; c@249: int histogramLength; c@249: int neighbourhoodLimit; c@243: }; c@243: c@243: class ClusterMeltSegmenter : public Segmenter c@243: { c@243: public: c@249: ClusterMeltSegmenter(ClusterMeltSegmenterParams params); c@249: virtual ~ClusterMeltSegmenter(); c@249: virtual void initialise(int samplerate); c@249: virtual int getWindowsize(); c@249: virtual int getHopsize(); c@249: virtual void extractFeatures(const double* samples, int nsamples); cannam@493: void setFeatures(const std::vector >& f); // provide the features yourself cannam@480: virtual void segment(); // segment into default number of segment-types cannam@480: void segment(int m); // segment into m segment-types c@249: int getNSegmentTypes() { return nclusters; } c@249: c@243: protected: c@249: void makeSegmentation(int* q, int len); cannam@480: c@251: void extractFeaturesConstQ(const double *, int); c@251: void extractFeaturesMFCC(const double *, int); c@251: c@249: Window *window; c@289: FFTReal *fft; c@251: ConstantQ* constq; c@251: MFCC* mfcc; cannam@480: model_t* model; // the HMM cannam@480: int* q; // the decoded HMM state sequence cannam@493: std::vector > histograms; c@249: cannam@480: feature_types featureType; cannam@480: double hopSize; // in seconds cannam@480: double windowSize; // in seconds c@249: c@249: // constant-Q parameters c@249: int fmin; c@249: int fmax; c@249: int nbins; c@249: int ncoeff; c@249: c@249: // PCA parameters c@249: int ncomponents; c@249: c@249: // HMM parameters c@249: int nHMMStates; c@249: c@249: // clustering parameters c@249: int nclusters; c@249: int histogramLength; c@249: int neighbourhoodLimit; c@249: c@249: Decimator *decimator; c@243: }; cannam@491: cannam@491: #endif