comparison src/Analyser.cpp @ 192:431a95c9d14d

Calculate frequency constraint for region outlining (does not actually do the analysis correctly yet)
author Chris Cannam
date Wed, 05 Mar 2014 09:36:13 +0000
parents 800e65412473
children 34797795a76c
comparison
equal deleted inserted replaced
191:800e65412473 192:431a95c9d14d
72 m_document = doc; 72 m_document = doc;
73 m_fileModel = model; 73 m_fileModel = model;
74 m_paneStack = paneStack; 74 m_paneStack = paneStack;
75 m_pane = pane; 75 m_pane = pane;
76 76
77 disconnect(m_pane, SIGNAL(regionOutlined(QRect)),
78 m_pane, SLOT(zoomToRegion(QRect)));
79 connect(m_pane, SIGNAL(regionOutlined(QRect)),
80 this, SLOT(regionOutlined(QRect)));
81
82 m_reAnalysingSelection = Selection(); 77 m_reAnalysingSelection = Selection();
83 m_reAnalysisCandidates.clear(); 78 m_reAnalysisCandidates.clear();
84 m_currentCandidate = -1; 79 m_currentCandidate = -1;
85 m_candidatesVisible = false; 80 m_candidatesVisible = false;
86 81
253 } 248 }
254 249
255 return ""; 250 return "";
256 } 251 }
257 252
258 void
259 Analyser::regionOutlined(QRect r)
260 {
261 cerr << "regionOutlined(" << r.x() << "," << r.y() << "," << r.width() << "," << r.height() << ")" << endl;
262 }
263
264 QString 253 QString
265 Analyser::reAnalyseSelection(Selection sel) 254 Analyser::reAnalyseSelection(Selection sel, FrequencyRange range)
266 { 255 {
267 if (sel == m_reAnalysingSelection) return ""; 256 if (sel == m_reAnalysingSelection) return "";
268 257
269 clearReAnalysis(); 258 clearReAnalysis();
270 259
273 TransformFactory *tf = TransformFactory::getInstance(); 262 TransformFactory *tf = TransformFactory::getInstance();
274 263
275 QString plugname = "pYIN"; 264 QString plugname = "pYIN";
276 QString base = "vamp:pyin:localcandidatepyin:"; 265 QString base = "vamp:pyin:localcandidatepyin:";
277 QString out = "pitchtrackcandidates"; 266 QString out = "pitchtrackcandidates";
267
268 if (range.isConstrained()) {
269 base = "vamp:pyin:yinfc:";
270 out = "f0";
271 }
278 272
279 Transforms transforms; 273 Transforms transforms;
280 274
281 QString notFound = tr("Transform \"%1\" not found. Unable to perform interactive analysis.<br><br>Is the %2 Vamp plugin correctly installed?"); 275 QString notFound = tr("Transform \"%1\" not found. Unable to perform interactive analysis.<br><br>Is the %2 Vamp plugin correctly installed?");
282 if (!tf->haveTransform(base + out)) { 276 if (!tf->haveTransform(base + out)) {
285 279
286 Transform t = tf->getDefaultTransformFor 280 Transform t = tf->getDefaultTransformFor
287 (base + out, m_fileModel->getSampleRate()); 281 (base + out, m_fileModel->getSampleRate());
288 t.setStepSize(256); 282 t.setStepSize(256);
289 t.setBlockSize(2048); 283 t.setBlockSize(2048);
284
285 if (range.isConstrained()) {
286 t.setParameter("minfreq", range.min);
287 t.setParameter("maxfreq", range.max);
288 }
290 289
291 RealTime start = RealTime::frame2RealTime 290 RealTime start = RealTime::frame2RealTime
292 (round(sel.getStartFrame()*1.0/256) * 256 - 2*256, m_fileModel->getSampleRate()); 291 (round(sel.getStartFrame()*1.0/256) * 256 - 2*256, m_fileModel->getSampleRate());
293 292
294 RealTime end = RealTime::frame2RealTime 293 RealTime end = RealTime::frame2RealTime