annotate src/MatchFeeder.h @ 60:faa523be20f9 refactors_no_float

Update both Feeders so as to recognise the end of one input before the other has ended. MatchFeeder does this by detecting trailing silence (as both its inputs are technically the same length since the shorter is zero-padded) and reporting that to Finder. MatchFeatureFeeder simply recognises missing features at the end and won't queue them.
author Chris Cannam
date Fri, 14 Nov 2014 13:53:58 +0000
parents 16870e8770ae
children a540137d393b
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
cannam@0 16 #ifndef _MATCH_FEEDER_H_
cannam@0 17 #define _MATCH_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
cannam@0 25 class MatchFeeder
cannam@0 26 {
cannam@0 27 public:
cannam@0 28 MatchFeeder(Matcher *m1, Matcher *m2);
cannam@0 29 ~MatchFeeder();
cannam@0 30
Chris@14 31 /**
Chris@14 32 * Feed the two supplied channels of frequency-domain input data
Chris@14 33 * to feeders 1 and 2 respectively, as appropriate (depending on
Chris@14 34 * their advance status).
Chris@14 35 */
cannam@0 36 void feed(const float *const *input);
cannam@0 37
Chris@14 38 struct Features {
Chris@14 39 std::vector<std::vector<double> > f1;
Chris@14 40 std::vector<std::vector<double> > f2;
Chris@14 41 };
Chris@14 42
Chris@14 43 /**
Chris@14 44 * Feed the two supplied channels of frequency-domain input data
Chris@24 45 * to matchers 1 and 2 respectively, as appropriate (depending on
Chris@14 46 * their advance status) and return any new feature vectors
Chris@14 47 * calculated by the two feeders.
Chris@14 48 */
Chris@14 49 Features feedAndGetFeatures(const float *const *input);
Chris@60 50
cannam@0 51 Finder *getFinder() { return finder; }
cannam@0 52
cannam@0 53 protected:
Chris@14 54 void prepare(const float *const *input);
Chris@14 55 Features feedBlock();
Chris@14 56 std::vector<double> feed1();
Chris@14 57 std::vector<double> feed2();
cannam@0 58
cannam@0 59 Finder *finder;
cannam@0 60 Matcher *pm1;
cannam@0 61 Matcher *pm2;
cannam@0 62
cannam@0 63 size_t fftSize;
cannam@0 64 double *reBuffer;
cannam@0 65 double *imBuffer;
cannam@0 66
cannam@0 67 std::queue<float *> q1;
cannam@0 68 std::queue<float *> q2;
Chris@60 69
Chris@60 70 int n;
Chris@60 71 int lastIn1;
Chris@60 72 int lastIn2;
cannam@0 73 };
cannam@0 74
cannam@0 75 #endif