qm-dsp  1.8
Segmenter.h
Go to the documentation of this file.
00001 #ifndef _SEGMENTER_H
00002 #define _SEGMENTER_H
00003 
00004 /*
00005  *  Segmenter.h
00006  *  soundbite
00007  *
00008  *  Created by Mark Levy on 23/03/2006.
00009  *  Copyright 2006 Centre for Digital Music, Queen Mary, University of London.
00010 
00011     This program is free software; you can redistribute it and/or
00012     modify it under the terms of the GNU General Public License as
00013     published by the Free Software Foundation; either version 2 of the
00014     License, or (at your option) any later version.  See the file
00015     COPYING included with this distribution for more information.
00016  *
00017  */
00018 
00019 #include <vector>
00020 #include <iostream>
00021 
00022 using std::vector;
00023 using std::ostream;
00024 
00025 class Segment
00026 {
00027 public:
00028         int start;              // in samples
00029         int end;
00030         int type;
00031 };
00032 
00033 class Segmentation
00034 {
00035 public:
00036         int nsegtypes;          // number of segment types, so possible types are {0,1,...,nsegtypes-1}
00037         int samplerate;
00038         vector<Segment> segments;       
00039 };
00040 
00041 ostream& operator<<(ostream& os, const Segmentation& s);
00042 
00043 class Segmenter
00044 {
00045 public:
00046         Segmenter() {}
00047         virtual ~Segmenter() {}
00048         virtual void initialise(int samplerate) = 0;    // must be called before any other methods
00049         virtual int getWindowsize() = 0;                                // required window size for calls to extractFeatures()
00050         virtual int getHopsize() = 0;                                   // required hop size for calls to extractFeatures()
00051         virtual void extractFeatures(const double* samples, int nsamples) = 0;
00052         virtual void segment() = 0;                                             // call once all the features have been extracted
00053         virtual void segment(int m) = 0;                                // specify desired number of segment-types
00054         virtual void clear() { features.clear(); }
00055         const Segmentation& getSegmentation() const { return segmentation; } 
00056 protected:
00057         vector<vector<double> > features;
00058         Segmentation segmentation;
00059         int samplerate;
00060 };
00061 
00062 #endif