Chris@105
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@105
|
2 /*
|
Chris@105
|
3 Vamp feature extraction plugin using the MATCH audio alignment
|
Chris@105
|
4 algorithm.
|
Chris@105
|
5
|
Chris@105
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@105
|
7 This file copyright 2007 Simon Dixon, Chris Cannam and QMUL.
|
Chris@105
|
8
|
Chris@105
|
9 This program is free software; you can redistribute it and/or
|
Chris@105
|
10 modify it under the terms of the GNU General Public License as
|
Chris@105
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@105
|
12 License, or (at your option) any later version. See the file
|
Chris@105
|
13 COPYING included with this distribution for more information.
|
Chris@105
|
14 */
|
Chris@105
|
15
|
Chris@105
|
16 #ifndef MATCH_PIPELINE_H
|
Chris@105
|
17 #define MATCH_PIPELINE_H
|
Chris@105
|
18
|
Chris@105
|
19 #include "Matcher.h"
|
Chris@105
|
20 #include "Finder.h"
|
Chris@105
|
21 #include "FeatureExtractor.h"
|
Chris@105
|
22 #include "FeatureConditioner.h"
|
Chris@105
|
23 #include "MatchFeatureFeeder.h"
|
Chris@105
|
24
|
Chris@105
|
25 class MatchPipeline
|
Chris@105
|
26 {
|
Chris@105
|
27 public:
|
Chris@105
|
28 /**
|
Chris@105
|
29 * Pipeline consisting of two Matchers, two FeatureConditioners,
|
Chris@105
|
30 * two FeatureExtractors, and a Finder. Features may be inserted
|
Chris@105
|
31 * at any point in the pipeline.
|
Chris@105
|
32 *
|
Chris@105
|
33 * The pipeline goes:
|
Chris@105
|
34 * Frequency-domain audio
|
Chris@105
|
35 * -> Features
|
Chris@105
|
36 * -> Conditioned features
|
Chris@105
|
37 * -> Matcher
|
Chris@105
|
38 */
|
Chris@105
|
39 MatchPipeline(FeatureExtractor::Parameters feParams,
|
Chris@105
|
40 FeatureConditioner::Parameters fcParams,
|
Chris@143
|
41 DistanceMetric::Parameters dParams,
|
Chris@105
|
42 Matcher::Parameters matchParams);
|
Chris@105
|
43
|
Chris@105
|
44 ~MatchPipeline();
|
Chris@105
|
45
|
Chris@105
|
46 /**
|
Chris@105
|
47 * Feed in data at the first pipeline stage. The input arrays
|
Chris@105
|
48 * represent frames of audio from the two different sources. Each
|
Chris@105
|
49 * is provided as a single array of alternating real and imaginary
|
Chris@105
|
50 * components.
|
Chris@105
|
51 *
|
Chris@105
|
52 * Input arrays must have at least 2 * (feParams.fftSize/2 + 1)
|
Chris@105
|
53 * elements. The arrays will be passed to FeatureExtractor and
|
Chris@105
|
54 * then on into the rest of the pipeline.
|
Chris@105
|
55 */
|
Chris@105
|
56 void feedFrequencyDomainAudio(const float *arr1, const float *arr2);
|
Chris@105
|
57
|
Chris@105
|
58 /**
|
Chris@105
|
59 * Feed in data at the second pipeline stage. The vectors
|
Chris@105
|
60 * represent feature frames from two different sources. They will
|
Chris@105
|
61 * be passed in to FeatureConditioner and then on to the rest of
|
Chris@105
|
62 * the pipeline.
|
Chris@105
|
63 */
|
Chris@105
|
64 void feedFeatures(const vector<double> &f1, const vector<double> &f2);
|
Chris@106
|
65
|
Chris@105
|
66 /**
|
Chris@105
|
67 * Feed in data at the third pipeline stage. The vectors represent
|
Chris@105
|
68 * conditioned feature frames from two different sources. They
|
Chris@105
|
69 * will be passed to MatchFeatureFeeder for feeding to the two
|
Chris@105
|
70 * matchers.
|
Chris@105
|
71 */
|
Chris@105
|
72 void feedConditionedFeatures(const vector<double> &f1, const vector<double> &f2);
|
Chris@105
|
73
|
Chris@105
|
74 /**
|
Chris@106
|
75 * If a frame was just fed in at the first or second pipeline
|
Chris@106
|
76 * stage, it can be retrieved from the second stage here. That is,
|
Chris@106
|
77 * if you provided frequency-domain audio, extractFeatures will
|
Chris@106
|
78 * give you back the FeatureExtractor's features.
|
Chris@106
|
79 */
|
Chris@106
|
80 void extractFeatures(vector<double> &f1, vector<double> &f2);
|
Chris@106
|
81
|
Chris@106
|
82 /**
|
Chris@106
|
83 * Retrieve the conditioned features from the third pipeline stage.
|
Chris@106
|
84 */
|
Chris@106
|
85 void extractConditionedFeatures(vector<double> &f1, vector<double> &f2);
|
Chris@106
|
86
|
Chris@106
|
87 /**
|
Chris@105
|
88 * Indicate that both inputs have come to an end.
|
Chris@105
|
89 */
|
Chris@105
|
90 void finish();
|
Chris@105
|
91
|
Chris@135
|
92 MatchFeatureFeeder *getFeeder();
|
Chris@105
|
93 Finder *getFinder();
|
Chris@105
|
94
|
Chris@105
|
95 private:
|
Chris@105
|
96 FeatureExtractor m_fe1;
|
Chris@105
|
97 FeatureExtractor m_fe2;
|
Chris@105
|
98 FeatureConditioner m_fc1;
|
Chris@105
|
99 FeatureConditioner m_fc2;
|
Chris@105
|
100 Matcher m_pm1;
|
Chris@105
|
101 Matcher m_pm2;
|
Chris@105
|
102 MatchFeatureFeeder m_feeder;
|
Chris@105
|
103 int m_lastFrameIn1;
|
Chris@105
|
104 int m_lastFrameIn2;
|
Chris@105
|
105 int m_frameNo;
|
Chris@106
|
106 vector<double> m_f1;
|
Chris@106
|
107 vector<double> m_f2;
|
Chris@106
|
108 vector<double> m_c1;
|
Chris@106
|
109 vector<double> m_c2;
|
Chris@105
|
110 bool aboveThreshold(const vector<double> &f);
|
Chris@105
|
111 };
|
Chris@105
|
112
|
Chris@105
|
113 #endif
|