NOOP, remove trailing tabs/whitespace.
[ardour.git] / libs / qm-dsp / dsp / segmentation / Segmenter.h
1 #ifndef _SEGMENTER_H
2 #define _SEGMENTER_H
3
4 /*
5  *  Segmenter.h
6  *  soundbite
7  *
8  *  Created by Mark Levy on 23/03/2006.
9  *  Copyright 2006 Centre for Digital Music, Queen Mary, University of London.
10
11     This program is free software; you can redistribute it and/or
12     modify it under the terms of the GNU General Public License as
13     published by the Free Software Foundation; either version 2 of the
14     License, or (at your option) any later version.  See the file
15     COPYING included with this distribution for more information.
16  *
17  */
18
19 #include <vector>
20 #include <iostream>
21
22 using std::vector;
23 using std::ostream;
24
25 class Segment
26 {
27 public:
28         int start;              // in samples
29         int end;
30         int type;
31 };
32
33 class Segmentation
34 {
35 public:
36         int nsegtypes;          // number of segment types, so possible types are {0,1,...,nsegtypes-1}
37         int samplerate;
38         vector<Segment> segments;
39 };
40
41 ostream& operator<<(ostream& os, const Segmentation& s);
42
43 class Segmenter
44 {
45 public:
46         Segmenter() {}
47         virtual ~Segmenter() {}
48         virtual void initialise(int samplerate) = 0;    // must be called before any other methods
49         virtual int getWindowsize() = 0;                                // required window size for calls to extractFeatures()
50         virtual int getHopsize() = 0;                                   // required hop size for calls to extractFeatures()
51         virtual void extractFeatures(const double* samples, int nsamples) = 0;
52         virtual void segment() = 0;                                             // call once all the features have been extracted
53         virtual void segment(int m) = 0;                                // specify desired number of segment-types
54         virtual void clear() { features.clear(); }
55         const Segmentation& getSegmentation() const { return segmentation; }
56 protected:
57         vector<vector<double> > features;
58         Segmentation segmentation;
59         int samplerate;
60 };
61
62 #endif