annotate src/Finder.h @ 67:a3efb15e7faf refactors

Merge from branch refactors_no_float
author Chris Cannam
date Tue, 18 Nov 2014 10:33:03 +0000
parents 19a93b15fcc3
children c3c50d5e05b7
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 /*
cannam@0 4 Vamp feature extraction plugin using the MATCH audio alignment
cannam@0 5 algorithm.
cannam@0 6
cannam@0 7 Centre for Digital Music, Queen Mary, University of London.
cannam@0 8 This file copyright 2007 Simon Dixon, Chris Cannam and QMUL.
cannam@0 9
cannam@0 10 This program is free software; you can redistribute it and/or
cannam@0 11 modify it under the terms of the GNU General Public License as
cannam@0 12 published by the Free Software Foundation; either version 2 of the
cannam@0 13 License, or (at your option) any later version. See the file
cannam@0 14 COPYING included with this distribution for more information.
cannam@0 15 */
cannam@0 16
cannam@0 17 #ifndef _FINDER_H_
cannam@0 18 #define _FINDER_H_
cannam@0 19
cannam@0 20 #include <vector>
cannam@0 21 #include <iostream>
cannam@0 22
cannam@0 23 #include "Matcher.h"
cannam@0 24
cannam@0 25 /** Maps cost matrix coordinates into an efficient
cannam@0 26 * (linear instead of quadratic space) representation.
cannam@0 27 * Stores result of most recent mapping for fast
cannam@0 28 * sequential access.
cannam@0 29 */
cannam@0 30 class Finder {
cannam@0 31
cannam@0 32 protected:
cannam@0 33 Matcher *pm1, *pm2;
cannam@0 34 int index1, index2, bestRow, bestCol;
cannam@0 35 int *rowRange;
cannam@0 36 int *colRange;
Chris@60 37 int duration1, duration2;
cannam@0 38
cannam@0 39 public:
cannam@0 40 Finder(Matcher *p1, Matcher *p2);
cannam@0 41
cannam@0 42 ~Finder();
cannam@0 43
Chris@60 44 /**
Chris@60 45 * Tell the finder that one or both files ends sooner than it
Chris@60 46 * thought, i.e. that some of the trailing features are silence or
Chris@60 47 * otherwise to be ignored. d1 and d2 are feature frame counts for
Chris@60 48 * matchers 1 and 2 respectively. If this is not called, the full
Chris@60 49 * duration of each input will be considered.
Chris@60 50 */
Chris@60 51 void setDurations(int d1, int d2);
Chris@60 52
cannam@0 53 /** Sets up the instance variables to point to the given
cannam@0 54 * coordinate in the distance matrix.
cannam@0 55 *
cannam@0 56 * @param i1 frameNumber in the first Matcher
cannam@0 57 * @param i2 frameNumber in the second Matcher
cannam@0 58 * @return true iff the point (i2,i1) is represented in the distance matrix
cannam@0 59 */
cannam@0 60 bool find(int i1, int i2);
cannam@0 61
cannam@0 62 /** Returns the range [lo,hi) of legal column indices for the
cannam@0 63 * given row. */
cannam@0 64 void getColRange(int row, int *range);
cannam@0 65
cannam@0 66 /** Returns the range [lo,hi) of legal row indices for the given
cannam@0 67 * column. */
cannam@0 68 void getRowRange(int col, int *range);
cannam@0 69
Chris@45 70 Matcher::Advance getExpandDirection(int row, int col);
Chris@45 71 Matcher::Advance getExpandDirection(int row, int col, bool check);
cannam@0 72
Chris@45 73 float getDistance(int row, int col);
Chris@45 74 void setDistance(int row, int col, float b);
cannam@0 75
Chris@53 76 double getPathCost(int row, int col);
Chris@53 77 double getRawPathCost(int row, int col); //!!!???
Chris@53 78 void setPathCost(int row, int col, double i);
cannam@0 79
Chris@45 80 Matcher::Advance getAdvance();
Chris@45 81 void setAdvance(Matcher::Advance a);
Chris@45 82
Chris@45 83 float getDistance();
Chris@45 84 void setDistance(float b);
cannam@0 85
Chris@53 86 double getPathCost();
Chris@53 87 void setPathCost(double i);
cannam@0 88
cannam@0 89 /** Calculates a rectangle of the path cost matrix so that the
cannam@0 90 * minimum cost path between the bottom left and top right
cannam@0 91 * corners can be computed. Caches previous values to avoid
cannam@0 92 * calling find() multiple times, and is several times faster as
cannam@0 93 * a result.
cannam@0 94 *
cannam@0 95 * @param r1 the bottom of the rectangle to be calculated
cannam@0 96 * @param c1 the left side of the rectangle to be calculated
cannam@0 97 * @param r2 the top of the rectangle to be calculated
cannam@0 98 * @param c2 the right side of the rectangle to be calculated
cannam@0 99 */
cannam@0 100 void recalculatePathCostMatrix(int r1, int c1, int r2, int c2);
cannam@0 101
Chris@30 102 /**
Chris@30 103 * Track back after all of the matchers have been fed in order to
Chris@30 104 * obtain the lowest cost path available. Path x and y coordinate
Chris@30 105 * pairs are returned in corresponding elements of pathx and
Chris@30 106 * pathy. Return value is the length of the returned path: only
Chris@30 107 * this many elements from pathx and pathy are valid (any
Chris@30 108 * subsequent ones may be spurious).
Chris@31 109 *
Chris@31 110 * @param smooth whether to smooth the path before returning it
Chris@30 111 */
Chris@31 112 int retrievePath(bool smooth, std::vector<int> &pathx, std::vector<int> &pathy);
Chris@30 113
cannam@0 114 }; // class Finder
cannam@0 115
cannam@0 116 #endif