comparison data/model/FlexiNoteModel.h @ 1039:b14064bd1f97 cxx11

This code now compiles. Main problem: sample rate types
author Chris Cannam
date Tue, 03 Mar 2015 17:09:19 +0000
parents 06579b8ffb7b
children a1cd5abcb38b
comparison
equal deleted inserted replaced
1038:cc27f35aa75c 1039:b14064bd1f97
40 */ 40 */
41 41
42 struct FlexiNote 42 struct FlexiNote
43 { 43 {
44 public: 44 public:
45 FlexiNote(long _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { } 45 FlexiNote(sv_frame_t _frame) : frame(_frame), value(0.0f), duration(0), level(1.f) { }
46 FlexiNote(long _frame, float _value, int _duration, float _level, QString _label) : 46 FlexiNote(sv_frame_t _frame, float _value, sv_frame_t _duration, float _level, QString _label) :
47 frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { } 47 frame(_frame), value(_value), duration(_duration), level(_level), label(_label) { }
48 48
49 int getDimensions() const { return 3; } 49 int getDimensions() const { return 3; }
50 50
51 long frame; 51 sv_frame_t frame;
52 float value; 52 float value;
53 int duration; 53 sv_frame_t duration;
54 float level; 54 float level;
55 QString label; 55 QString label;
56 56
57 QString getLabel() const { return label; } 57 QString getLabel() const { return label; }
58 58
206 206
207 Point point(*i); 207 Point point(*i);
208 command->deletePoint(point); 208 command->deletePoint(point);
209 209
210 switch (column) { 210 switch (column) {
211 case 4: point.level = value.toDouble(); break; 211 case 4: point.level = float(value.toDouble()); break;
212 case 5: point.label = value.toString(); break; 212 case 5: point.label = value.toString(); break;
213 } 213 }
214 214
215 command->addPoint(point); 215 command->addPoint(point);
216 return command->finish(); 216 return command->finish();
229 NoteList getNotes() const 229 NoteList getNotes() const
230 { 230 {
231 return getNotesWithin(getStartFrame(), getEndFrame()); 231 return getNotesWithin(getStartFrame(), getEndFrame());
232 } 232 }
233 233
234 NoteList getNotesWithin(int startFrame, int endFrame) const 234 NoteList getNotesWithin(sv_frame_t startFrame, sv_frame_t endFrame) const
235 { 235 {
236 PointList points = getPoints(startFrame, endFrame); 236 PointList points = getPoints(startFrame, endFrame);
237 NoteList notes; 237 NoteList notes;
238 for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) { 238 for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) {
239 int duration = pli->duration; 239 sv_frame_t duration = pli->duration;
240 if (duration == 0 || duration == 1) { 240 if (duration == 0 || duration == 1) {
241 duration = getSampleRate() / 20; 241 duration = getSampleRate() / 20;
242 } 242 }
243 int pitch = lrintf(pli->value); 243 int pitch = int(lrintf(pli->value));
244 244
245 int velocity = 100; 245 int velocity = 100;
246 if (pli->level > 0.f && pli->level <= 1.f) { 246 if (pli->level > 0.f && pli->level <= 1.f) {
247 velocity = lrintf(pli->level * 127); 247 velocity = int(lrintf(pli->level * 127));
248 } 248 }
249 249
250 NoteData note(pli->frame, duration, pitch, velocity); 250 NoteData note(pli->frame, duration, pitch, velocity);
251 251
252 if (getScaleUnits() == "Hz") { 252 if (getScaleUnits() == "Hz") {