Canorus  0.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
/home/iurt/rpm/BUILD/canorus-0.7.R1002/src/core/note.h
Go to the documentation of this file.
00001 
00008 #ifndef NOTE_H_
00009 #define NOTE_H_
00010 
00011 #include "core/muselement.h"
00012 #include "core/playable.h"
00013 #include "core/slur.h"
00014 #include "core/diatonicpitch.h"
00015 
00016 class CAVoice;
00017 
00018 class CANote : public CAPlayable {
00019 public:
00020         enum CAStemDirection {
00021                 StemNeutral,
00022                 StemUp,
00023                 StemDown,
00024                 StemPreferred // voice's direction
00025         };
00026 
00027         CANote( CADiatonicPitch pitch, CAPlayableLength length, CAVoice *voice, int timeStart, int timeLength=-1 );
00028         CANote *clone(CAVoice* voice=0);
00029 
00030         virtual ~CANote();
00031 
00032         CAPlayableLength noteLength() { return _playableLength; }
00033 
00034         inline CADiatonicPitch& diatonicPitch() { return _diatonicPitch; }
00035         inline void setDiatonicPitch( CADiatonicPitch& pitch ) {
00036                 _diatonicPitch = pitch;
00037                 updateTies();
00038         }
00039 
00040         CAStemDirection stemDirection() { return _stemDirection; }
00041         void setStemDirection(CAStemDirection direction);
00042 
00043         int notePosition();
00044 
00045         inline CASlur *tieStart() { return _tieStart; }
00046         inline CASlur *tieEnd() { return _tieEnd; }
00047         inline CASlur *slurStart() { return _slurStart; }
00048         inline CASlur *slurEnd() { return _slurEnd; }
00049         inline CASlur *phrasingSlurStart() { return _phrasingSlurStart; }
00050         inline CASlur *phrasingSlurEnd() { return _phrasingSlurEnd; }
00051 
00052         CAStemDirection         actualStemDirection();
00053         CASlur::CASlurDirection actualSlurDirection();
00054 
00055         inline void setTieStart( CASlur *tieStart ) { _tieStart = tieStart; }
00056         inline void setTieEnd( CASlur *tieEnd ) { _tieEnd = tieEnd; }
00057         inline void setSlurStart( CASlur *slurStart ) { _slurStart = slurStart; }
00058         inline void setSlurEnd( CASlur *slurEnd ) { _slurEnd = slurEnd; }
00059         inline void setPhrasingSlurStart( CASlur *pSlurStart ) { _phrasingSlurStart = pSlurStart; }
00060         inline void setPhrasingSlurEnd( CASlur *pSlurEnd ) { _phrasingSlurEnd = pSlurEnd; }
00061 
00062         void updateTies();
00063 
00064         bool isPartOfChord();
00065         bool isLastInChord();
00066         bool isFirstInChord();
00067         QList<CANote*> getChord();
00068 
00069         bool forceAccidentals() { return _forceAccidentals; }
00070         void setForceAccidentals(bool force) { _forceAccidentals = force; }
00071 
00072         static const QString generateNoteName(int pitch, int accs);
00073 
00074         static const QString stemDirectionToString(CAStemDirection);
00075         static CAStemDirection stemDirectionFromString(const QString);
00076 
00077         int compare(CAMusElement* elt);
00078 
00079 private:
00080         CADiatonicPitch _diatonicPitch;
00081         CAStemDirection _stemDirection;
00082         bool _forceAccidentals; // Always draw notes accidentals.
00083 
00085         // Slurs and ties //
00087         CASlur *_tieStart;
00088         CASlur *_tieEnd;
00089         CASlur *_slurStart;
00090         CASlur *_slurEnd;
00091         CASlur *_phrasingSlurStart;
00092         CASlur *_phrasingSlurEnd;
00093 };
00094 #endif /* NOTE_H_*/