cannam@18: #ifndef _SEGMENTER_H cannam@18: #define _SEGMENTER_H cannam@18: cannam@18: /* cannam@18: * Segmenter.h cannam@18: * soundbite cannam@18: * cannam@18: * Created by Mark Levy on 23/03/2006. Chris@84: * Copyright 2006 Centre for Digital Music, Queen Mary, University of London. Chris@84: Chris@84: This program is free software; you can redistribute it and/or Chris@84: modify it under the terms of the GNU General Public License as Chris@84: published by the Free Software Foundation; either version 2 of the Chris@84: License, or (at your option) any later version. See the file Chris@84: COPYING included with this distribution for more information. cannam@18: * cannam@18: */ cannam@18: cannam@18: #include cannam@18: #include cannam@18: cannam@18: using std::vector; cannam@18: using std::ostream; cannam@18: cannam@18: class Segment cannam@18: { cannam@18: public: cannam@18: int start; // in samples cannam@18: int end; cannam@18: int type; cannam@18: }; cannam@18: cannam@18: class Segmentation cannam@18: { cannam@18: public: cannam@18: int nsegtypes; // number of segment types, so possible types are {0,1,...,nsegtypes-1} cannam@18: int samplerate; cannam@18: vector segments; cannam@18: }; cannam@18: cannam@18: ostream& operator<<(ostream& os, const Segmentation& s); cannam@18: cannam@18: class Segmenter cannam@18: { cannam@18: public: cannam@18: Segmenter() {} cannam@18: virtual ~Segmenter() {} cannam@18: virtual void initialise(int samplerate) = 0; // must be called before any other methods cannam@18: virtual int getWindowsize() = 0; // required window size for calls to extractFeatures() cannam@18: virtual int getHopsize() = 0; // required hop size for calls to extractFeatures() cannam@24: virtual void extractFeatures(const double* samples, int nsamples) = 0; cannam@18: virtual void segment() = 0; // call once all the features have been extracted cannam@18: virtual void segment(int m) = 0; // specify desired number of segment-types cannam@18: virtual void clear() { features.clear(); } cannam@18: const Segmentation& getSegmentation() const { return segmentation; } cannam@18: protected: cannam@18: vector > features; cannam@18: Segmentation segmentation; cannam@18: int samplerate; cannam@18: }; cannam@18: cannam@18: #endif