annotate src/MatchFeatureFeeder.h @ 167:28c73e5db2eb structure

Allow querying the best-estimate reference frame for the current feed point; don't heap-allocate finder
author Chris Cannam
date Thu, 05 Feb 2015 14:06:57 +0000
parents 2b61e0cb6847
children bb4507f24dc9
rev   line source
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.
cannam@0 7 This file copyright 2007 Simon Dixon, Chris Cannam and QMUL.
cannam@0 8
cannam@0 9 This program is free software; you can redistribute it and/or
cannam@0 10 modify it under the terms of the GNU General Public License as
cannam@0 11 published by the Free Software Foundation; either version 2 of the
cannam@0 12 License, or (at your option) any later version. See the file
cannam@0 13 COPYING included with this distribution for more information.
cannam@0 14 */
cannam@0 15
Chris@24 16 #ifndef _MATCH_FEATURE_FEEDER_H_
Chris@24 17 #define _MATCH_FEATURE_FEEDER_H_
cannam@0 18
cannam@0 19 #include "Matcher.h"
cannam@0 20 #include "Finder.h"
cannam@0 21
cannam@0 22 #include <queue>
Chris@14 23 #include <vector>
cannam@0 24
Chris@24 25 class MatchFeatureFeeder
cannam@0 26 {
cannam@0 27 public:
Chris@24 28 MatchFeatureFeeder(Matcher *m1, Matcher *m2);
Chris@24 29 ~MatchFeatureFeeder();
cannam@0 30
Chris@155 31 MatchFeatureFeeder(const MatchFeatureFeeder &other);
Chris@155 32 MatchFeatureFeeder &operator=(const MatchFeatureFeeder &other);
Chris@155 33
Chris@154 34 void setMatchers(Matcher *m1, Matcher *m2);
Chris@154 35
Chris@14 36 /**
Chris@24 37 * Feed the two supplied feature vectors to feeders 1 and 2
Chris@24 38 * respectively (depending on their advance status). Matchers must
Chris@24 39 * have been constructed using the external featureSize
Chris@24 40 * constructor.
Chris@60 41 *
Chris@60 42 * f1 and f2 are normally expected to have the same number of
Chris@60 43 * values, and that number should be the featureSize passed to the
Chris@60 44 * constructors for both Matchers. The exception is when one input
Chris@60 45 * ends before the other one: subsequent calls should pass a
Chris@60 46 * feature vector as normal for the input that is still going on,
Chris@60 47 * and an empty vector for the one that has ended.
Chris@14 48 */
Chris@24 49 void feed(std::vector<double> f1, std::vector<double> f2);
Chris@14 50
Chris@63 51 /**
Chris@167 52 * Get the best estimate for the frame in the reference (f1)
Chris@167 53 * corresponding to the latest frame in the other input (f2).
Chris@167 54 */
Chris@167 55 int getEstimatedReferenceFrame();
Chris@167 56
Chris@167 57 /**
Chris@63 58 * Indicate that both inputs have come to an end.
Chris@63 59 */
Chris@63 60 void finish();
Chris@135 61
Chris@135 62 /**
Chris@135 63 * Return the forward path, that is, the estimate of the
Chris@135 64 * lowest-cost path that was generated (possibly in real-time)
Chris@135 65 * while initially tracking the inputs. This is the path that is
Chris@135 66 * used to determine the shape of the search zone within which the
Chris@135 67 * eventual reverse path will be sought by the Finder.
Chris@135 68 */
Chris@135 69 void retrieveForwardPath(std::vector<int> &pathx, std::vector<int> &pathy) {
Chris@135 70 pathx = m_fpx;
Chris@135 71 pathy = m_fpy;
Chris@135 72 }
Chris@135 73
Chris@167 74 Finder *getFinder() { return &m_finder; }
cannam@0 75
cannam@0 76 protected:
Chris@24 77 void feedBlock();
Chris@24 78 void feed1();
Chris@24 79 void feed2();
cannam@0 80
Chris@147 81 Matcher *m_pm1; // I do not own this
Chris@147 82 Matcher *m_pm2; // I do not own this
cannam@0 83
Chris@167 84 Finder m_finder; // I own this, and it refers to m_pm1
Chris@167 85
Chris@74 86 std::queue<std::vector<double> > m_q1;
Chris@74 87 std::queue<std::vector<double> > m_q2;
Chris@135 88
Chris@135 89 vector<int> m_fpx;
Chris@135 90 vector<int> m_fpy;
cannam@0 91 };
cannam@0 92
cannam@0 93 #endif