Mercurial > hg > svgui
comparison layer/NoteLayer.cpp @ 197:6b023411087b
* Work on harmonising colour and scale ranges between types of layer
* Add normalize options to colour 3d plot layer
author | Chris Cannam |
---|---|
date | Thu, 01 Feb 2007 14:31:28 +0000 |
parents | 33929e0c3c6b |
children | c2ed5014d4ff |
comparison
equal
deleted
inserted
replaced
196:22c99c8aa1e0 | 197:6b023411087b |
---|---|
17 | 17 |
18 #include "data/model/Model.h" | 18 #include "data/model/Model.h" |
19 #include "base/RealTime.h" | 19 #include "base/RealTime.h" |
20 #include "base/Profiler.h" | 20 #include "base/Profiler.h" |
21 #include "base/Pitch.h" | 21 #include "base/Pitch.h" |
22 #include "base/LogRange.h" | |
22 #include "view/View.h" | 23 #include "view/View.h" |
23 | 24 |
24 #include "data/model/NoteModel.h" | 25 #include "data/model/NoteModel.h" |
25 | 26 |
26 #include "widgets/ItemEditDialog.h" | 27 #include "widgets/ItemEditDialog.h" |
483 | 484 |
484 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; | 485 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; |
485 | 486 |
486 } else if (log) { | 487 } else if (log) { |
487 | 488 |
488 min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min); | 489 LogRange::mapRange(min, max); |
489 max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max); | |
490 | 490 |
491 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; | 491 std::cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << std::endl; |
492 | 492 |
493 } | 493 } |
494 | 494 |
504 min = Pitch::getFrequencyForPitch(lrintf(min)); | 504 min = Pitch::getFrequencyForPitch(lrintf(min)); |
505 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); | 505 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); |
506 } | 506 } |
507 | 507 |
508 if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { | 508 if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { |
509 min = (min < 0.0) ? -log10(-min) : (min == 0.0) ? 0.0 : log10(min); | 509 LogRange::mapRange(min, max); |
510 max = (max < 0.0) ? -log10(-max) : (max == 0.0) ? 0.0 : log10(max); | |
511 log = true; | 510 log = true; |
512 } | 511 } |
513 } | 512 } |
514 | 513 |
515 if (max == min) max = min + 1.0; | 514 if (max == min) max = min + 1.0; |
531 lrintf((val - lrintf(val)) * 100)); | 530 lrintf((val - lrintf(val)) * 100)); |
532 // std::cerr << "shouldConvertMIDIToHz true, val now = " << val << std::endl; | 531 // std::cerr << "shouldConvertMIDIToHz true, val now = " << val << std::endl; |
533 } | 532 } |
534 | 533 |
535 if (logarithmic) { | 534 if (logarithmic) { |
536 val = (val < 0.0) ? -log10(-val) : (val == 0.0) ? 0.0 : log10(val); | 535 val = LogRange::map(val); |
537 // std::cerr << "logarithmic true, val now = " << val << std::endl; | 536 // std::cerr << "logarithmic true, val now = " << val << std::endl; |
538 } | 537 } |
539 | 538 |
540 int y = int(h - ((val - min) * h) / (max - min)) - 1; | 539 int y = int(h - ((val - min) * h) / (max - min)) - 1; |
541 // std::cerr << "y = " << y << std::endl; | 540 // std::cerr << "y = " << y << std::endl; |
552 getScaleExtents(v, min, max, logarithmic); | 551 getScaleExtents(v, min, max, logarithmic); |
553 | 552 |
554 float val = min + (float(h - y) * float(max - min)) / h; | 553 float val = min + (float(h - y) * float(max - min)) / h; |
555 | 554 |
556 if (logarithmic) { | 555 if (logarithmic) { |
557 val = pow(10, val); | 556 val = powf(10.f, val); |
558 } | 557 } |
559 | 558 |
560 if (shouldConvertMIDIToHz()) { | 559 if (shouldConvertMIDIToHz()) { |
561 val = Pitch::getPitchForFrequency(val); | 560 val = Pitch::getPitchForFrequency(val); |
562 } | 561 } |