qm-dsp  1.8
Segmenter.h
Go to the documentation of this file.
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 
34 {
35 public:
36  int nsegtypes; // number of segment types, so possible types are {0,1,...,nsegtypes-1}
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;
60 };
61 
62 #endif
int start
Definition: Segmenter.h:28
Segmenter()
Definition: Segmenter.h:46
virtual void clear()
Definition: Segmenter.h:54
int nsegtypes
Definition: Segmenter.h:36
vector< Segment > segments
Definition: Segmenter.h:38
const Segmentation & getSegmentation() const
Definition: Segmenter.h:55
ostream & operator<<(ostream &os, const Segmentation &s)
Definition: Segmenter.cpp:19
int samplerate
Definition: Segmenter.h:37
int samplerate
Definition: Segmenter.h:59
Segmentation segmentation
Definition: Segmenter.h:58
virtual ~Segmenter()
Definition: Segmenter.h:47
int end
Definition: Segmenter.h:29
int type
Definition: Segmenter.h:30
vector< vector< double > > features
Definition: Segmenter.h:57