Mercurial > hg > match-vamp
comparison MatchFeatureFeeder.cpp @ 24:89929e9e54fb
Add MatchFeatureFeeder, permitting the aligner to be driven from external data
author | Chris Cannam |
---|---|
date | Fri, 10 Oct 2014 17:45:28 +0100 |
parents | MatchFeeder.cpp@b15106b0abcd |
children |
comparison
equal
deleted
inserted
replaced
23:64c4c0cf80c9 | 24:89929e9e54fb |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Vamp feature extraction plugin using the MATCH audio alignment | |
5 algorithm. | |
6 | |
7 Centre for Digital Music, Queen Mary, University of London. | |
8 This file copyright 2007 Simon Dixon, Chris Cannam and QMUL. | |
9 | |
10 This program is free software; you can redistribute it and/or | |
11 modify it under the terms of the GNU General Public License as | |
12 published by the Free Software Foundation; either version 2 of the | |
13 License, or (at your option) any later version. See the file | |
14 COPYING included with this distribution for more information. | |
15 */ | |
16 | |
17 #include "MatchFeatureFeeder.h" | |
18 | |
19 using std::vector; | |
20 | |
21 MatchFeatureFeeder::MatchFeatureFeeder(Matcher *m1, Matcher *m2) : | |
22 pm1(m1), pm2(m2) | |
23 { | |
24 finder = new Finder(m1, m2); | |
25 } | |
26 | |
27 MatchFeatureFeeder::~MatchFeatureFeeder() | |
28 { | |
29 delete finder; | |
30 } | |
31 | |
32 void | |
33 MatchFeatureFeeder::feed(vector<double> f1, vector<double> f2) | |
34 { | |
35 q1.push(f1); | |
36 q2.push(f2); | |
37 | |
38 while (!q1.empty() && !q2.empty()) { | |
39 feedBlock(); | |
40 } | |
41 } | |
42 | |
43 void | |
44 MatchFeatureFeeder::feedBlock() | |
45 { | |
46 if (pm1->frameCount < pm1->blockSize) { // fill initial block | |
47 feed1(); | |
48 feed2(); | |
49 } | |
50 else if (pm1->runCount >= pm1->params.maxRunCount) { // slope constraints | |
51 feed2(); | |
52 } else if (pm2->runCount >= pm2->params.maxRunCount) { | |
53 feed1(); | |
54 } else { | |
55 switch (finder->getExpandDirection | |
56 (pm1->frameCount-1, pm2->frameCount-1)) { | |
57 case ADVANCE_THIS: | |
58 feed1(); | |
59 break; | |
60 case ADVANCE_OTHER: | |
61 feed2(); | |
62 break; | |
63 case ADVANCE_BOTH: | |
64 feed1(); | |
65 feed2(); | |
66 break; | |
67 } | |
68 } | |
69 } | |
70 | |
71 void | |
72 MatchFeatureFeeder::feed1() | |
73 { | |
74 pm1->consumeFeatureVector(q1.front()); | |
75 q1.pop(); | |
76 } | |
77 | |
78 void | |
79 MatchFeatureFeeder::feed2() | |
80 { | |
81 pm2->consumeFeatureVector(q2.front()); | |
82 q2.pop(); | |
83 } | |
84 |