annotate Finder.h @ 31:1ff9ae1dcb50

Make smoothing optional (internally, not exposed as a parameter)
author Chris Cannam
date Fri, 31 Oct 2014 15:54:15 +0000
parents 7784b0a0dd4d
children
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;
cannam@0 37
cannam@0 38 public:
cannam@0 39 Finder(Matcher *p1, Matcher *p2);
cannam@0 40
cannam@0 41 ~Finder();
cannam@0 42
cannam@0 43 /** Sets up the instance variables to point to the given
cannam@0 44 * coordinate in the distance matrix.
cannam@0 45 *
cannam@0 46 * @param i1 frameNumber in the first Matcher
cannam@0 47 * @param i2 frameNumber in the second Matcher
cannam@0 48 * @return true iff the point (i2,i1) is represented in the distance matrix
cannam@0 49 */
cannam@0 50 bool find(int i1, int i2);
cannam@0 51
cannam@0 52 /** Returns the range [lo,hi) of legal column indices for the
cannam@0 53 * given row. */
cannam@0 54 void getColRange(int row, int *range);
cannam@0 55
cannam@0 56 /** Returns the range [lo,hi) of legal row indices for the given
cannam@0 57 * column. */
cannam@0 58 void getRowRange(int col, int *range);
cannam@0 59
cannam@0 60 int getExpandDirection(int row, int col);
cannam@0 61 int getExpandDirection(int row, int col, bool check);
cannam@0 62
cannam@0 63 unsigned char getDistance(int row, int col);
cannam@0 64 void setDistance(int row, int col, unsigned char b);
cannam@0 65
cannam@0 66 int getPathCost(int row, int col);
cannam@0 67 int getRawPathCost(int row, int col);
cannam@0 68 void setPathCost(int row, int col, int i);
cannam@0 69
cannam@0 70 unsigned char getDistance();
cannam@0 71 void setDistance(int b);
cannam@0 72
cannam@0 73 int getPathCost();
cannam@0 74 void setPathCost(int i);
cannam@0 75
cannam@0 76 /** Calculates a rectangle of the path cost matrix so that the
cannam@0 77 * minimum cost path between the bottom left and top right
cannam@0 78 * corners can be computed. Caches previous values to avoid
cannam@0 79 * calling find() multiple times, and is several times faster as
cannam@0 80 * a result.
cannam@0 81 *
cannam@0 82 * @param r1 the bottom of the rectangle to be calculated
cannam@0 83 * @param c1 the left side of the rectangle to be calculated
cannam@0 84 * @param r2 the top of the rectangle to be calculated
cannam@0 85 * @param c2 the right side of the rectangle to be calculated
cannam@0 86 */
cannam@0 87 void recalculatePathCostMatrix(int r1, int c1, int r2, int c2);
cannam@0 88
Chris@30 89 /**
Chris@30 90 * Track back after all of the matchers have been fed in order to
Chris@30 91 * obtain the lowest cost path available. Path x and y coordinate
Chris@30 92 * pairs are returned in corresponding elements of pathx and
Chris@30 93 * pathy. Return value is the length of the returned path: only
Chris@30 94 * this many elements from pathx and pathy are valid (any
Chris@30 95 * subsequent ones may be spurious).
Chris@31 96 *
Chris@31 97 * @param smooth whether to smooth the path before returning it
Chris@30 98 */
Chris@31 99 int retrievePath(bool smooth, std::vector<int> &pathx, std::vector<int> &pathy);
Chris@30 100
cannam@0 101 }; // class Finder
cannam@0 102
cannam@0 103 #endif