comparison layer/FlexiNoteLayer.cpp @ 684:917039d333bb tonioni

Merge from default branch
author Chris Cannam
date Tue, 26 Nov 2013 14:38:48 +0000
parents layer/NoteLayer.cpp@1a0dfcbffaf1 layer/NoteLayer.cpp@47735c9518e7
children 212644efa523
comparison
equal deleted inserted replaced
680:ced5f158eda7 684:917039d333bb
248 min = Pitch::getFrequencyForPitch(lrintf(min)); 248 min = Pitch::getFrequencyForPitch(lrintf(min));
249 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 249 max = Pitch::getFrequencyForPitch(lrintf(max + 1));
250 } 250 }
251 251
252 #ifdef DEBUG_NOTE_LAYER 252 #ifdef DEBUG_NOTE_LAYER
253 std::cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << std::endl; 253 cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << endl;
254 #endif 254 #endif
255 255
256 return true; 256 return true;
257 } 257 }
258 258
271 271
272 m_scaleMinimum = min; 272 m_scaleMinimum = min;
273 m_scaleMaximum = max; 273 m_scaleMaximum = max;
274 274
275 #ifdef DEBUG_NOTE_LAYER 275 #ifdef DEBUG_NOTE_LAYER
276 std::cerr << "FlexiNoteLayer::setDisplayExtents: min = " << min << ", max = " << max << std::endl; 276 cerr << "FlexiNoteLayer::setDisplayExtents: min = " << min << ", max = " << max << endl;
277 #endif 277 #endif
278 278
279 emit layerParametersChanged(); 279 emit layerParametersChanged();
280 return true; 280 return true;
281 } 281 }
337 // see SpectrogramLayer::setVerticalZoomStep 337 // see SpectrogramLayer::setVerticalZoomStep
338 338
339 newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; 339 newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2;
340 newmin = newmax - newdist; 340 newmin = newmax - newdist;
341 341
342 // std::cerr << "newmin = " << newmin << ", newmax = " << newmax << std::endl; 342 // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl;
343 343
344 } else { 344 } else {
345 float dmid = (dmax + dmin) / 2; 345 float dmid = (dmax + dmin) / 2;
346 newmin = dmid - newdist / 2; 346 newmin = dmid - newdist / 2;
347 newmax = dmid + newdist / 2; 347 newmax = dmid + newdist / 2;
354 if (newmax > max) { 354 if (newmax > max) {
355 newmax = max; 355 newmax = max;
356 } 356 }
357 357
358 #ifdef DEBUG_NOTE_LAYER 358 #ifdef DEBUG_NOTE_LAYER
359 std::cerr << "FlexiNoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << std::endl; 359 cerr << "FlexiNoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl;
360 #endif 360 #endif
361 361
362 setDisplayExtents(newmin, newmax); 362 setDisplayExtents(newmin, newmax);
363 } 363 }
364 364
436 long frame = v->getFrameForX(x); 436 long frame = v->getFrameForX(x);
437 437
438 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame); 438 FlexiNoteModel::PointList onPoints = m_model->getPoints(frame);
439 if (onPoints.empty()) return false; 439 if (onPoints.empty()) return false;
440 440
441 // std::cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << std::endl; 441 // cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << endl;
442 442
443 int nearestDistance = -1; 443 int nearestDistance = -1;
444 444
445 for (FlexiNoteModel::PointList::const_iterator i = onPoints.begin(); 445 for (FlexiNoteModel::PointList::const_iterator i = onPoints.begin();
446 i != onPoints.end(); ++i) { 446 i != onPoints.end(); ++i) {
666 if (shouldConvertMIDIToHz()) { 666 if (shouldConvertMIDIToHz()) {
667 min = Pitch::getFrequencyForPitch(lrintf(min)); 667 min = Pitch::getFrequencyForPitch(lrintf(min));
668 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 668 max = Pitch::getFrequencyForPitch(lrintf(max + 1));
669 } 669 }
670 670
671 // std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; 671 #ifdef DEBUG_NOTE_LAYER
672 cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << endl;
673 #endif
672 674
673 } else if (log) { 675 } else if (log) {
674 676
675 LogRange::mapRange(min, max); 677 LogRange::mapRange(min, max);
676 678
677 // std::cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; 679 #ifdef DEBUG_NOTE_LAYER
678 680 cerr << "FlexiNoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << endl;
681 #endif
679 } 682 }
680 683
681 } else { 684 } else {
682 685
683 getDisplayExtents(min, max); 686 getDisplayExtents(min, max);
706 bool logarithmic = false; 709 bool logarithmic = false;
707 int h = v->height(); 710 int h = v->height();
708 711
709 getScaleExtents(v, min, max, logarithmic); 712 getScaleExtents(v, min, max, logarithmic);
710 713
711 // std::cerr << "FlexiNoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << std::endl; 714 #ifdef DEBUG_NOTE_LAYER
715 cerr << "FlexiNoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << endl;
716 #endif
712 717
713 if (shouldConvertMIDIToHz()) { 718 if (shouldConvertMIDIToHz()) {
714 val = Pitch::getFrequencyForPitch(lrintf(val), 719 val = Pitch::getFrequencyForPitch(lrintf(val),
715 lrintf((val - lrintf(val)) * 100)); 720 lrintf((val - lrintf(val)) * 100));
716 // std::cerr << "shouldConvertMIDIToHz true, val now = " << val << std::endl; 721 #ifdef DEBUG_NOTE_LAYER
722 cerr << "shouldConvertMIDIToHz true, val now = " << val << endl;
723 #endif
717 } 724 }
718 725
719 if (logarithmic) { 726 if (logarithmic) {
720 val = LogRange::map(val); 727 val = LogRange::map(val);
721 // std::cerr << "logarithmic true, val now = " << val << std::endl; 728 #ifdef DEBUG_NOTE_LAYER
729 cerr << "logarithmic true, val now = " << val << endl;
730 #endif
722 } 731 }
723 732
724 int y = int(h - ((val - min) * h) / (max - min)) - 1; 733 int y = int(h - ((val - min) * h) / (max - min)) - 1;
725 // std::cerr << "y = " << y << std::endl; 734 #ifdef DEBUG_NOTE_LAYER
735 cerr << "y = " << y << endl;
736 #endif
726 return y; 737 return y;
727 } 738 }
728 739
729 float 740 float
730 FlexiNoteLayer::getValueForY(View *v, int y) const 741 FlexiNoteLayer::getValueForY(View *v, int y) const