comparison src/Analyser.cpp @ 326:b176ea403ee8

Connect up the auto-analysis and precision analysis settings
author Chris Cannam
date Fri, 13 Jun 2014 14:47:44 +0100
parents ef75afbe4c67
children 6b57c58b88d2
comparison
equal deleted inserted replaced
325:ef75afbe4c67 326:b176ea403ee8
76 m_pane = pane; 76 m_pane = pane;
77 77
78 connect(doc, SIGNAL(layerAboutToBeDeleted(Layer *)), 78 connect(doc, SIGNAL(layerAboutToBeDeleted(Layer *)),
79 this, SLOT(layerAboutToBeDeleted(Layer *))); 79 this, SLOT(layerAboutToBeDeleted(Layer *)));
80 80
81 return doAllAnalyses(); 81 QSettings settings;
82 settings.beginGroup("Analyser");
83 bool autoAnalyse = settings.value("auto-analysis", true).toBool();
84 settings.endGroup();
85
86 return doAllAnalyses(autoAnalyse);
82 } 87 }
83 88
84 QString 89 QString
85 Analyser::analyseExistingFile() 90 Analyser::analyseExistingFile()
86 { 91 {
95 if (m_layers[Notes]) { 100 if (m_layers[Notes]) {
96 m_document->removeLayerFromView(m_pane, m_layers[Notes]); 101 m_document->removeLayerFromView(m_pane, m_layers[Notes]);
97 m_layers[Notes] = 0; 102 m_layers[Notes] = 0;
98 } 103 }
99 104
100 return doAllAnalyses(); 105 return doAllAnalyses(true);
101 } 106 }
102 107
103 QString 108 QString
104 Analyser::doAllAnalyses() 109 Analyser::doAllAnalyses(bool withPitchTrack)
105 { 110 {
106 m_reAnalysingSelection = Selection(); 111 m_reAnalysingSelection = Selection();
107 m_reAnalysisCandidates.clear(); 112 m_reAnalysisCandidates.clear();
108 m_currentCandidate = -1; 113 m_currentCandidate = -1;
109 m_candidatesVisible = false; 114 m_candidatesVisible = false;
121 warning = addVisualisations(); 126 warning = addVisualisations();
122 127
123 error = addWaveform(); 128 error = addWaveform();
124 if (error != "") return error; 129 if (error != "") return error;
125 130
126 error = addAnalyses(); 131 if (withPitchTrack) {
127 if (error != "") return error; 132 error = addAnalyses();
133 if (error != "") return error;
134 }
128 135
129 loadState(Audio); 136 loadState(Audio);
130 loadState(PitchTrack); 137 loadState(PitchTrack);
131 loadState(Notes); 138 loadState(Notes);
132 loadState(Spectrogram); 139 loadState(Spectrogram);
299 if (existingPitch && existingNotes) { 306 if (existingPitch && existingNotes) {
300 cerr << "recording existing pitch and notes layers" << endl; 307 cerr << "recording existing pitch and notes layers" << endl;
301 m_layers[PitchTrack] = existingPitch; 308 m_layers[PitchTrack] = existingPitch;
302 m_layers[Notes] = existingNotes; 309 m_layers[Notes] = existingNotes;
303 return ""; 310 return "";
304 } else if (existingPitch || existingNotes) { 311 } else {
305 return "One (but not both) of pitch and note track found in session"; 312 if (existingPitch) {
313 m_document->removeLayerFromView(m_pane, existingPitch);
314 m_layers[PitchTrack] = 0;
315 }
316 if (existingNotes) {
317 m_document->removeLayerFromView(m_pane, existingNotes);
318 m_layers[Notes] = 0;
319 }
306 } 320 }
307 321
308 TransformFactory *tf = TransformFactory::getInstance(); 322 TransformFactory *tf = TransformFactory::getInstance();
309 323
310 QString plugname = "pYIN"; 324 QString plugname = "pYIN";
332 } 346 }
333 if (!tf->haveTransform(base + noteout)) { 347 if (!tf->haveTransform(base + noteout)) {
334 return notFound.arg(base + noteout).arg(plugname); 348 return notFound.arg(base + noteout).arg(plugname);
335 } 349 }
336 350
351 QSettings settings;
352 settings.beginGroup("Analyser");
353 bool precise = settings.value("precision-analysis", false).toBool();
354 settings.endGroup();
355
337 Transform t = tf->getDefaultTransformFor 356 Transform t = tf->getDefaultTransformFor
338 (base + f0out, m_fileModel->getSampleRate()); 357 (base + f0out, m_fileModel->getSampleRate());
339 t.setStepSize(256); 358 t.setStepSize(256);
340 t.setBlockSize(2048); 359 t.setBlockSize(2048);
360
361 if (precise) {
362 cerr << "setting parameters for precise mode" << endl;
363 t.setParameter("precisetime", 1);
364 } else {
365 cerr << "setting parameters for vague mode" << endl;
366 t.setParameter("precisetime", 0);
367 }
341 368
342 transforms.push_back(t); 369 transforms.push_back(t);
343 370
344 t.setOutput(noteout); 371 t.setOutput(noteout);
345 372