Mercurial > hg > qm-dsp
comparison dsp/segmentation/Segmenter.h @ 505:930b5b0f707d
Merge branch 'codestyle-and-tidy'
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Wed, 05 Jun 2019 12:55:15 +0100 |
parents | bb78ca3fe7de |
children |
comparison
equal
deleted
inserted
replaced
471:e3335cb213da | 505:930b5b0f707d |
---|---|
1 #ifndef _SEGMENTER_H | 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ |
2 #define _SEGMENTER_H | |
3 | |
4 /* | 2 /* |
5 * Segmenter.h | 3 * Segmenter.h |
6 * soundbite | 4 * soundbite |
7 * | 5 * |
8 * Created by Mark Levy on 23/03/2006. | 6 * Created by Mark Levy on 23/03/2006. |
14 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
15 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
16 * | 14 * |
17 */ | 15 */ |
18 | 16 |
17 #ifndef QM_DSP_SEGMENTER_H | |
18 #define QM_DSP_SEGMENTER_H | |
19 | |
19 #include <vector> | 20 #include <vector> |
20 #include <iostream> | 21 #include <iostream> |
21 | |
22 using std::vector; | |
23 using std::ostream; | |
24 | 22 |
25 class Segment | 23 class Segment |
26 { | 24 { |
27 public: | 25 public: |
28 int start; // in samples | 26 int start; // in samples |
29 int end; | 27 int end; |
30 int type; | 28 int type; |
31 }; | 29 }; |
32 | 30 |
33 class Segmentation | 31 class Segmentation |
34 { | 32 { |
35 public: | 33 public: |
36 int nsegtypes; // number of segment types, so possible types are {0,1,...,nsegtypes-1} | 34 int nsegtypes; // number of segment types, so possible types are {0,1,...,nsegtypes-1} |
37 int samplerate; | 35 int samplerate; |
38 vector<Segment> segments; | 36 std::vector<Segment> segments; |
39 }; | 37 }; |
40 | 38 |
41 ostream& operator<<(ostream& os, const Segmentation& s); | 39 std::ostream& operator<<(std::ostream& os, const Segmentation& s); |
42 | 40 |
43 class Segmenter | 41 class Segmenter |
44 { | 42 { |
45 public: | 43 public: |
46 Segmenter() {} | 44 Segmenter() {} |
47 virtual ~Segmenter() {} | 45 virtual ~Segmenter() {} |
48 virtual void initialise(int samplerate) = 0; // must be called before any other methods | 46 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() | 47 virtual int getWindowsize() = 0; // required window size for calls to extractFeatures() |
50 virtual int getHopsize() = 0; // required hop size for calls to extractFeatures() | 48 virtual int getHopsize() = 0; // required hop size for calls to extractFeatures() |
51 virtual void extractFeatures(const double* samples, int nsamples) = 0; | 49 virtual void extractFeatures(const double* samples, int nsamples) = 0; |
52 virtual void segment() = 0; // call once all the features have been extracted | 50 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 | 51 virtual void segment(int m) = 0; // specify desired number of segment-types |
54 virtual void clear() { features.clear(); } | 52 virtual void clear() { features.clear(); } |
55 const Segmentation& getSegmentation() const { return segmentation; } | 53 const Segmentation& getSegmentation() const { return segmentation; } |
56 protected: | 54 protected: |
57 vector<vector<double> > features; | 55 std::vector<std::vector<double> > features; |
58 Segmentation segmentation; | 56 Segmentation segmentation; |
59 int samplerate; | 57 int samplerate; |
60 }; | 58 }; |
61 | 59 |
62 #endif | 60 #endif |