changeset 106:921a88e8859d feature_conditioner

Permit retrieving features
author Chris Cannam
date Thu, 04 Dec 2014 13:43:00 +0000
parents 3f46ce2d2874
children a07b962e9f03
files src/MatchPipeline.cpp src/MatchPipeline.h
diffstat 2 files changed, 42 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/MatchPipeline.cpp	Thu Dec 04 13:35:23 2014 +0000
+++ b/src/MatchPipeline.cpp	Thu Dec 04 13:43:00 2014 +0000
@@ -45,20 +45,40 @@
 void
 MatchPipeline::feedFeatures(const vector<double> &f1, const vector<double> &f2)
 {
+    m_f1 = f1;
+    m_f2 = f2;
+
     feedConditionedFeatures(m_fc1.process(f1), m_fc2.process(f2));
 }
 
 void
-MatchPipeline::feedConditionedFeatures(const vector<double> &f1, const vector<double> &f2)
+MatchPipeline::feedConditionedFeatures(const vector<double> &c1, const vector<double> &c2)
 {
-    m_feeder.feed(f1, f2);
+    m_c1 = c1;
+    m_c2 = c2;
+    
+    m_feeder.feed(c1, c2);
 
-    if (aboveThreshold(f1)) m_lastFrameIn1 = m_frameNo;
-    if (aboveThreshold(f2)) m_lastFrameIn2 = m_frameNo;
+    if (aboveThreshold(c1)) m_lastFrameIn1 = m_frameNo;
+    if (aboveThreshold(c2)) m_lastFrameIn2 = m_frameNo;
 
     ++m_frameNo;
 }
 
+void
+MatchPipeline::extractFeatures(vector<double> &f1, vector<double> &f2)
+{
+    f1 = m_f1;
+    f2 = m_f2;
+}
+
+void
+MatchPipeline::extractConditionedFeatures(vector<double> &c1, vector<double> &c2)
+{
+    c1 = m_c1;
+    c2 = m_c2;
+}
+
 bool
 MatchPipeline::aboveThreshold(const vector<double> &f)
 {
--- a/src/MatchPipeline.h	Thu Dec 04 13:35:23 2014 +0000
+++ b/src/MatchPipeline.h	Thu Dec 04 13:43:00 2014 +0000
@@ -61,7 +61,7 @@
      * the pipeline.
      */
     void feedFeatures(const vector<double> &f1, const vector<double> &f2);
-
+    
     /**
      * Feed in data at the third pipeline stage. The vectors represent
      * conditioned feature frames from two different sources. They
@@ -71,6 +71,19 @@
     void feedConditionedFeatures(const vector<double> &f1, const vector<double> &f2);
 
     /**
+     * If a frame was just fed in at the first or second pipeline
+     * stage, it can be retrieved from the second stage here. That is,
+     * if you provided frequency-domain audio, extractFeatures will
+     * give you back the FeatureExtractor's features.
+     */
+    void extractFeatures(vector<double> &f1, vector<double> &f2);
+
+    /**
+     * Retrieve the conditioned features from the third pipeline stage.
+     */
+    void extractConditionedFeatures(vector<double> &f1, vector<double> &f2);
+
+    /**
      * Indicate that both inputs have come to an end.
      */
     void finish();
@@ -88,6 +101,10 @@
     int m_lastFrameIn1;
     int m_lastFrameIn2;
     int m_frameNo;
+    vector<double> m_f1;
+    vector<double> m_f2;
+    vector<double> m_c1;
+    vector<double> m_c2;
     bool aboveThreshold(const vector<double> &f);
 };