annotate src/MatchPipeline.h @ 160:581b1118ec28 refactors

Permit overriding reference frequency for second input in MatchPipeline
author Chris Cannam
date Thu, 29 Jan 2015 17:07:05 +0000
parents 6914a6a01ffc
children d23dad16d6f9
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@105 71 void feedFeatures(const vector<double> &f1, const vector<double> &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@105 79 void feedConditionedFeatures(const vector<double> &f1, const vector<double> &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@106 87 void extractFeatures(vector<double> &f1, vector<double> &f2);
Chris@106 88
Chris@106 89 /**
Chris@106 90 * Retrieve the conditioned features from the third pipeline stage.
Chris@106 91 */
Chris@106 92 void extractConditionedFeatures(vector<double> &f1, vector<double> &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@135 99 MatchFeatureFeeder *getFeeder();
Chris@105 100 Finder *getFinder();
Chris@105 101
Chris@105 102 private:
Chris@105 103 FeatureExtractor m_fe1;
Chris@105 104 FeatureExtractor m_fe2;
Chris@105 105 FeatureConditioner m_fc1;
Chris@105 106 FeatureConditioner m_fc2;
Chris@105 107 Matcher m_pm1;
Chris@105 108 Matcher m_pm2;
Chris@105 109 MatchFeatureFeeder m_feeder;
Chris@105 110 int m_lastFrameIn1;
Chris@105 111 int m_lastFrameIn2;
Chris@105 112 int m_frameNo;
Chris@106 113 vector<double> m_f1;
Chris@106 114 vector<double> m_f2;
Chris@106 115 vector<double> m_c1;
Chris@106 116 vector<double> m_c2;
Chris@105 117 bool aboveThreshold(const vector<double> &f);
Chris@105 118 };
Chris@105 119
Chris@105 120 #endif