comparison data/model/NoteModel.h @ 929:59e7fe1b1003 warnfix_no_size_t

Unsigned removals and warning fixes in data/
author Chris Cannam
date Tue, 17 Jun 2014 14:33:42 +0100
parents c48b07b34cb3
children cc27f35aa75c
comparison
equal deleted inserted replaced
928:6a94bb528e9d 929:59e7fe1b1003
37 37
38 struct Note 38 struct Note
39 { 39 {
40 public: 40 public:
41 Note(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } 41 Note(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { }
42 Note(long _frame, float _value, size_t _duration, float _level, QString _label) : 42 Note(long _frame, float _value, int _duration, float _level, QString _label) :
43 frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } 43 frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { }
44 44
45 int getDimensions() const { return 3; } 45 int getDimensions() const { return 3; }
46 46
47 long frame; 47 long frame;
48 float value; 48 float value;
49 size_t duration; 49 int duration;
50 float level; 50 float level;
51 QString label; 51 QString label;
52 52
53 QString getLabel() const { return label; } 53 QString getLabel() const { return label; }
54 54
60 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n") 60 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n")
61 .arg(indent).arg(frame).arg(value).arg(duration).arg(level) 61 .arg(indent).arg(frame).arg(value).arg(duration).arg(level)
62 .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); 62 .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
63 } 63 }
64 64
65 QString toDelimitedDataString(QString delimiter, size_t sampleRate) const 65 QString toDelimitedDataString(QString delimiter, int sampleRate) const
66 { 66 {
67 QStringList list; 67 QStringList list;
68 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); 68 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
69 list << QString("%1").arg(value); 69 list << QString("%1").arg(value);
70 list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str(); 70 list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str();
96 class NoteModel : public IntervalModel<Note>, public NoteExportable 96 class NoteModel : public IntervalModel<Note>, public NoteExportable
97 { 97 {
98 Q_OBJECT 98 Q_OBJECT
99 99
100 public: 100 public:
101 NoteModel(size_t sampleRate, size_t resolution, 101 NoteModel(int sampleRate, int resolution,
102 bool notifyOnAdd = true) : 102 bool notifyOnAdd = true) :
103 IntervalModel<Note>(sampleRate, resolution, notifyOnAdd), 103 IntervalModel<Note>(sampleRate, resolution, notifyOnAdd),
104 m_valueQuantization(0) 104 m_valueQuantization(0)
105 { 105 {
106 PlayParameterRepository::getInstance()->addPlayable(this); 106 PlayParameterRepository::getInstance()->addPlayable(this);
107 } 107 }
108 108
109 NoteModel(size_t sampleRate, size_t resolution, 109 NoteModel(int sampleRate, int resolution,
110 float valueMinimum, float valueMaximum, 110 float valueMinimum, float valueMaximum,
111 bool notifyOnAdd = true) : 111 bool notifyOnAdd = true) :
112 IntervalModel<Note>(sampleRate, resolution, 112 IntervalModel<Note>(sampleRate, resolution,
113 valueMinimum, valueMaximum, 113 valueMinimum, valueMaximum,
114 notifyOnAdd), 114 notifyOnAdd),
219 /** 219 /**
220 * NoteExportable methods. 220 * NoteExportable methods.
221 */ 221 */
222 222
223 NoteList getNotes() const { 223 NoteList getNotes() const {
224 return getNotes(getStartFrame(), getEndFrame()); 224 return getNotesWithin(getStartFrame(), getEndFrame());
225 } 225 }
226 226
227 NoteList getNotes(size_t startFrame, size_t endFrame) const { 227 NoteList getNotesWithin(int startFrame, int endFrame) const {
228 228
229 PointList points = getPoints(startFrame, endFrame); 229 PointList points = getPoints(startFrame, endFrame);
230 NoteList notes; 230 NoteList notes;
231 231
232 for (PointList::iterator pli = 232 for (PointList::iterator pli =
233 points.begin(); pli != points.end(); ++pli) { 233 points.begin(); pli != points.end(); ++pli) {
234 234
235 size_t duration = pli->duration; 235 int duration = pli->duration;
236 if (duration == 0 || duration == 1) { 236 if (duration == 0 || duration == 1) {
237 duration = getSampleRate() / 20; 237 duration = getSampleRate() / 20;
238 } 238 }
239 239
240 int pitch = lrintf(pli->value); 240 int pitch = lrintf(pli->value);