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

Introduce and use a samplerate type
author Chris Cannam
date Wed, 04 Mar 2015 12:01:04 +0000
parents cc27f35aa75c
children 57633d605547
comparison
equal deleted inserted replaced
1039:b14064bd1f97 1040:a1cd5abcb38b
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, int sampleRate) const 65 QString toDelimitedDataString(QString delimiter, sv_samplerate_t 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(int sampleRate, int resolution, 101 NoteModel(sv_samplerate_t 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(int sampleRate, int resolution, 109 NoteModel(sv_samplerate_t 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),
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 sv_frame_t 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 = sv_frame_t(getSampleRate() / 20);
238 } 238 }
239 239
240 int pitch = int(lrintf(pli->value)); 240 int pitch = int(lrintf(pli->value));
241 241
242 int velocity = 100; 242 int velocity = 100;