comparison data/model/FlexiNoteModel.h @ 1040:a1cd5abcb38b cxx11

Introduce and use a samplerate type
author Chris Cannam
date Wed, 04 Mar 2015 12:01:04 +0000
parents b14064bd1f97
children 57633d605547
comparison
equal deleted inserted replaced
1039:b14064bd1f97 1040:a1cd5abcb38b
64 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n") 64 QString("%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n")
65 .arg(indent).arg(frame).arg(value).arg(duration).arg(level) 65 .arg(indent).arg(frame).arg(value).arg(duration).arg(level)
66 .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes); 66 .arg(XmlExportable::encodeEntities(label)).arg(extraAttributes);
67 } 67 }
68 68
69 QString toDelimitedDataString(QString delimiter, int sampleRate) const 69 QString toDelimitedDataString(QString delimiter, sv_samplerate_t sampleRate) const
70 { 70 {
71 QStringList list; 71 QStringList list;
72 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str(); 72 list << RealTime::frame2RealTime(frame, sampleRate).toString().c_str();
73 list << QString("%1").arg(value); 73 list << QString("%1").arg(value);
74 list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str(); 74 list << RealTime::frame2RealTime(duration, sampleRate).toString().c_str();
100 class FlexiNoteModel : public IntervalModel<FlexiNote>, public NoteExportable 100 class FlexiNoteModel : public IntervalModel<FlexiNote>, public NoteExportable
101 { 101 {
102 Q_OBJECT 102 Q_OBJECT
103 103
104 public: 104 public:
105 FlexiNoteModel(int sampleRate, int resolution, 105 FlexiNoteModel(sv_samplerate_t sampleRate, int resolution,
106 bool notifyOnAdd = true) : 106 bool notifyOnAdd = true) :
107 IntervalModel<FlexiNote>(sampleRate, resolution, notifyOnAdd), 107 IntervalModel<FlexiNote>(sampleRate, resolution, notifyOnAdd),
108 m_valueQuantization(0) 108 m_valueQuantization(0)
109 { 109 {
110 PlayParameterRepository::getInstance()->addPlayable(this); 110 PlayParameterRepository::getInstance()->addPlayable(this);
111 } 111 }
112 112
113 FlexiNoteModel(int sampleRate, int resolution, 113 FlexiNoteModel(sv_samplerate_t sampleRate, int resolution,
114 float valueMinimum, float valueMaximum, 114 float valueMinimum, float valueMaximum,
115 bool notifyOnAdd = true) : 115 bool notifyOnAdd = true) :
116 IntervalModel<FlexiNote>(sampleRate, resolution, 116 IntervalModel<FlexiNote>(sampleRate, resolution,
117 valueMinimum, valueMaximum, 117 valueMinimum, valueMaximum,
118 notifyOnAdd), 118 notifyOnAdd),
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 sv_frame_t 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 = sv_frame_t(getSampleRate() / 20);
242 } 242 }
243 int pitch = int(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) {