comparison layer/NoteLayer.cpp @ 944:78c152e4db95

Merge from branch tonioni
author Chris Cannam
date Mon, 20 Apr 2015 09:12:17 +0100
parents b66fb15de477
children 94e4952a6774
comparison
equal deleted inserted replaced
896:78e041e45ff0 944:78c152e4db95
207 // unit.startsWith("midi")) return true; 207 // unit.startsWith("midi")) return true;
208 // return false; 208 // return false;
209 } 209 }
210 210
211 bool 211 bool
212 NoteLayer::getValueExtents(float &min, float &max, 212 NoteLayer::getValueExtents(double &min, double &max,
213 bool &logarithmic, QString &unit) const 213 bool &logarithmic, QString &unit) const
214 { 214 {
215 if (!m_model) return false; 215 if (!m_model) return false;
216 min = m_model->getValueMinimum(); 216 min = m_model->getValueMinimum();
217 max = m_model->getValueMaximum(); 217 max = m_model->getValueMaximum();
218 218
219 if (shouldConvertMIDIToHz()) { 219 if (shouldConvertMIDIToHz()) {
220 unit = "Hz"; 220 unit = "Hz";
221 min = Pitch::getFrequencyForPitch(lrintf(min)); 221 min = Pitch::getFrequencyForPitch(int(lrint(min)));
222 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 222 max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
223 } else unit = getScaleUnits(); 223 } else unit = getScaleUnits();
224 224
225 if (m_verticalScale == MIDIRangeScale || 225 if (m_verticalScale == MIDIRangeScale ||
226 m_verticalScale == LogScale) logarithmic = true; 226 m_verticalScale == LogScale) logarithmic = true;
227 227
228 return true; 228 return true;
229 } 229 }
230 230
231 bool 231 bool
232 NoteLayer::getDisplayExtents(float &min, float &max) const 232 NoteLayer::getDisplayExtents(double &min, double &max) const
233 { 233 {
234 if (!m_model || shouldAutoAlign()) return false; 234 if (!m_model || shouldAutoAlign()) return false;
235 235
236 if (m_verticalScale == MIDIRangeScale) { 236 if (m_verticalScale == MIDIRangeScale) {
237 min = Pitch::getFrequencyForPitch(0); 237 min = Pitch::getFrequencyForPitch(0);
246 min = m_scaleMinimum; 246 min = m_scaleMinimum;
247 max = m_scaleMaximum; 247 max = m_scaleMaximum;
248 } 248 }
249 249
250 if (shouldConvertMIDIToHz()) { 250 if (shouldConvertMIDIToHz()) {
251 min = Pitch::getFrequencyForPitch(lrintf(min)); 251 min = Pitch::getFrequencyForPitch(int(lrint(min)));
252 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 252 max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
253 } 253 }
254 254
255 #ifdef DEBUG_NOTE_LAYER 255 #ifdef DEBUG_NOTE_LAYER
256 cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << endl; 256 cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << endl;
257 #endif 257 #endif
258 258
259 return true; 259 return true;
260 } 260 }
261 261
262 bool 262 bool
263 NoteLayer::setDisplayExtents(float min, float max) 263 NoteLayer::setDisplayExtents(double min, double max)
264 { 264 {
265 if (!m_model) return false; 265 if (!m_model) return false;
266 266
267 if (min == max) { 267 if (min == max) {
268 if (min == 0.f) { 268 if (min == 0.f) {
300 if (!m_model) return 0; 300 if (!m_model) return 0;
301 301
302 RangeMapper *mapper = getNewVerticalZoomRangeMapper(); 302 RangeMapper *mapper = getNewVerticalZoomRangeMapper();
303 if (!mapper) return 0; 303 if (!mapper) return 0;
304 304
305 float dmin, dmax; 305 double dmin, dmax;
306 getDisplayExtents(dmin, dmax); 306 getDisplayExtents(dmin, dmax);
307 307
308 int nr = mapper->getPositionForValue(dmax - dmin); 308 int nr = mapper->getPositionForValue(dmax - dmin);
309 309
310 delete mapper; 310 delete mapper;
321 if (!m_model) return; 321 if (!m_model) return;
322 322
323 RangeMapper *mapper = getNewVerticalZoomRangeMapper(); 323 RangeMapper *mapper = getNewVerticalZoomRangeMapper();
324 if (!mapper) return; 324 if (!mapper) return;
325 325
326 float min, max; 326 double min, max;
327 bool logarithmic; 327 bool logarithmic;
328 QString unit; 328 QString unit;
329 getValueExtents(min, max, logarithmic, unit); 329 getValueExtents(min, max, logarithmic, unit);
330 330
331 float dmin, dmax; 331 double dmin, dmax;
332 getDisplayExtents(dmin, dmax); 332 getDisplayExtents(dmin, dmax);
333 333
334 float newdist = mapper->getValueForPosition(100 - step); 334 double newdist = mapper->getValueForPosition(100 - step);
335 335
336 float newmin, newmax; 336 double newmin, newmax;
337 337
338 if (logarithmic) { 338 if (logarithmic) {
339 339
340 // see SpectrogramLayer::setVerticalZoomStep 340 // see SpectrogramLayer::setVerticalZoomStep
341 341
342 newmax = (newdist + sqrtf(newdist*newdist + 4*dmin*dmax)) / 2; 342 newmax = (newdist + sqrt(newdist*newdist + 4*dmin*dmax)) / 2;
343 newmin = newmax - newdist; 343 newmin = newmax - newdist;
344 344
345 // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl; 345 // cerr << "newmin = " << newmin << ", newmax = " << newmax << endl;
346 346
347 } else { 347 } else {
348 float dmid = (dmax + dmin) / 2; 348 double dmid = (dmax + dmin) / 2;
349 newmin = dmid - newdist / 2; 349 newmin = dmid - newdist / 2;
350 newmax = dmid + newdist / 2; 350 newmax = dmid + newdist / 2;
351 } 351 }
352 352
353 if (newmin < min) { 353 if (newmin < min) {
370 { 370 {
371 if (!m_model) return 0; 371 if (!m_model) return 0;
372 372
373 RangeMapper *mapper; 373 RangeMapper *mapper;
374 374
375 float min, max; 375 double min, max;
376 bool logarithmic; 376 bool logarithmic;
377 QString unit; 377 QString unit;
378 getValueExtents(min, max, logarithmic, unit); 378 getValueExtents(min, max, logarithmic, unit);
379 379
380 if (min == max) return 0; 380 if (min == max) return 0;
391 NoteModel::PointList 391 NoteModel::PointList
392 NoteLayer::getLocalPoints(View *v, int x) const 392 NoteLayer::getLocalPoints(View *v, int x) const
393 { 393 {
394 if (!m_model) return NoteModel::PointList(); 394 if (!m_model) return NoteModel::PointList();
395 395
396 int frame = v->getFrameForX(x); 396 sv_frame_t frame = v->getFrameForX(x);
397 397
398 NoteModel::PointList onPoints = 398 NoteModel::PointList onPoints =
399 m_model->getPoints(frame); 399 m_model->getPoints(frame);
400 400
401 if (!onPoints.empty()) { 401 if (!onPoints.empty()) {
434 bool 434 bool
435 NoteLayer::getPointToDrag(View *v, int x, int y, NoteModel::Point &p) const 435 NoteLayer::getPointToDrag(View *v, int x, int y, NoteModel::Point &p) const
436 { 436 {
437 if (!m_model) return false; 437 if (!m_model) return false;
438 438
439 int frame = v->getFrameForX(x); 439 sv_frame_t frame = v->getFrameForX(x);
440 440
441 NoteModel::PointList onPoints = m_model->getPoints(frame); 441 NoteModel::PointList onPoints = m_model->getPoints(frame);
442 if (onPoints.empty()) return false; 442 if (onPoints.empty()) return false;
443 443
444 // cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << endl; 444 // cerr << "frame " << frame << ": " << onPoints.size() << " candidate points" << endl;
504 504
505 QString pitchText; 505 QString pitchText;
506 506
507 if (shouldConvertMIDIToHz()) { 507 if (shouldConvertMIDIToHz()) {
508 508
509 int mnote = lrintf(note.value); 509 int mnote = int(lrint(note.value));
510 int cents = lrintf((note.value - mnote) * 100); 510 int cents = int(lrint((note.value - float(mnote)) * 100));
511 float freq = Pitch::getFrequencyForPitch(mnote, cents); 511 double freq = Pitch::getFrequencyForPitch(mnote, cents);
512 pitchText = tr("%1 (%2, %3 Hz)") 512 pitchText = tr("%1 (%2, %3 Hz)")
513 .arg(Pitch::getPitchLabel(mnote, cents)) 513 .arg(Pitch::getPitchLabel(mnote, cents))
514 .arg(mnote) 514 .arg(mnote)
515 .arg(freq); 515 .arg(freq);
516 516
545 getYForValue(v, note.value)); 545 getYForValue(v, note.value));
546 return text; 546 return text;
547 } 547 }
548 548
549 bool 549 bool
550 NoteLayer::snapToFeatureFrame(View *v, int &frame, 550 NoteLayer::snapToFeatureFrame(View *v, sv_frame_t &frame,
551 int &resolution, 551 int &resolution,
552 SnapType snap) const 552 SnapType snap) const
553 { 553 {
554 if (!m_model) { 554 if (!m_model) {
555 return Layer::snapToFeatureFrame(v, frame, resolution, snap); 555 return Layer::snapToFeatureFrame(v, frame, resolution, snap);
565 frame = points.begin()->frame; 565 frame = points.begin()->frame;
566 return true; 566 return true;
567 } 567 }
568 568
569 points = m_model->getPoints(frame, frame); 569 points = m_model->getPoints(frame, frame);
570 int snapped = frame; 570 sv_frame_t snapped = frame;
571 bool found = false; 571 bool found = false;
572 572
573 for (NoteModel::PointList::const_iterator i = points.begin(); 573 for (NoteModel::PointList::const_iterator i = points.begin();
574 i != points.end(); ++i) { 574 i != points.end(); ++i) {
575 575
617 frame = snapped; 617 frame = snapped;
618 return found; 618 return found;
619 } 619 }
620 620
621 void 621 void
622 NoteLayer::getScaleExtents(View *v, float &min, float &max, bool &log) const 622 NoteLayer::getScaleExtents(View *v, double &min, double &max, bool &log) const
623 { 623 {
624 min = 0.0; 624 min = 0.0;
625 max = 0.0; 625 max = 0.0;
626 log = false; 626 log = false;
627 627
635 635
636 min = m_model->getValueMinimum(); 636 min = m_model->getValueMinimum();
637 max = m_model->getValueMaximum(); 637 max = m_model->getValueMaximum();
638 638
639 if (shouldConvertMIDIToHz()) { 639 if (shouldConvertMIDIToHz()) {
640 min = Pitch::getFrequencyForPitch(lrintf(min)); 640 min = Pitch::getFrequencyForPitch(int(lrint(min)));
641 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 641 max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
642 } 642 }
643 643
644 #ifdef DEBUG_NOTE_LAYER 644 #ifdef DEBUG_NOTE_LAYER
645 cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << endl; 645 cerr << "NoteLayer[" << this << "]::getScaleExtents: min = " << min << ", max = " << max << ", log = " << log << endl;
646 #endif 646 #endif
661 661
662 if (m_verticalScale == MIDIRangeScale) { 662 if (m_verticalScale == MIDIRangeScale) {
663 min = Pitch::getFrequencyForPitch(0); 663 min = Pitch::getFrequencyForPitch(0);
664 max = Pitch::getFrequencyForPitch(127); 664 max = Pitch::getFrequencyForPitch(127);
665 } else if (shouldConvertMIDIToHz()) { 665 } else if (shouldConvertMIDIToHz()) {
666 min = Pitch::getFrequencyForPitch(lrintf(min)); 666 min = Pitch::getFrequencyForPitch(int(lrint(min)));
667 max = Pitch::getFrequencyForPitch(lrintf(max + 1)); 667 max = Pitch::getFrequencyForPitch(int(lrint(max + 1)));
668 } 668 }
669 669
670 if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { 670 if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) {
671 LogRange::mapRange(min, max); 671 LogRange::mapRange(min, max);
672 log = true; 672 log = true;
675 675
676 if (max == min) max = min + 1.0; 676 if (max == min) max = min + 1.0;
677 } 677 }
678 678
679 int 679 int
680 NoteLayer::getYForValue(View *v, float val) const 680 NoteLayer::getYForValue(View *v, double val) const
681 { 681 {
682 float min = 0.0, max = 0.0; 682 double min = 0.0, max = 0.0;
683 bool logarithmic = false; 683 bool logarithmic = false;
684 int h = v->height(); 684 int h = v->height();
685 685
686 getScaleExtents(v, min, max, logarithmic); 686 getScaleExtents(v, min, max, logarithmic);
687 687
688 #ifdef DEBUG_NOTE_LAYER 688 #ifdef DEBUG_NOTE_LAYER
689 cerr << "NoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << endl; 689 cerr << "NoteLayer[" << this << "]::getYForValue(" << val << "): min = " << min << ", max = " << max << ", log = " << logarithmic << endl;
690 #endif 690 #endif
691 691
692 if (shouldConvertMIDIToHz()) { 692 if (shouldConvertMIDIToHz()) {
693 val = Pitch::getFrequencyForPitch(lrintf(val), 693 val = Pitch::getFrequencyForPitch(int(lrint(val)),
694 lrintf((val - lrintf(val)) * 100)); 694 int(lrint((val - rint(val)) * 100)));
695 #ifdef DEBUG_NOTE_LAYER 695 #ifdef DEBUG_NOTE_LAYER
696 cerr << "shouldConvertMIDIToHz true, val now = " << val << endl; 696 cerr << "shouldConvertMIDIToHz true, val now = " << val << endl;
697 #endif 697 #endif
698 } 698 }
699 699
709 cerr << "y = " << y << endl; 709 cerr << "y = " << y << endl;
710 #endif 710 #endif
711 return y; 711 return y;
712 } 712 }
713 713
714 float 714 double
715 NoteLayer::getValueForY(View *v, int y) const 715 NoteLayer::getValueForY(View *v, int y) const
716 { 716 {
717 float min = 0.0, max = 0.0; 717 double min = 0.0, max = 0.0;
718 bool logarithmic = false; 718 bool logarithmic = false;
719 int h = v->height(); 719 int h = v->height();
720 720
721 getScaleExtents(v, min, max, logarithmic); 721 getScaleExtents(v, min, max, logarithmic);
722 722
723 float val = min + (float(h - y) * float(max - min)) / h; 723 double val = min + (double(h - y) * double(max - min)) / h;
724 724
725 if (logarithmic) { 725 if (logarithmic) {
726 val = powf(10.f, val); 726 val = pow(10.0, val);
727 } 727 }
728 728
729 if (shouldConvertMIDIToHz()) { 729 if (shouldConvertMIDIToHz()) {
730 val = Pitch::getPitchForFrequency(val); 730 val = Pitch::getPitchForFrequency(val);
731 } 731 }
743 void 743 void
744 NoteLayer::paint(View *v, QPainter &paint, QRect rect) const 744 NoteLayer::paint(View *v, QPainter &paint, QRect rect) const
745 { 745 {
746 if (!m_model || !m_model->isOK()) return; 746 if (!m_model || !m_model->isOK()) return;
747 747
748 int sampleRate = m_model->getSampleRate(); 748 sv_samplerate_t sampleRate = m_model->getSampleRate();
749 if (!sampleRate) return; 749 if (!sampleRate) return;
750 750
751 // Profiler profiler("NoteLayer::paint", true); 751 // Profiler profiler("NoteLayer::paint", true);
752 752
753 int x0 = rect.left(), x1 = rect.right(); 753 int x0 = rect.left(), x1 = rect.right();
754 int frame0 = v->getFrameForX(x0); 754 sv_frame_t frame0 = v->getFrameForX(x0);
755 int frame1 = v->getFrameForX(x1); 755 sv_frame_t frame1 = v->getFrameForX(x1);
756 756
757 NoteModel::PointList points(m_model->getPoints(frame0, frame1)); 757 NoteModel::PointList points(m_model->getPoints(frame0, frame1));
758 if (points.empty()) return; 758 if (points.empty()) return;
759 759
760 paint.setPen(getBaseQColor()); 760 paint.setPen(getBaseQColor());
763 brushColour.setAlpha(80); 763 brushColour.setAlpha(80);
764 764
765 // SVDEBUG << "NoteLayer::paint: resolution is " 765 // SVDEBUG << "NoteLayer::paint: resolution is "
766 // << m_model->getResolution() << " frames" << endl; 766 // << m_model->getResolution() << " frames" << endl;
767 767
768 float min = m_model->getValueMinimum(); 768 double min = m_model->getValueMinimum();
769 float max = m_model->getValueMaximum(); 769 double max = m_model->getValueMaximum();
770 if (max == min) max = min + 1.0; 770 if (max == min) max = min + 1.0;
771 771
772 QPoint localPos; 772 QPoint localPos;
773 NoteModel::Point illuminatePoint(0); 773 NoteModel::Point illuminatePoint(0);
774 bool shouldIlluminate = false; 774 bool shouldIlluminate = false;
847 NoteLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const 847 NoteLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const
848 { 848 {
849 if (!m_model || m_model->getPoints().empty()) return; 849 if (!m_model || m_model->getPoints().empty()) return;
850 850
851 QString unit; 851 QString unit;
852 float min, max; 852 double min, max;
853 bool logarithmic; 853 bool logarithmic;
854 854
855 int w = getVerticalScaleWidth(v, false, paint); 855 int w = getVerticalScaleWidth(v, false, paint);
856 int h = v->height(); 856 int h = v->height();
857 857
886 { 886 {
887 // SVDEBUG << "NoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl; 887 // SVDEBUG << "NoteLayer::drawStart(" << e->x() << "," << e->y() << ")" << endl;
888 888
889 if (!m_model) return; 889 if (!m_model) return;
890 890
891 int frame = v->getFrameForX(e->x()); 891 sv_frame_t frame = v->getFrameForX(e->x());
892 if (frame < 0) frame = 0; 892 if (frame < 0) frame = 0;
893 frame = frame / m_model->getResolution() * m_model->getResolution(); 893 frame = frame / m_model->getResolution() * m_model->getResolution();
894 894
895 float value = getValueForY(v, e->y()); 895 double value = getValueForY(v, e->y());
896 896
897 m_editingPoint = NoteModel::Point(frame, value, 0, 0.8, tr("New Point")); 897 m_editingPoint = NoteModel::Point(frame, float(value), 0, 0.8f, tr("New Point"));
898 m_originalPoint = m_editingPoint; 898 m_originalPoint = m_editingPoint;
899 899
900 if (m_editingCommand) finish(m_editingCommand); 900 if (m_editingCommand) finish(m_editingCommand);
901 m_editingCommand = new NoteModel::EditCommand(m_model, 901 m_editingCommand = new NoteModel::EditCommand(m_model,
902 tr("Draw Point")); 902 tr("Draw Point"));
910 { 910 {
911 // SVDEBUG << "NoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl; 911 // SVDEBUG << "NoteLayer::drawDrag(" << e->x() << "," << e->y() << ")" << endl;
912 912
913 if (!m_model || !m_editing) return; 913 if (!m_model || !m_editing) return;
914 914
915 int frame = v->getFrameForX(e->x()); 915 sv_frame_t frame = v->getFrameForX(e->x());
916 if (frame < 0) frame = 0; 916 if (frame < 0) frame = 0;
917 frame = frame / m_model->getResolution() * m_model->getResolution(); 917 frame = frame / m_model->getResolution() * m_model->getResolution();
918 918
919 float newValue = getValueForY(v, e->y()); 919 double newValue = getValueForY(v, e->y());
920 920
921 int newFrame = m_editingPoint.frame; 921 sv_frame_t newFrame = m_editingPoint.frame;
922 int newDuration = frame - newFrame; 922 sv_frame_t newDuration = frame - newFrame;
923 if (newDuration < 0) { 923 if (newDuration < 0) {
924 newFrame = frame; 924 newFrame = frame;
925 newDuration = -newDuration; 925 newDuration = -newDuration;
926 } else if (newDuration == 0) { 926 } else if (newDuration == 0) {
927 newDuration = 1; 927 newDuration = 1;
928 } 928 }
929 929
930 m_editingCommand->deletePoint(m_editingPoint); 930 m_editingCommand->deletePoint(m_editingPoint);
931 m_editingPoint.frame = newFrame; 931 m_editingPoint.frame = newFrame;
932 m_editingPoint.value = newValue; 932 m_editingPoint.value = float(newValue);
933 m_editingPoint.duration = newDuration; 933 m_editingPoint.duration = newDuration;
934 m_editingCommand->addPoint(m_editingPoint); 934 m_editingCommand->addPoint(m_editingPoint);
935 } 935 }
936 936
937 void 937 void
1017 int xdist = e->x() - m_dragStartX; 1017 int xdist = e->x() - m_dragStartX;
1018 int ydist = e->y() - m_dragStartY; 1018 int ydist = e->y() - m_dragStartY;
1019 int newx = m_dragPointX + xdist; 1019 int newx = m_dragPointX + xdist;
1020 int newy = m_dragPointY + ydist; 1020 int newy = m_dragPointY + ydist;
1021 1021
1022 int frame = v->getFrameForX(newx); 1022 sv_frame_t frame = v->getFrameForX(newx);
1023 if (frame < 0) frame = 0; 1023 if (frame < 0) frame = 0;
1024 frame = frame / m_model->getResolution() * m_model->getResolution(); 1024 frame = frame / m_model->getResolution() * m_model->getResolution();
1025 1025
1026 float value = getValueForY(v, newy); 1026 double value = getValueForY(v, newy);
1027 1027
1028 if (!m_editingCommand) { 1028 if (!m_editingCommand) {
1029 m_editingCommand = new NoteModel::EditCommand(m_model, 1029 m_editingCommand = new NoteModel::EditCommand(m_model,
1030 tr("Drag Point")); 1030 tr("Drag Point"));
1031 } 1031 }
1032 1032
1033 m_editingCommand->deletePoint(m_editingPoint); 1033 m_editingCommand->deletePoint(m_editingPoint);
1034 m_editingPoint.frame = frame; 1034 m_editingPoint.frame = frame;
1035 m_editingPoint.value = value; 1035 m_editingPoint.value = float(value);
1036 m_editingCommand->addPoint(m_editingPoint); 1036 m_editingCommand->addPoint(m_editingPoint);
1037 } 1037 }
1038 1038
1039 void 1039 void
1040 NoteLayer::editEnd(View *, QMouseEvent *) 1040 NoteLayer::editEnd(View *, QMouseEvent *)
1105 delete dialog; 1105 delete dialog;
1106 return true; 1106 return true;
1107 } 1107 }
1108 1108
1109 void 1109 void
1110 NoteLayer::moveSelection(Selection s, int newStartFrame) 1110 NoteLayer::moveSelection(Selection s, sv_frame_t newStartFrame)
1111 { 1111 {
1112 if (!m_model) return; 1112 if (!m_model) return;
1113 1113
1114 NoteModel::EditCommand *command = 1114 NoteModel::EditCommand *command =
1115 new NoteModel::EditCommand(m_model, tr("Drag Selection")); 1115 new NoteModel::EditCommand(m_model, tr("Drag Selection"));
1149 for (NoteModel::PointList::iterator i = points.begin(); 1149 for (NoteModel::PointList::iterator i = points.begin();
1150 i != points.end(); ++i) { 1150 i != points.end(); ++i) {
1151 1151
1152 if (s.contains(i->frame)) { 1152 if (s.contains(i->frame)) {
1153 1153
1154 double targetStart = i->frame; 1154 double targetStart = double(i->frame);
1155 targetStart = newSize.getStartFrame() + 1155 targetStart = double(newSize.getStartFrame()) +
1156 double(targetStart - s.getStartFrame()) * ratio; 1156 targetStart - double(s.getStartFrame()) * ratio;
1157 1157
1158 double targetEnd = i->frame + i->duration; 1158 double targetEnd = double(i->frame + i->duration);
1159 targetEnd = newSize.getStartFrame() + 1159 targetEnd = double(newSize.getStartFrame()) +
1160 double(targetEnd - s.getStartFrame()) * ratio; 1160 targetEnd - double(s.getStartFrame()) * ratio;
1161 1161
1162 NoteModel::Point newPoint(*i); 1162 NoteModel::Point newPoint(*i);
1163 newPoint.frame = lrint(targetStart); 1163 newPoint.frame = lrint(targetStart);
1164 newPoint.duration = lrint(targetEnd - targetStart); 1164 newPoint.duration = lrint(targetEnd - targetStart);
1165 command->deletePoint(*i); 1165 command->deletePoint(*i);
1209 } 1209 }
1210 } 1210 }
1211 } 1211 }
1212 1212
1213 bool 1213 bool
1214 NoteLayer::paste(View *v, const Clipboard &from, int /* frameOffset */, bool /* interactive */) 1214 NoteLayer::paste(View *v, const Clipboard &from, sv_frame_t /* frameOffset */, bool /* interactive */)
1215 { 1215 {
1216 if (!m_model) return false; 1216 if (!m_model) return false;
1217 1217
1218 const Clipboard::PointList &points = from.getPoints(); 1218 const Clipboard::PointList &points = from.getPoints();
1219 1219
1241 1241
1242 for (Clipboard::PointList::const_iterator i = points.begin(); 1242 for (Clipboard::PointList::const_iterator i = points.begin();
1243 i != points.end(); ++i) { 1243 i != points.end(); ++i) {
1244 1244
1245 if (!i->haveFrame()) continue; 1245 if (!i->haveFrame()) continue;
1246 int frame = 0; 1246 sv_frame_t frame = 0;
1247 1247
1248 if (!realign) { 1248 if (!realign) {
1249 1249
1250 frame = i->getFrame(); 1250 frame = i->getFrame();
1251 1251
1266 else newPoint.value = (m_model->getValueMinimum() + 1266 else newPoint.value = (m_model->getValueMinimum() +
1267 m_model->getValueMaximum()) / 2; 1267 m_model->getValueMaximum()) / 2;
1268 if (i->haveLevel()) newPoint.level = i->getLevel(); 1268 if (i->haveLevel()) newPoint.level = i->getLevel();
1269 if (i->haveDuration()) newPoint.duration = i->getDuration(); 1269 if (i->haveDuration()) newPoint.duration = i->getDuration();
1270 else { 1270 else {
1271 int nextFrame = frame; 1271 sv_frame_t nextFrame = frame;
1272 Clipboard::PointList::const_iterator j = i; 1272 Clipboard::PointList::const_iterator j = i;
1273 for (; j != points.end(); ++j) { 1273 for (; j != points.end(); ++j) {
1274 if (!j->haveFrame()) continue; 1274 if (!j->haveFrame()) continue;
1275 if (j != i) break; 1275 if (j != i) break;
1276 } 1276 }
1290 finish(command); 1290 finish(command);
1291 return true; 1291 return true;
1292 } 1292 }
1293 1293
1294 void 1294 void
1295 NoteLayer::addNoteOn(int frame, int pitch, int velocity) 1295 NoteLayer::addNoteOn(sv_frame_t frame, int pitch, int velocity)
1296 { 1296 {
1297 m_pendingNoteOns.insert(Note(frame, pitch, 0, float(velocity) / 127.0, "")); 1297 m_pendingNoteOns.insert(Note(frame, float(pitch), 0, float(velocity) / 127.f, ""));
1298 } 1298 }
1299 1299
1300 void 1300 void
1301 NoteLayer::addNoteOff(int frame, int pitch) 1301 NoteLayer::addNoteOff(sv_frame_t frame, int pitch)
1302 { 1302 {
1303 for (NoteSet::iterator i = m_pendingNoteOns.begin(); 1303 for (NoteSet::iterator i = m_pendingNoteOns.begin();
1304 i != m_pendingNoteOns.end(); ++i) { 1304 i != m_pendingNoteOns.end(); ++i) {
1305 if (lrintf((*i).value) == pitch) { 1305 if (lrintf((*i).value) == pitch) {
1306 Note note(*i); 1306 Note note(*i);