annotate src/MatchPipeline.h @ 183:24ddab06aace re-minimise

Toward allowing types to be small again. Doesn't currently build
author Chris Cannam
date Thu, 19 Feb 2015 17:17:20 +0000
parents eeed3498fe96
children 175c8f044e7c
rev   line source
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@160 38 *
Chris@160 39 * Only one set of FeatureExtractor::Parameters is provided; this
Chris@160 40 * contains a single reference frequency, but it's possible the
Chris@160 41 * two input streams may have different tuning frequencies. A
Chris@160 42 * separate frequency for the second input can be provided here as
Chris@160 43 * an optional parameter if needed.
Chris@105 44 */
Chris@105 45 MatchPipeline(FeatureExtractor::Parameters feParams,
Chris@105 46 FeatureConditioner::Parameters fcParams,
Chris@143 47 DistanceMetric::Parameters dParams,
Chris@160 48 Matcher::Parameters matchParams,
Chris@160 49 double secondReferenceFrequency = 0.0);
Chris@105 50
Chris@105 51 ~MatchPipeline();
Chris@105 52
Chris@105 53 /**
Chris@105 54 * Feed in data at the first pipeline stage. The input arrays
Chris@105 55 * represent frames of audio from the two different sources. Each
Chris@105 56 * is provided as a single array of alternating real and imaginary
Chris@105 57 * components.
Chris@105 58 *
Chris@105 59 * Input arrays must have at least 2 * (feParams.fftSize/2 + 1)
Chris@105 60 * elements. The arrays will be passed to FeatureExtractor and
Chris@105 61 * then on into the rest of the pipeline.
Chris@105 62 */
Chris@105 63 void feedFrequencyDomainAudio(const float *arr1, const float *arr2);
Chris@105 64
Chris@105 65 /**
Chris@105 66 * Feed in data at the second pipeline stage. The vectors
Chris@105 67 * represent feature frames from two different sources. They will
Chris@105 68 * be passed in to FeatureConditioner and then on to the rest of
Chris@105 69 * the pipeline.
Chris@105 70 */
Chris@183 71 void feedFeatures(const feature_t &f1, const feature_t &f2);
Chris@106 72
Chris@105 73 /**
Chris@105 74 * Feed in data at the third pipeline stage. The vectors represent
Chris@105 75 * conditioned feature frames from two different sources. They
Chris@105 76 * will be passed to MatchFeatureFeeder for feeding to the two
Chris@105 77 * matchers.
Chris@105 78 */
Chris@183 79 void feedConditionedFeatures(const feature_t &f1, const feature_t &f2);
Chris@105 80
Chris@105 81 /**
Chris@106 82 * If a frame was just fed in at the first or second pipeline
Chris@106 83 * stage, it can be retrieved from the second stage here. That is,
Chris@106 84 * if you provided frequency-domain audio, extractFeatures will
Chris@106 85 * give you back the FeatureExtractor's features.
Chris@106 86 */
Chris@183 87 void extractFeatures(feature_t &f1, feature_t &f2);
Chris@106 88
Chris@106 89 /**
Chris@106 90 * Retrieve the conditioned features from the third pipeline stage.
Chris@106 91 */
Chris@183 92 void extractConditionedFeatures(feature_t &f1, feature_t &f2);
Chris@106 93
Chris@106 94 /**
Chris@105 95 * Indicate that both inputs have come to an end.
Chris@105 96 */
Chris@105 97 void finish();
Chris@105 98
Chris@155 99 /**
Chris@155 100 * Retrieve the final path. Only valid once all the features have
Chris@155 101 * been supplied and finish() has been called.
Chris@155 102 *
Chris@155 103 * See Finder::retrievePath for more details.
Chris@155 104 */
Chris@155 105 int retrievePath(bool smooth, std::vector<int> &pathx, std::vector<int> &pathy);
Chris@155 106
Chris@155 107 /**
Chris@155 108 * Retrieve the forward path resulting from the online search.
Chris@155 109 *
Chris@155 110 * See MatchFeatureFeeder::retrieveForwardPath for more details.
Chris@155 111 */
Chris@155 112 void retrieveForwardPath(std::vector<int> &pathx, std::vector<int> &pathy);
Chris@173 113
Chris@173 114 /**
Chris@173 115 * Get the path cost for the overall path to the end of both
Chris@173 116 * sources.
Chris@173 117 *
Chris@173 118 * See Finder::getOverallCost for more details.
Chris@173 119 */
Chris@173 120 double getOverallCost();
Chris@173 121
Chris@105 122 private:
Chris@105 123 FeatureExtractor m_fe1;
Chris@105 124 FeatureExtractor m_fe2;
Chris@105 125 FeatureConditioner m_fc1;
Chris@105 126 FeatureConditioner m_fc2;
Chris@105 127 Matcher m_pm1;
Chris@105 128 Matcher m_pm2;
Chris@105 129 MatchFeatureFeeder m_feeder;
Chris@105 130 int m_lastFrameIn1;
Chris@105 131 int m_lastFrameIn2;
Chris@105 132 int m_frameNo;
Chris@183 133 feature_t m_f1;
Chris@183 134 feature_t m_f2;
Chris@183 135 feature_t m_c1;
Chris@183 136 feature_t m_c2;
Chris@183 137 bool aboveThreshold(const feature_t &f);
Chris@166 138 FeatureExtractor::Parameters paramsWithFreq(FeatureExtractor::Parameters,
Chris@166 139 double);
Chris@105 140 };
Chris@105 141
Chris@105 142 #endif