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