16 #ifndef _NOTE_MODEL_H_ 17 #define _NOTE_MODEL_H_ 42 Note(
long _frame,
float _value,
int _duration,
float _level, QString _label) :
57 QString extraAttributes =
"")
const 60 QString(
"%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n")
69 list << QString(
"%1").arg(
value);
71 list << QString(
"%1").arg(
level);
73 return list.join(delimiter);
78 const Note &p2)
const {
89 const Note &p2)
const {
102 bool notifyOnAdd =
true) :
110 float valueMinimum,
float valueMaximum,
111 bool notifyOnAdd =
true) :
113 valueMinimum, valueMaximum,
137 virtual void toXml(QTextStream &out,
139 QString extraAttributes =
"")
const 141 std::cerr <<
"NoteModel::toXml: extraAttributes = \"" 142 << extraAttributes.toStdString() << std::endl;
147 QString(
"%1 subtype=\"note\" valueQuantization=\"%2\"")
163 case 0:
return tr(
"Time");
164 case 1:
return tr(
"Frame");
165 case 2:
return tr(
"Pitch");
166 case 3:
return tr(
"Duration");
167 case 4:
return tr(
"Level");
168 case 5:
return tr(
"Label");
169 default:
return tr(
"Unknown");
173 virtual QVariant
getData(
int row,
int column,
int role)
const 180 if (i ==
m_points.end())
return QVariant();
183 case 4:
return i->level;
184 case 5:
return i->label;
185 default:
return QVariant();
193 (row, column, value, role);
196 if (role != Qt::EditRole)
return 0;
199 EditCommand *command =
new EditCommand(
this, tr(
"Edit Data"));
202 command->deletePoint(point);
205 case 4: point.
level = value.toDouble();
break;
206 case 5: point.
label = value.toString();
break;
209 command->addPoint(point);
210 return command->finish();
232 for (PointList::iterator pli =
233 points.begin(); pli != points.end(); ++pli) {
235 int duration = pli->duration;
236 if (duration == 0 || duration == 1) {
240 int pitch = lrintf(pli->value);
243 if (pli->level > 0.f && pli->level <= 1.f) {
244 velocity = lrintf(pli->level * 127);
247 NoteData note(pli->frame, duration, pitch, velocity);
255 notes.push_back(note);
std::multiset< Note, typename Note ::OrderComparator > PointList
static PlayParameterRepository * getInstance()
NoteModel(int sampleRate, int resolution, bool notifyOnAdd=true)
static RealTime frame2RealTime(long frame, unsigned int sampleRate)
Convert a sample frame at the given sample rate into a RealTime.
PointList::const_iterator PointListConstIterator
bool isMidiPitchQuantized
virtual bool canPlay() const
virtual int getSampleRate() const
float getValueQuantization() const
NoteModel – a concrete IntervalModel for notes.
void removePlayable(const Playable *playable)
bool operator()(const Note &p1, const Note &p2) const
virtual QVariant getData(int row, int column, int role) const
TabularModel methods.
bool operator()(const Note &p1, const Note &p2) const
virtual int getColumnCount() const
TabularModel methods.
virtual QVariant getData(int row, int column, int role) const
TabularModel methods.
int getDimensions() const
static int getPitchForFrequency(float frequency, float *centsOffsetReturn=0, float concertA=0.0)
Return the nearest MIDI pitch to the given frequency.
virtual QString getHeading(int column) const
static QString encodeEntities(QString)
virtual QString getScaleUnits() const
virtual int getStartFrame() const
void setValueQuantization(float q)
NoteList getNotes() const
NoteExportable methods.
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
virtual const SparseModel< Note >::PointList & getPoints() const
Model containing sparse data (points with some properties) of which the properties include a duration...
NoteList getNotesWithin(int startFrame, int endFrame) const
Note(long _frame, float _value, int _duration, float _level, QString _label)
QString toDelimitedDataString(QString delimiter, int sampleRate) const
virtual int getEndFrame() const
std::vector< NoteData > NoteList
NoteModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd=true)
QString getTypeName() const
Return the type of the model.
float m_valueQuantization
virtual Command * getSetDataCommand(int row, int column, const QVariant &value, int role)
virtual Command * getSetDataCommand(int row, int column, const QVariant &value, int role)
virtual QString getDefaultPlayClipId() const
virtual void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
virtual SortType getSortType(int column) const
std::string toString(bool align=false) const
Return a human-readable debug-type string to full precision (probably not a format to show to a user ...
void addPlayable(const Playable *playable)
PointListIterator getPointListIteratorForRow(int row)