16 #ifndef _FLEXINOTE_MODEL_H_ 17 #define _FLEXINOTE_MODEL_H_ 46 FlexiNote(
long _frame,
float _value,
int _duration,
float _level, QString _label) :
61 QString extraAttributes =
"")
const 64 QString(
"%1<point frame=\"%2\" value=\"%3\" duration=\"%4\" level=\"%5\" label=\"%6\" %7/>\n")
73 list << QString(
"%1").arg(
value);
75 list << QString(
"%1").arg(
level);
77 return list.join(delimiter);
106 bool notifyOnAdd =
true) :
114 float valueMinimum,
float valueMaximum,
115 bool notifyOnAdd =
true) :
117 valueMinimum, valueMaximum,
143 virtual void toXml(QTextStream &out,
145 QString extraAttributes =
"")
const 147 std::cerr <<
"FlexiNoteModel::toXml: extraAttributes = \"" 148 << extraAttributes.toStdString() << std::endl;
153 QString(
"%1 subtype=\"flexinote\" valueQuantization=\"%2\"")
169 case 0:
return tr(
"Time");
170 case 1:
return tr(
"Frame");
171 case 2:
return tr(
"Pitch");
172 case 3:
return tr(
"Duration");
173 case 4:
return tr(
"Level");
174 case 5:
return tr(
"Label");
175 default:
return tr(
"Unknown");
179 virtual QVariant
getData(
int row,
int column,
int role)
const 186 if (i ==
m_points.end())
return QVariant();
189 case 4:
return i->level;
190 case 5:
return i->label;
191 default:
return QVariant();
199 (row, column, value, role);
202 if (role != Qt::EditRole)
return 0;
205 EditCommand *command =
new EditCommand(
this, tr(
"Edit Data"));
208 command->deletePoint(point);
211 case 4: point.
level = value.toDouble();
break;
212 case 5: point.
label = value.toString();
break;
215 command->addPoint(point);
216 return command->finish();
238 for (PointList::iterator pli = points.begin(); pli != points.end(); ++pli) {
239 int duration = pli->duration;
240 if (duration == 0 || duration == 1) {
243 int pitch = lrintf(pli->value);
246 if (pli->level > 0.f && pli->level <= 1.f) {
247 velocity = lrintf(pli->level * 127);
250 NoteData note(pli->frame, duration, pitch, velocity);
257 notes.push_back(note);
FlexiNoteModel(int sampleRate, int resolution, bool notifyOnAdd=true)
std::multiset< FlexiNote, typename FlexiNote ::OrderComparator > PointList
static PlayParameterRepository * getInstance()
virtual Command * getSetDataCommand(int row, int column, const QVariant &value, int role)
FlexiNoteModel(int sampleRate, int resolution, float valueMinimum, float valueMaximum, bool notifyOnAdd=true)
virtual QVariant getData(int row, int column, int role) const
TabularModel methods.
static RealTime frame2RealTime(long frame, unsigned int sampleRate)
Convert a sample frame at the given sample rate into a RealTime.
bool operator()(const FlexiNote &p1, const FlexiNote &p2) const
virtual void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
virtual int getColumnCount() const
TabularModel methods.
FlexiNote(long _frame, float _value, int _duration, float _level, QString _label)
PointList::const_iterator PointListConstIterator
bool isMidiPitchQuantized
virtual int getSampleRate() const
QString getTypeName() const
Return the type of the model.
void removePlayable(const Playable *playable)
FlexiNoteModel – a concrete IntervalModel for notes.
float getValueMinimum() const
NoteList getNotes() const
NoteExportable methods.
virtual ~FlexiNoteModel()
virtual QVariant getData(int row, int column, int role) const
TabularModel methods.
virtual bool canPlay() const
virtual QString getHeading(int column) const
static int getPitchForFrequency(float frequency, float *centsOffsetReturn=0, float concertA=0.0)
Return the nearest MIDI pitch to the given frequency.
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
static QString encodeEntities(QString)
virtual QString getScaleUnits() const
virtual int getStartFrame() const
void setValueQuantization(float q)
virtual const SparseModel< FlexiNote >::PointList & getPoints() const
QString toDelimitedDataString(QString delimiter, int sampleRate) const
Model containing sparse data (points with some properties) of which the properties include a duration...
float m_valueQuantization
virtual int getEndFrame() const
float getValueMaximum() const
std::vector< NoteData > NoteList
virtual Command * getSetDataCommand(int row, int column, const QVariant &value, int role)
virtual QString getDefaultPlayClipId() const
virtual SortType getSortType(int column) const
bool operator()(const FlexiNote &p1, const FlexiNote &p2) const
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
int getDimensions() const
float getValueQuantization() 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)
NoteList getNotesWithin(int startFrame, int endFrame) const