cannam@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
cannam@0
|
2 /*
|
cannam@0
|
3 Vamp feature extraction plugin using the MATCH audio alignment
|
cannam@0
|
4 algorithm.
|
cannam@0
|
5
|
cannam@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@236
|
7 Copyright (c) 2007-2020 Simon Dixon, Chris Cannam, and Queen Mary
|
Chris@230
|
8 University of London, Copyright (c) 2014-2015 Tido GmbH.
|
cannam@0
|
9
|
cannam@0
|
10 This program is free software; you can redistribute it and/or
|
cannam@0
|
11 modify it under the terms of the GNU General Public License as
|
cannam@0
|
12 published by the Free Software Foundation; either version 2 of the
|
cannam@0
|
13 License, or (at your option) any later version. See the file
|
cannam@0
|
14 COPYING included with this distribution for more information.
|
cannam@0
|
15 */
|
cannam@0
|
16
|
Chris@235
|
17 #ifndef MATCH_FEATURE_FEEDER_H
|
Chris@235
|
18 #define MATCH_FEATURE_FEEDER_H
|
cannam@0
|
19
|
cannam@0
|
20 #include "Matcher.h"
|
cannam@0
|
21 #include "Finder.h"
|
cannam@0
|
22
|
cannam@0
|
23 #include <queue>
|
Chris@14
|
24 #include <vector>
|
cannam@0
|
25
|
Chris@24
|
26 class MatchFeatureFeeder
|
cannam@0
|
27 {
|
cannam@0
|
28 public:
|
Chris@24
|
29 MatchFeatureFeeder(Matcher *m1, Matcher *m2);
|
Chris@24
|
30 ~MatchFeatureFeeder();
|
cannam@0
|
31
|
Chris@14
|
32 /**
|
Chris@24
|
33 * Feed the two supplied feature vectors to feeders 1 and 2
|
Chris@24
|
34 * respectively (depending on their advance status). Matchers must
|
Chris@24
|
35 * have been constructed using the external featureSize
|
Chris@24
|
36 * constructor.
|
Chris@60
|
37 *
|
Chris@60
|
38 * f1 and f2 are normally expected to have the same number of
|
Chris@60
|
39 * values, and that number should be the featureSize passed to the
|
Chris@60
|
40 * constructors for both Matchers. The exception is when one input
|
Chris@60
|
41 * ends before the other one: subsequent calls should pass a
|
Chris@60
|
42 * feature vector as normal for the input that is still going on,
|
Chris@60
|
43 * and an empty vector for the one that has ended.
|
Chris@14
|
44 */
|
Chris@183
|
45 void feed(feature_t f1, feature_t f2);
|
Chris@14
|
46
|
Chris@63
|
47 /**
|
Chris@167
|
48 * Get the best estimate for the frame in the reference (f1)
|
Chris@167
|
49 * corresponding to the latest frame in the other input (f2).
|
Chris@167
|
50 */
|
Chris@167
|
51 int getEstimatedReferenceFrame();
|
Chris@167
|
52
|
Chris@167
|
53 /**
|
Chris@63
|
54 * Indicate that both inputs have come to an end.
|
Chris@63
|
55 */
|
Chris@63
|
56 void finish();
|
Chris@135
|
57
|
Chris@135
|
58 /**
|
Chris@135
|
59 * Return the forward path, that is, the estimate of the
|
Chris@135
|
60 * lowest-cost path that was generated (possibly in real-time)
|
Chris@135
|
61 * while initially tracking the inputs. This is the path that is
|
Chris@135
|
62 * used to determine the shape of the search zone within which the
|
Chris@135
|
63 * eventual reverse path will be sought by the Finder.
|
Chris@135
|
64 */
|
Chris@135
|
65 void retrieveForwardPath(std::vector<int> &pathx, std::vector<int> &pathy) {
|
Chris@135
|
66 pathx = m_fpx;
|
Chris@135
|
67 pathy = m_fpy;
|
Chris@135
|
68 }
|
Chris@135
|
69
|
Chris@167
|
70 Finder *getFinder() { return &m_finder; }
|
cannam@0
|
71
|
cannam@0
|
72 protected:
|
Chris@24
|
73 void feedBlock();
|
Chris@24
|
74 void feed1();
|
Chris@24
|
75 void feed2();
|
cannam@0
|
76
|
Chris@147
|
77 Matcher *m_pm1; // I do not own this
|
Chris@147
|
78 Matcher *m_pm2; // I do not own this
|
cannam@0
|
79
|
Chris@167
|
80 Finder m_finder; // I own this, and it refers to m_pm1
|
Chris@167
|
81
|
Chris@183
|
82 std::queue<feature_t> m_q1;
|
Chris@183
|
83 std::queue<feature_t> m_q2;
|
Chris@135
|
84
|
Chris@235
|
85 std::vector<int> m_fpx;
|
Chris@235
|
86 std::vector<int> m_fpy;
|
Chris@171
|
87
|
Chris@171
|
88 // not provided:
|
Chris@171
|
89 MatchFeatureFeeder(const MatchFeatureFeeder &other);
|
Chris@171
|
90 MatchFeatureFeeder &operator=(const MatchFeatureFeeder &other);
|
cannam@0
|
91 };
|
cannam@0
|
92
|
cannam@0
|
93 #endif
|