comparison dsp/segmentation/Segmenter.h @ 18:8e90a56b4b5f

* merge in segmentation code from soundbite plugin/library repository
author cannam
date Wed, 09 Jan 2008 10:46:25 +0000
parents
children 2b74bd60c61f
comparison
equal deleted inserted replaced
17:a120ac7b26b2 18:8e90a56b4b5f
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. All rights reserved.
10 *
11 */
12
13 #include <vector>
14 #include <iostream>
15
16 using std::vector;
17 using std::ostream;
18
19 class Segment
20 {
21 public:
22 int start; // in samples
23 int end;
24 int type;
25 };
26
27 class Segmentation
28 {
29 public:
30 int nsegtypes; // number of segment types, so possible types are {0,1,...,nsegtypes-1}
31 int samplerate;
32 vector<Segment> segments;
33 };
34
35 ostream& operator<<(ostream& os, const Segmentation& s);
36
37 class Segmenter
38 {
39 public:
40 Segmenter() {}
41 virtual ~Segmenter() {}
42 virtual void initialise(int samplerate) = 0; // must be called before any other methods
43 virtual int getWindowsize() = 0; // required window size for calls to extractFeatures()
44 virtual int getHopsize() = 0; // required hop size for calls to extractFeatures()
45 virtual void extractFeatures(double* samples, int nsamples) = 0;
46 virtual void segment() = 0; // call once all the features have been extracted
47 virtual void segment(int m) = 0; // specify desired number of segment-types
48 virtual void clear() { features.clear(); }
49 const Segmentation& getSegmentation() const { return segmentation; }
50 protected:
51 vector<vector<double> > features;
52 Segmentation segmentation;
53 int samplerate;
54 };
55
56 #endif