Mercurial > hg > tony
comparison src/Analyser.cpp @ 403:cc33cdb114f6
Merge from cxx11 branch
author | Chris Cannam |
---|---|
date | Mon, 23 Mar 2015 11:26:28 +0000 |
parents | a0eedd10dee3 |
children | 0a12d7e79b74 |
comparison
equal
deleted
inserted
replaced
401:1610b2b03203 | 403:cc33cdb114f6 |
---|---|
156 m_currentCandidate = -1; | 156 m_currentCandidate = -1; |
157 m_reAnalysingSelection = Selection(); | 157 m_reAnalysingSelection = Selection(); |
158 } | 158 } |
159 | 159 |
160 bool | 160 bool |
161 Analyser::getDisplayFrequencyExtents(float &min, float &max) | 161 Analyser::getDisplayFrequencyExtents(double &min, double &max) |
162 { | 162 { |
163 if (!m_layers[Spectrogram]) return false; | 163 if (!m_layers[Spectrogram]) return false; |
164 return m_layers[Spectrogram]->getDisplayExtents(min, max); | 164 return m_layers[Spectrogram]->getDisplayExtents(min, max); |
165 } | 165 } |
166 | 166 |
167 bool | 167 bool |
168 Analyser::setDisplayFrequencyExtents(float min, float max) | 168 Analyser::setDisplayFrequencyExtents(double min, double max) |
169 { | 169 { |
170 if (!m_layers[Spectrogram]) return false; | 170 if (!m_layers[Spectrogram]) return false; |
171 m_layers[Spectrogram]->setDisplayExtents(min, max); | 171 m_layers[Spectrogram]->setDisplayExtents(min, max); |
172 return true; | 172 return true; |
173 } | 173 } |
418 flexiNoteLayer->setBaseColour(cdb->getColourIndex(tr("Bright Blue"))); | 418 flexiNoteLayer->setBaseColour(cdb->getColourIndex(tr("Bright Blue"))); |
419 PlayParameters *params = flexiNoteLayer->getPlayParameters(); | 419 PlayParameters *params = flexiNoteLayer->getPlayParameters(); |
420 if (params) params->setPlayPan(1); | 420 if (params) params->setPlayPan(1); |
421 connect(flexiNoteLayer, SIGNAL(modelCompletionChanged()), | 421 connect(flexiNoteLayer, SIGNAL(modelCompletionChanged()), |
422 this, SLOT(layerCompletionChanged())); | 422 this, SLOT(layerCompletionChanged())); |
423 connect(flexiNoteLayer, SIGNAL(reAnalyseRegion(int, int, float, float)), | 423 connect(flexiNoteLayer, SIGNAL(reAnalyseRegion(sv_frame_t, sv_frame_t, float, float)), |
424 this, SLOT(reAnalyseRegion(int, int, float, float))); | 424 this, SLOT(reAnalyseRegion(sv_frame_t, sv_frame_t, float, float))); |
425 connect(flexiNoteLayer, SIGNAL(materialiseReAnalysis()), | 425 connect(flexiNoteLayer, SIGNAL(materialiseReAnalysis()), |
426 this, SLOT(materialiseReAnalysis())); | 426 this, SLOT(materialiseReAnalysis())); |
427 } | 427 } |
428 | 428 |
429 return ""; | 429 return ""; |
430 } | 430 } |
431 | 431 |
432 void | 432 void |
433 Analyser::reAnalyseRegion(int frame0, int frame1, float freq0, float freq1) | 433 Analyser::reAnalyseRegion(sv_frame_t frame0, sv_frame_t frame1, float freq0, float freq1) |
434 { | 434 { |
435 cerr << "Analyser::reAnalyseRegion(" << frame0 << ", " << frame1 | 435 cerr << "Analyser::reAnalyseRegion(" << frame0 << ", " << frame1 |
436 << ", " << freq0 << ", " << freq1 << ")" << endl; | 436 << ", " << freq0 << ", " << freq1 << ")" << endl; |
437 showPitchCandidates(true); | 437 showPitchCandidates(true); |
438 (void)reAnalyseSelection(Selection(frame0, frame1), | 438 (void)reAnalyseSelection(Selection(frame0, frame1), |
504 (base + out, m_fileModel->getSampleRate()); | 504 (base + out, m_fileModel->getSampleRate()); |
505 t.setStepSize(256); | 505 t.setStepSize(256); |
506 t.setBlockSize(2048); | 506 t.setBlockSize(2048); |
507 | 507 |
508 if (range.isConstrained()) { | 508 if (range.isConstrained()) { |
509 t.setParameter("minfreq", range.min); | 509 t.setParameter("minfreq", float(range.min)); |
510 t.setParameter("maxfreq", range.max); | 510 t.setParameter("maxfreq", float(range.max)); |
511 t.setBlockSize(4096); | 511 t.setBlockSize(4096); |
512 } | 512 } |
513 | 513 |
514 // get time stamps that align with the 256-sample grid of the original extraction | 514 // get time stamps that align with the 256-sample grid of the original extraction |
515 int startSample = ceil(sel.getStartFrame()*1.0/256) * 256; | 515 const sv_frame_t grid = 256; |
516 int endSample = ceil(sel.getEndFrame()*1.0/256) * 256; | 516 sv_frame_t startSample = (sel.getStartFrame() / grid) * grid; |
517 if (startSample < sel.getStartFrame()) startSample += grid; | |
518 sv_frame_t endSample = (sel.getEndFrame() / grid) * grid; | |
519 if (endSample < sel.getEndFrame()) endSample += grid; | |
517 if (!range.isConstrained()) { | 520 if (!range.isConstrained()) { |
518 startSample -= 4*256; // 4*256 is for 4 frames offset due to timestamp shift | 521 startSample -= 4*grid; // 4*256 is for 4 frames offset due to timestamp shift |
519 endSample -= 4*256; | 522 endSample -= 4*grid; |
520 } else { | 523 } else { |
521 endSample -= 9*256; // MM says: not sure what the CHP plugin does there | 524 endSample -= 9*grid; // MM says: not sure what the CHP plugin does there |
522 } | 525 } |
523 RealTime start = RealTime::frame2RealTime(startSample, m_fileModel->getSampleRate()); | 526 RealTime start = RealTime::frame2RealTime(startSample, m_fileModel->getSampleRate()); |
524 RealTime end = RealTime::frame2RealTime(endSample, m_fileModel->getSampleRate()); | 527 RealTime end = RealTime::frame2RealTime(endSample, m_fileModel->getSampleRate()); |
525 | 528 |
526 RealTime duration; | 529 RealTime duration; |
800 | 803 |
801 myLayer->paste(m_pane, clip, 0, false); | 804 myLayer->paste(m_pane, clip, 0, false); |
802 } | 805 } |
803 | 806 |
804 void | 807 void |
805 Analyser::getEnclosingSelectionScope(int f, int &f0, int &f1) | 808 Analyser::getEnclosingSelectionScope(sv_frame_t f, sv_frame_t &f0, sv_frame_t &f1) |
806 { | 809 { |
807 FlexiNoteLayer *flexiNoteLayer = | 810 FlexiNoteLayer *flexiNoteLayer = |
808 qobject_cast<FlexiNoteLayer *>(m_layers[Notes]); | 811 qobject_cast<FlexiNoteLayer *>(m_layers[Notes]); |
809 | 812 |
810 int f0i = f, f1i = f; | 813 sv_frame_t f0i = f, f1i = f; |
811 int res = 1; | 814 int res = 1; |
812 | 815 |
813 if (!flexiNoteLayer) { | 816 if (!flexiNoteLayer) { |
814 f0 = f1 = f; | 817 f0 = f1 = f; |
815 return; | 818 return; |