Chris@105: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@105: /* Chris@105: Vamp feature extraction plugin using the MATCH audio alignment Chris@105: algorithm. Chris@105: Chris@105: Centre for Digital Music, Queen Mary, University of London. Chris@105: This file copyright 2007 Simon Dixon, Chris Cannam and QMUL. Chris@105: Chris@105: This program is free software; you can redistribute it and/or Chris@105: modify it under the terms of the GNU General Public License as Chris@105: published by the Free Software Foundation; either version 2 of the Chris@105: License, or (at your option) any later version. See the file Chris@105: COPYING included with this distribution for more information. Chris@105: */ Chris@105: Chris@105: #ifndef MATCH_PIPELINE_H Chris@105: #define MATCH_PIPELINE_H Chris@105: Chris@105: #include "Matcher.h" Chris@105: #include "Finder.h" Chris@105: #include "FeatureExtractor.h" Chris@105: #include "FeatureConditioner.h" Chris@105: #include "MatchFeatureFeeder.h" Chris@105: Chris@105: class MatchPipeline Chris@105: { Chris@105: public: Chris@105: /** Chris@105: * Pipeline consisting of two Matchers, two FeatureConditioners, Chris@105: * two FeatureExtractors, and a Finder. Features may be inserted Chris@105: * at any point in the pipeline. Chris@105: * Chris@105: * The pipeline goes: Chris@105: * Frequency-domain audio Chris@105: * -> Features Chris@105: * -> Conditioned features Chris@105: * -> Matcher Chris@105: */ Chris@105: MatchPipeline(FeatureExtractor::Parameters feParams, Chris@105: FeatureConditioner::Parameters fcParams, Chris@143: DistanceMetric::Parameters dParams, Chris@105: Matcher::Parameters matchParams); Chris@105: Chris@105: ~MatchPipeline(); Chris@105: Chris@105: /** Chris@105: * Feed in data at the first pipeline stage. The input arrays Chris@105: * represent frames of audio from the two different sources. Each Chris@105: * is provided as a single array of alternating real and imaginary Chris@105: * components. Chris@105: * Chris@105: * Input arrays must have at least 2 * (feParams.fftSize/2 + 1) Chris@105: * elements. The arrays will be passed to FeatureExtractor and Chris@105: * then on into the rest of the pipeline. Chris@105: */ Chris@105: void feedFrequencyDomainAudio(const float *arr1, const float *arr2); Chris@105: Chris@105: /** Chris@105: * Feed in data at the second pipeline stage. The vectors Chris@105: * represent feature frames from two different sources. They will Chris@105: * be passed in to FeatureConditioner and then on to the rest of Chris@105: * the pipeline. Chris@105: */ Chris@105: void feedFeatures(const vector &f1, const vector &f2); Chris@106: Chris@105: /** Chris@105: * Feed in data at the third pipeline stage. The vectors represent Chris@105: * conditioned feature frames from two different sources. They Chris@105: * will be passed to MatchFeatureFeeder for feeding to the two Chris@105: * matchers. Chris@105: */ Chris@105: void feedConditionedFeatures(const vector &f1, const vector &f2); Chris@105: Chris@105: /** Chris@106: * If a frame was just fed in at the first or second pipeline Chris@106: * stage, it can be retrieved from the second stage here. That is, Chris@106: * if you provided frequency-domain audio, extractFeatures will Chris@106: * give you back the FeatureExtractor's features. Chris@106: */ Chris@106: void extractFeatures(vector &f1, vector &f2); Chris@106: Chris@106: /** Chris@106: * Retrieve the conditioned features from the third pipeline stage. Chris@106: */ Chris@106: void extractConditionedFeatures(vector &f1, vector &f2); Chris@106: Chris@106: /** Chris@105: * Indicate that both inputs have come to an end. Chris@105: */ Chris@105: void finish(); Chris@105: Chris@135: MatchFeatureFeeder *getFeeder(); Chris@105: Finder *getFinder(); Chris@105: Chris@105: private: Chris@105: FeatureExtractor m_fe1; Chris@105: FeatureExtractor m_fe2; Chris@105: FeatureConditioner m_fc1; Chris@105: FeatureConditioner m_fc2; Chris@105: Matcher m_pm1; Chris@105: Matcher m_pm2; Chris@105: MatchFeatureFeeder m_feeder; Chris@105: int m_lastFrameIn1; Chris@105: int m_lastFrameIn2; Chris@105: int m_frameNo; Chris@106: vector m_f1; Chris@106: vector m_f2; Chris@106: vector m_c1; Chris@106: vector m_c2; Chris@105: bool aboveThreshold(const vector &f); Chris@105: }; Chris@105: Chris@105: #endif