annotate dsp/segmentation/Segmenter.h @ 30:a251fb0de594

* Make MFCC able to accept already-FFT'd input, and simplify API a bit * Add log power value to MFCC, restore windowing, and avoid some heap allocs * In HMM, bail out of iteration if loglik hits NaN
author cannam
date Fri, 18 Jan 2008 13:24:12 +0000
parents 2b74bd60c61f
children e5907ae6de17
rev   line source
cannam@18 1 #ifndef _SEGMENTER_H
cannam@18 2 #define _SEGMENTER_H
cannam@18 3
cannam@18 4 /*
cannam@18 5 * Segmenter.h
cannam@18 6 * soundbite
cannam@18 7 *
cannam@18 8 * Created by Mark Levy on 23/03/2006.
cannam@18 9 * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. All rights reserved.
cannam@18 10 *
cannam@18 11 */
cannam@18 12
cannam@18 13 #include <vector>
cannam@18 14 #include <iostream>
cannam@18 15
cannam@18 16 using std::vector;
cannam@18 17 using std::ostream;
cannam@18 18
cannam@18 19 class Segment
cannam@18 20 {
cannam@18 21 public:
cannam@18 22 int start; // in samples
cannam@18 23 int end;
cannam@18 24 int type;
cannam@18 25 };
cannam@18 26
cannam@18 27 class Segmentation
cannam@18 28 {
cannam@18 29 public:
cannam@18 30 int nsegtypes; // number of segment types, so possible types are {0,1,...,nsegtypes-1}
cannam@18 31 int samplerate;
cannam@18 32 vector<Segment> segments;
cannam@18 33 };
cannam@18 34
cannam@18 35 ostream& operator<<(ostream& os, const Segmentation& s);
cannam@18 36
cannam@18 37 class Segmenter
cannam@18 38 {
cannam@18 39 public:
cannam@18 40 Segmenter() {}
cannam@18 41 virtual ~Segmenter() {}
cannam@18 42 virtual void initialise(int samplerate) = 0; // must be called before any other methods
cannam@18 43 virtual int getWindowsize() = 0; // required window size for calls to extractFeatures()
cannam@18 44 virtual int getHopsize() = 0; // required hop size for calls to extractFeatures()
cannam@24 45 virtual void extractFeatures(const double* samples, int nsamples) = 0;
cannam@18 46 virtual void segment() = 0; // call once all the features have been extracted
cannam@18 47 virtual void segment(int m) = 0; // specify desired number of segment-types
cannam@18 48 virtual void clear() { features.clear(); }
cannam@18 49 const Segmentation& getSegmentation() const { return segmentation; }
cannam@18 50 protected:
cannam@18 51 vector<vector<double> > features;
cannam@18 52 Segmentation segmentation;
cannam@18 53 int samplerate;
cannam@18 54 };
cannam@18 55
cannam@18 56 #endif