Mercurial > hg > tony
comparison main/Analyser.cpp @ 673:90ee5448c205
Fix inconsistency between MainWindow and Analyser in the default value of the lowampsuppression option, and enforce default values in a single place. As it stood, the menu option was showing "checked" (on first run) but the parameter was actually unset until you toggled it or used the reset-to-default function.
author | Chris Cannam |
---|---|
date | Mon, 18 Nov 2019 15:07:19 +0000 |
parents | 327177b6bd3a |
children |
comparison
equal
deleted
inserted
replaced
672:de3d628e048e | 673:90ee5448c205 |
---|---|
65 | 65 |
66 Analyser::~Analyser() | 66 Analyser::~Analyser() |
67 { | 67 { |
68 } | 68 } |
69 | 69 |
70 std::map<QString, QVariant> | |
71 Analyser::getAnalysisSettings() | |
72 { | |
73 return { { "precision-analysis", false }, | |
74 { "lowamp-analysis", true }, | |
75 { "onset-analysis", true }, | |
76 { "prune-analysis", true } | |
77 }; | |
78 } | |
79 | |
70 QString | 80 QString |
71 Analyser::newFileLoaded(Document *doc, ModelId model, | 81 Analyser::newFileLoaded(Document *doc, ModelId model, |
72 PaneStack *paneStack, Pane *pane) | 82 PaneStack *paneStack, Pane *pane) |
73 { | 83 { |
74 m_document = doc; | 84 m_document = doc; |
396 return notFound.arg(base + noteout).arg(plugname); | 406 return notFound.arg(base + noteout).arg(plugname); |
397 } | 407 } |
398 | 408 |
399 QSettings settings; | 409 QSettings settings; |
400 settings.beginGroup("Analyser"); | 410 settings.beginGroup("Analyser"); |
401 bool precise = settings.value("precision-analysis", false).toBool(); | 411 |
402 bool lowamp = settings.value("lowamp-analysis", false).toBool(); | 412 bool precise = false, lowamp = true, onset = true, prune = true; |
403 bool onset = settings.value("onset-analysis", true).toBool(); // should these be the same as in MainWindow.cpp? | 413 |
404 bool prune = settings.value("prune-analysis", true).toBool(); | 414 std::map<QString, bool &> flags { |
415 { "precision-analysis", precise }, | |
416 { "lowamp-analysis", lowamp }, | |
417 { "onset-analysis", onset }, | |
418 { "prune-analysis", prune } | |
419 }; | |
420 | |
421 auto keyMap = getAnalysisSettings(); | |
422 | |
423 for (auto p: flags) { | |
424 auto ki = keyMap.find(p.first); | |
425 if (ki != keyMap.end()) { | |
426 p.second = settings.value(ki->first, ki->second).toBool(); | |
427 } else { | |
428 throw std::logic_error("Internal error: One or more analysis settings keys not found in map: check addAnalyses and getAnalysisSettings"); | |
429 } | |
430 } | |
431 | |
405 settings.endGroup(); | 432 settings.endGroup(); |
406 | 433 |
407 Transform t = tf->getDefaultTransformFor | 434 Transform t = tf->getDefaultTransformFor |
408 (base + f0out, waveFileModel->getSampleRate()); | 435 (base + f0out, waveFileModel->getSampleRate()); |
409 t.setStepSize(256); | 436 t.setStepSize(256); |