Mercurial > hg > svgui
comparison layer/NoteLayer.cpp @ 669:123ebecd12e6 tonioni
Merge from default branch
author | Chris Cannam |
---|---|
date | Tue, 16 Jul 2013 14:45:55 +0100 |
parents | 7256926d3af1 ab9fefdaa103 |
children | 47735c9518e7 |
comparison
equal
deleted
inserted
replaced
663:1a0fdad4af4d | 669:123ebecd12e6 |
---|---|
36 | 36 |
37 #include <iostream> | 37 #include <iostream> |
38 #include <cmath> | 38 #include <cmath> |
39 #include <utility> | 39 #include <utility> |
40 | 40 |
41 //#define DEBUG_NOTE_LAYER 1 | |
42 | |
41 NoteLayer::NoteLayer() : | 43 NoteLayer::NoteLayer() : |
42 SingleColourLayer(), | 44 SingleColourLayer(), |
43 m_model(0), | 45 m_model(0), |
44 m_editing(false), | 46 m_editing(false), |
45 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), | 47 m_originalPoint(0, 0.0, 0, 1.f, tr("New Point")), |
613 if (shouldConvertMIDIToHz()) { | 615 if (shouldConvertMIDIToHz()) { |
614 min = Pitch::getFrequencyForPitch(lrintf(min)); | 616 min = Pitch::getFrequencyForPitch(lrintf(min)); |
615 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); | 617 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); |
616 } | 618 } |
617 | 619 |
620 #ifdef DEBUG_NOTE_LAYER | |
618 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; | 621 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; |
622 #endif | |
619 | 623 |
620 } else if (log) { | 624 } else if (log) { |
621 | 625 |
622 LogRange::mapRange(min, max); | 626 LogRange::mapRange(min, max); |
623 | 627 |
628 #ifdef DEBUG_NOTE_LAYER | |
624 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; | 629 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; |
630 #endif | |
625 | 631 |
626 } | 632 } |
627 | 633 |
628 } else { | 634 } else { |
629 | 635 |
653 bool logarithmic = false; | 659 bool logarithmic = false; |
654 int h = v->height(); | 660 int h = v->height(); |
655 | 661 |
656 getScaleExtents(v, min, max, logarithmic); | 662 getScaleExtents(v, min, max, logarithmic); |
657 | 663 |
658 // std::cerr << "NoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << std::endl; | 664 #ifdef DEBUG_NOTE_LAYER |
665 std::cerr << "NoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << std::endl; | |
666 #endif | |
659 | 667 |
660 if (shouldConvertMIDIToHz()) { | 668 if (shouldConvertMIDIToHz()) { |
661 val = Pitch::getFrequencyForPitch(lrintf(val), | 669 val = Pitch::getFrequencyForPitch(lrintf(val), |
662 lrintf((val - lrintf(val)) * 100)); | 670 lrintf((val - lrintf(val)) * 100)); |
663 // std::cerr << "shouldConvertMIDIToHz true, val now = " << val << std::endl; | 671 #ifdef DEBUG_NOTE_LAYER |
672 std::cerr << "shouldConvertMIDIToHz true, val now = " << val << std::endl; | |
673 #endif | |
664 } | 674 } |
665 | 675 |
666 if (logarithmic) { | 676 if (logarithmic) { |
667 val = LogRange::map(val); | 677 val = LogRange::map(val); |
668 // std::cerr << "logarithmic true, val now = " << val << std::endl; | 678 #ifdef DEBUG_NOTE_LAYER |
679 std::cerr << "logarithmic true, val now = " << val << std::endl; | |
680 #endif | |
669 } | 681 } |
670 | 682 |
671 int y = int(h - ((val - min) * h) / (max - min)) - 1; | 683 int y = int(h - ((val - min) * h) / (max - min)) - 1; |
672 // std::cerr << "y = " << y << std::endl; | 684 #ifdef DEBUG_NOTE_LAYER |
685 std::cerr << "y = " << y << std::endl; | |
686 #endif | |
673 return y; | 687 return y; |
674 } | 688 } |
675 | 689 |
676 float | 690 float |
677 NoteLayer::getValueForY(View *v, int y) const | 691 NoteLayer::getValueForY(View *v, int y) const |