|
|
#ifndef _NOTE_H_ #define _NOTE_H_ #include "event.h" #include "table.h" #include "expression.h" #include "bow.h" class Ornament; class Vector; class Lyrics; class Tuplet; enum { NS_STACCATO, NS_LEGATO, NS_ACCDOWN, NS_ACCUP, NS_ACCENT1, NS_ACCENT2, NS_ACCENT3, NS_ACCENT4, NS_ACCENT5, NS_ACCENT6, NS_ACCENT7, NS_ACCENT8, NS_ACCENT9, NS_ACCENT10, NS_ACCENT11, NS_TRILLER, NS_TRILL1, NS_TRILL2, NS_INF, NS_BOWUP, NS_BOWDOWN }; enum { AS_LABEL1, AS_LABEL2, AS_LABEL3, AS_CASE1, AS_CASE2, AS_PEDAL1, AS_PEDAL2, AS_NOTEDOT, AS_NOTE3, AS_NOTE6, AS_NOTEXX, AS_8VA, AS_15VA, AS_TRILLX, AS_TRILLX2, AS_DECRESCENDO, AS_CRESCENDO, AS_BRACKETUP, AS_BRACKETDOWN, AS_ARPEGGIO, AS_TEXT, DYN_PPP, DYN_PP, DYN_P, DYN_MP, DYN_MF, DYN_F, DYN_FF, DYN_FFF, DYN_SFZ, DYN_SF, DYN_SFF, DYN_FP }; /** The note event contains a pitch, velocity, enharmonic shift, channel and a vector of ornaments. */ class Note : public Event { private: short int _pitch; short int _vel; short int _prop; short int _chan; Tuplet * _tuplet; Vector * _ornament; char * _cPitch; public: /** Default constructor */ Note(); /** Constructor used by copy() */ Note(const Note&); /** Use this constructor to build a new note */ Note(int pitch, int vel, long len, Position pos, int enh, int tup=0, int c=-1); /** Use this constructor to build a new note */ Note(char* pitch, int vel, long len, Position pos, int enh, int tup=0, int c=-1); /** This destructor gets rid of the ornament vector */ ~Note(); // virtual bool operator==(Element*); /** returns the pitch */ int pitch() const { return _pitch; } /** returns the velocity */ int vel() const { return _vel; } /** returns the enharmonic shift */ int enh() const { return (_prop & MASK_ENH)-2; } /** returns the channel. -1 invokes the default (part defined) channel */ int chan() const { return _chan; } /** returns the ornament-vector */ Vector * ornament() const { return _ornament; } /** stem can be STEM_UP, STEM_DOWN or STEM_AUTO */ int stem() const { return (_prop & MASK_STEM) >> SHIFT_STEM; } /** returns true if this is not to be displayed as part of a group of notes */ bool nogroup() const { return ((_prop & MASK_NOGROUP) >> SHIFT_NOGROUP == 1); } /** the display is the value (in ticks) to displayed in the score presentation. In most cases * this equals the the duration. Only in case of tuplets, the width has to be shortened * (the total width of three eighths triplets is the same as the duration of a regular quarter) */ long display(int res = 1) const; /** returns the tuplet of this note (may be 0 !) */ Tuplet * tuplet() const; /** the base of a tuplet (3 for triplets, 7 for septlets, etc) */ int tupletBase() const; /** the total tuplet duration */ int tupletDuration() const; /** tuplet with base and duration */ void tuplet(int base, int duration); /** sets the pitch */ void setPitch(int f); /** sets the velocity */ void setVel(int v); /** sets the enharmonic shift */ void setEnh(int e); /** sets the MIDI channel */ void setChan(int c); /** sets the stem (STEM_UP, STEM_DOWN or STEM_AUTO) */ void setStem(int); /** lets this note not to be displayed as a part of a group of notes */ void setNogroup(bool); /** lets this note be displayed as a tuplet (base 3 = triplet) */ void setTuplet(Tuplet * tp); /** adds an ornament to the ornament vector */ void add(Ornament*); /** removes an ornament from the ornament vector. The ornament is not deleted here, deletion is done in AddOrnament's destructor */ void remove(Ornament*); /** returns an ornament of the ornament vector, and creates it, if necessary */ Expression * setExpression(int); /** returns an ornament of the ornament vector, and creates it, if necessary */ Bow * setBow(int,int,int); /** returns the note's lyrics. No new lyrics are created if they don't exist yet. */ Lyrics * lyrics(); /* extracts the expresseions from the note into a vector and returns this vector */ Vector * removeExp(); /* extracts the bow(s) from the note into a vector and returns this vector */ Vector * removeBow(); /** returns the pitch in a nice character presentation */ char * cPitch(); /** implementation of the print method */ virtual ostream & print(int,ostream&) const; /** implementation of the flush method */ virtual void flush(const char*) const; /** implementation of the copy method */ virtual Element * copy() const; /** implementation of the load method */ static Element * load(char*,ifstream*&,Element*); private: static const int MASK_ENH = 7; static const int MASK_STEM = 24; static const int MASK_NOGROUP = 32; static const int SHIFT_STEM = 3; static const int SHIFT_NOGROUP = 5; }; #endif
Generated by: wuerthne on clouseau on Fri Sep 21 19:20:46 2001, using kdoc 2.0a53. |