Mercurial > hg > svcore
comparison data/model/NoteModel.h @ 340:516819f2b97b
* Add Erase tool and mode
* Add icons for Normalize buttons in property boxes, and for Show Peaks
* Add support for velocity in notes -- not yet reflected in display or
editable in the note edit dialog, but they are imported from MIDI,
played, and exported
* Begin work on making pastes align pasted times (subtler than I thought)
author | Chris Cannam |
---|---|
date | Fri, 23 Nov 2007 16:48:23 +0000 |
parents | f14e2f7b24f7 |
children | 700cd3350391 |
comparison
equal
deleted
inserted
replaced
339:ba30f4a3e3be | 340:516819f2b97b |
---|---|
30 */ | 30 */ |
31 | 31 |
32 struct Note | 32 struct Note |
33 { | 33 { |
34 public: | 34 public: |
35 Note(long _frame) : frame(_frame), value(0.0f), duration(0) { } | 35 Note(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } |
36 Note(long _frame, float _value, size_t _duration, QString _label) : | 36 Note(long _frame, float _value, size_t _duration, float _level, QString _label) : |
37 frame(_frame), value(_value), duration(_duration), label(_label) { } | 37 frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } |
38 | 38 |
39 int getDimensions() const { return 3; } | 39 int getDimensions() const { return 3; } |
40 | 40 |
41 long frame; | 41 long frame; |
42 float value; | 42 float value; |
43 size_t duration; | 43 size_t duration; |
44 float level; | |
44 QString label; | 45 QString label; |
45 | 46 |
46 QString getLabel() const { return label; } | 47 QString getLabel() const { return label; } |
47 | 48 |
48 void toXml(QTextStream &stream, | 49 void toXml(QTextStream &stream, |
49 QString indent = "", | 50 QString indent = "", |
50 QString extraAttributes = "") const | 51 QString extraAttributes = "") const |
51 { | 52 { |
52 stream << | 53 stream << |
53 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" label=\"%5\" %6/>\n") | 54 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n") |
54 .arg(indent).arg(frame).arg(value).arg(duration).arg(label).arg(extraAttributes); | 55 .arg(indent).arg(frame).arg(value).arg(duration).arg(level).arg(label).arg(extraAttributes); |
55 } | 56 } |
56 | 57 |
57 QString toDelimitedDataString(QString delimiter, size_t sampleRate) const | 58 QString toDelimitedDataString(QString delimiter, size_t sampleRate) const |
58 { | 59 { |
59 QStringList list; | 60 QStringList list; |
60 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); | 61 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); |
61 list << QString("%1").arg(value); | 62 list << QString("%1").arg(value); |
62 list << QString("%1").arg(duration); | 63 list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str(); |
64 list << QString("%1").arg(level); | |
63 if (label != "") list << label; | 65 if (label != "") list << label; |
64 return list.join(delimiter); | 66 return list.join(delimiter); |
65 } | 67 } |
66 | 68 |
67 struct Comparator { | 69 struct Comparator { |
68 bool operator()(const Note &p1, | 70 bool operator()(const Note &p1, |
69 const Note &p2) const { | 71 const Note &p2) const { |
70 if (p1.frame != p2.frame) return p1.frame < p2.frame; | 72 if (p1.frame != p2.frame) return p1.frame < p2.frame; |
71 if (p1.value != p2.value) return p1.value < p2.value; | 73 if (p1.value != p2.value) return p1.value < p2.value; |
72 if (p1.duration != p2.duration) return p1.duration < p2.duration; | 74 if (p1.duration != p2.duration) return p1.duration < p2.duration; |
75 if (p1.level != p2.level) return p1.level < p2.level; | |
73 return p1.label < p2.label; | 76 return p1.label < p2.label; |
74 } | 77 } |
75 }; | 78 }; |
76 | 79 |
77 struct OrderComparator { | 80 struct OrderComparator { |