23 #include "noteevent.h" 24 #include "pitchspelling.h" 39 class AccidentalState;
47 static const int MAX_DOTS = 4;
62 HEAD_PITCHNAME_GERMAN,
66 HEAD_SHAPE_NOTE_7_AIKIN,
67 HEAD_SHAPE_NOTE_7_FUNK,
68 HEAD_SHAPE_NOTE_7_WALKER,
73 enum class Group : signed char {
147 enum class Type : signed char {
162 NoteHead(Score* s = 0) : Symbol(s) {}
167 Group headGroup()
const;
169 static QString scheme2userName(
Scheme scheme);
170 static QString group2userName(
Group group);
171 static QString type2userName(
Type type);
172 static QString scheme2name(
Scheme scheme);
173 static QString group2name(
Group group);
174 static QString type2name(
Type type);
175 static Scheme name2scheme(
const QString& s);
176 static Group name2group(
const QString& s);
177 static Type name2type(
const QString& s);
188 int tpc1 { Tpc::TPC_INVALID };
189 int tpc2 { Tpc::TPC_INVALID };
190 int fret { FRET_NONE };
191 int string { STRING_NONE };
195 NoteVal(
int p) : pitch(p) {}
198 static const int INVALID_LINE = -10000;
235 class Note final :
public Element {
238 enum class ValueType : char { OFFSET_VAL, USER_VAL };
242 bool _ghost {
false };
243 bool _hidden {
false };
244 bool _dotsHidden {
false };
247 bool _fretConflict {
false };
249 bool dragMode {
false };
251 bool _mirror {
false };
252 bool _small {
false };
254 mutable bool _mark {
false };
255 bool _fixed {
false };
264 ValueType _veloType { ValueType::OFFSET_VAL };
266 char _offTimeType { 0 };
267 char _onTimeType { 0 };
269 int _subchannel { 0 };
270 int _line { INVALID_LINE };
273 mutable int _tpc[2] { Tpc::TPC_INVALID, Tpc::TPC_INVALID };
274 mutable int _pitch { 0 };
276 int _veloOffset { 0 };
277 int _fixedLine { 0 };
278 qreal _tuning { 0.0 };
280 Accidental* _accidental { 0 };
286 QVector<NoteDot*> _dots;
287 NoteEventList _playEvents;
288 QVector<Spanner*> _spannerFor;
289 QVector<Spanner*> _spannerBack;
291 SymId _cachedNoteheadSym;
292 SymId _cachedSymNull;
296 void startDrag(EditData&)
override;
297 QRectF drag(EditData&ed)
override;
298 void endDrag(EditData&)
override;
299 void editDrag(EditData &editData)
override;
301 void verticalDrag(EditData& ed);
302 void horizontalDrag(EditData& ed);
304 void addSpanner(Spanner*);
305 void removeSpanner(Spanner*);
306 int concertPitchIdx()
const;
307 void updateRelLine(
int relLine,
bool undoable);
308 bool isNoteName()
const;
309 SymId noteHead()
const;
311 void normalizeLeftDragDelta(Segment* seg, EditData &ed, NoteEditData* ned);
313 static QString tpcUserName(
int tpc,
int pitch,
bool explicitAccidental);
317 Note(
const Note&,
bool link =
false);
320 Note& operator=(
const Note&) =
delete;
321 virtual Note* clone()
const override {
return new Note(*
this,
false); }
324 void undoUnlink()
override;
326 qreal mag()
const override;
328 void layout()
override;
331 void setCachedNoteheadSym(
SymId i) { _cachedNoteheadSym = i; };
332 void scanElements(
void* data,
void (*func)(
void*, Element*),
bool all =
true)
override;
333 void setTrack(
int val)
override;
335 int playTicks()
const;
336 Fraction playTicksFraction()
const;
338 qreal headWidth()
const;
339 qreal headHeight()
const;
340 qreal tabHeadWidth(
const StaffType* tab = 0)
const;
341 qreal tabHeadHeight(
const StaffType* tab = 0)
const;
342 QPointF stemDownNW()
const;
343 QPointF stemUpSE()
const;
344 qreal bboxXShift()
const;
345 qreal noteheadCenterX()
const;
346 qreal bboxRightPos()
const;
347 qreal headBodyWidth()
const;
356 int subtype()
const override {
return int(_headGroup); }
357 QString subtypeName()
const override;
359 void setPitch(
int val);
360 void setPitch(
int pitch,
int tpc1,
int tpc2);
361 int pitch()
const {
return _pitch; }
362 int ottaveCapoFret()
const;
365 qreal tuning()
const {
return _tuning; }
366 void setTuning(qreal v) { _tuning = v; }
367 void undoSetTpc(
int v);
368 int transposition()
const;
369 bool fixed()
const {
return _fixed; }
370 void setFixed(
bool v) { _fixed = v; }
371 int fixedLine()
const {
return _fixedLine; }
372 void setFixedLine(
int v) { _fixedLine = v; }
375 int tpc1()
const {
return _tpc[0]; }
376 int tpc2()
const {
return _tpc[1]; }
377 QString tpcUserName(
bool explicitAccidental =
false)
const;
380 void setTpc1(
int v) { _tpc[0] = v; }
381 void setTpc2(
int v) { _tpc[1] = v; }
382 void setTpcFromPitch();
383 int tpc1default(
int pitch)
const;
384 int tpc2default(
int pitch)
const;
385 int transposeTpc(
int tpc);
387 Accidental* accidental()
const {
return _accidental; }
388 void setAccidental(Accidental* a) { _accidental = a; }
394 void setLine(
int n) { _line = n; }
395 int physicalLine()
const;
397 int fret()
const {
return _fret; }
398 void setFret(
int val) { _fret = val; }
399 int string()
const {
return _string; }
400 void setString(
int val);
401 bool ghost()
const {
return _ghost; }
402 void setGhost(
bool val) { _ghost = val; }
403 bool fretConflict()
const {
return _fretConflict; }
404 void setFretConflict(
bool val) { _fretConflict = val; }
406 void add(Element*)
override;
407 void remove(Element*)
override;
409 bool mirror()
const {
return _mirror; }
410 void setMirror(
bool val) { _mirror = val; }
412 bool small()
const {
return _small; }
413 void setSmall(
bool val);
415 bool play()
const {
return _play; }
416 void setPlay(
bool val) { _play = val; }
418 Ms::Tie* tieFor()
const {
return _tieFor; }
419 Ms::Tie* tieBack()
const {
return _tieBack; }
420 void setTieFor(Tie* t) { _tieFor = t; }
421 void setTieBack(Tie* t) { _tieBack = t; }
422 Note* firstTiedNote()
const;
423 const Note* lastTiedNote()
const;
424 Note* lastTiedNote() {
return const_cast<Note*
>(
static_cast<const Note*
>(
this)->lastTiedNote()); }
425 int unisonIndex()
const;
426 void disconnectTiedNotes();
427 void connectTiedNotes();
429 Chord* chord()
const {
return (Chord*)parent(); }
430 void setChord(Chord* a) { setParent((Element*)a); }
431 void draw(QPainter*)
const override;
433 void read(XmlReader&)
override;
434 bool readProperties(XmlReader&)
override;
435 void readAddConnector(ConnectorInfoReader* info,
bool pasteMode)
override;
436 void write(XmlWriter&)
const override;
438 bool acceptDrop(EditData&)
const override;
439 Element* drop(EditData&)
override;
441 bool hidden()
const {
return _hidden; }
442 void setHidden(
bool val) { _hidden = val; }
443 bool dotsHidden()
const {
return _dotsHidden; }
444 void setDotsHidden(
bool val) { _dotsHidden = val; }
447 QString noteTypeUserName()
const;
449 ElementList& el() {
return _el; }
450 const ElementList& el()
const {
return _el; }
452 int subchannel()
const {
return _subchannel; }
453 void setSubchannel(
int val) { _subchannel = val; }
458 Direction userDotPosition()
const {
return _userDotPosition; }
459 void setUserDotPosition(
Direction d) { _userDotPosition = d; }
460 bool dotIsUp()
const;
462 void reset()
override;
464 ValueType veloType()
const {
return _veloType; }
465 void setVeloType(ValueType v) { _veloType = v; }
466 int veloOffset()
const {
return _veloOffset; }
467 void setVeloOffset(
int v) { _veloOffset = v; }
469 void setOnTimeOffset(
int v);
470 void setOffTimeOffset(
int v);
472 int customizeVelocity(
int velo)
const;
473 NoteDot* dot(
int n) {
return _dots[n]; }
474 const QVector<NoteDot*>& dots()
const {
return _dots; }
475 QVector<NoteDot*>& dots() {
return _dots; }
478 void updateAccidental(AccidentalState*);
480 void setNval(
const NoteVal&, Fraction = { -1, 1} );
481 NoteEventList& playEvents() {
return _playEvents; }
482 const NoteEventList& playEvents()
const {
return _playEvents; }
483 NoteEvent* noteEvent(
int idx) {
return &_playEvents[idx]; }
484 void setPlayEvents(
const NoteEventList& l) { _playEvents = l; }
486 const QVector<Spanner*>& spannerFor()
const {
return _spannerFor; }
487 const QVector<Spanner*>& spannerBack()
const {
return _spannerBack; }
489 void addSpannerBack(Spanner* e) {
if (!_spannerBack.contains(e)) _spannerBack.push_back(e); }
490 bool removeSpannerBack(Spanner* e) {
return _spannerBack.removeOne(e); }
491 void addSpannerFor(Spanner* e) {
if (!_spannerFor.contains(e)) _spannerFor.push_back(e); }
492 bool removeSpannerFor(Spanner* e) {
return _spannerFor.removeOne(e); }
494 void transposeDiatonic(
int interval,
bool keepAlterations,
bool useDoubleAccidentals);
496 void localSpatiumChanged(qreal oldValue, qreal newValue)
override;
497 QVariant getProperty(Pid propertyId)
const override;
498 bool setProperty(Pid propertyId,
const QVariant&)
override;
499 void undoChangeDotsVisible(
bool v);
500 QVariant propertyDefault(Pid)
const override;
501 QString propertyUserValue(Pid)
const override;
503 bool mark()
const {
return _mark; }
504 void setMark(
bool v)
const { _mark = v; }
505 void setScore(Score* s)
override;
508 void addParentheses();
512 NoteVal noteVal()
const;
514 Element* nextInEl(Element* e);
515 Element* prevInEl(Element* e);
516 Element* nextElement()
override;
517 Element* prevElement()
override;
518 virtual Element* lastElementBeforeSegment();
519 Element* nextSegmentElement()
override;
520 Element* prevSegmentElement()
override;
522 QString accessibleInfo()
const override;
523 QString screenReaderInfo()
const override;
524 QString accessibleExtraInfo()
const override;
526 Shape shape()
const override;
527 std::vector<Note*> tiedNotes()
const;
529 void setOffTimeType(
int v) { _offTimeType = v; }
530 void setOnTimeType(
int v) { _onTimeType = v; }
531 int offTimeType()
const {
return _offTimeType; }
532 int onTimeType()
const {
return _onTimeType; }
SymId
Definition: sym.h:45
ElementType
Definition: types.h:34
Direction
Definition: types.h:351
NoteType
Definition: types.h:324
Scheme
Definition: note.h:57
AccidentalType
Definition: types.h:152
Definition: cursor.cpp:30
Group
Definition: note.h:73
Graphic representation of a note.
Definition: note.h:235
DirectionH
Definition: mscore.h:301
Type
Definition: note.h:147