comparison data/model/NoteModel.h @ 1038:cc27f35aa75c cxx11

Introducing the signed 64-bit frame index type, and fixing build failures from inclusion of -Wconversion with -Werror. Not finished yet.
author Chris Cannam
date Tue, 03 Mar 2015 15:18:24 +0000
parents 59e7fe1b1003
children a1cd5abcb38b
comparison
equal deleted inserted replaced
1037:bf0e5944289b 1038:cc27f35aa75c
36 */ 36 */
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(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { }
42 Note(long _frame, float _value, int _duration, float _level, QString _label) : 42 Note(sv_frame_t _frame, float _value, sv_frame_t _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 sv_frame_t frame;
48 float value; 48 float value;
49 int duration; 49 sv_frame_t 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
200 200
201 Point point(*i); 201 Point point(*i);
202 command->deletePoint(point); 202 command->deletePoint(point);
203 203
204 switch (column) { 204 switch (column) {
205 case 4: point.level = value.toDouble(); break; 205 case 4: point.level = float(value.toDouble()); break;
206 case 5: point.label = value.toString(); break; 206 case 5: point.label = value.toString(); break;
207 } 207 }
208 208
209 command->addPoint(point); 209 command->addPoint(point);
210 return command->finish(); 210 return command->finish();
222 222
223 NoteList getNotes() const { 223 NoteList getNotes() const {
224 return getNotesWithin(getStartFrame(), getEndFrame()); 224 return getNotesWithin(getStartFrame(), getEndFrame());
225 } 225 }
226 226
227 NoteList getNotesWithin(int startFrame, int endFrame) const { 227 NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t 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 int duration = pli->duration; 235 sv_frame_t 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 = int(lrintf(pli->value));
241 241
242 int velocity = 100; 242 int velocity = 100;
243 if (pli->level > 0.f && pli->level <= 1.f) { 243 if (pli->level > 0.f && pli->level <= 1.f) {
244 velocity = lrintf(pli->level * 127); 244 velocity = int(lrintf(pli->level * 127));
245 } 245 }
246 246
247 NoteData note(pli->frame, duration, pitch, velocity); 247 NoteData note(pli->frame, duration, pitch, velocity);
248 248
249 if (getScaleUnits() == "Hz") { 249 if (getScaleUnits() == "Hz") {