00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __TNote__
00026 #define __TNote__
00027
00028 #include "exports.h"
00029 #include "common.h"
00030 #include "TPitch.h"
00031 #include "TNotation.h"
00032 #include "TScoreInstrument.h"
00033 #include "TTimeModification.h"
00034 #include "smartpointer.h"
00035 #include "TScoreVisitor.h"
00036
00037 namespace MusicXML
00038 {
00039
00046 class EXP TExpression : public visitable, public smartable {
00047
00048 public:
00049 enum { undefined = -1 };
00050 EXP friend SMARTP<TExpression> newExpression();
00051
00052 virtual void accept(TScoreVisitor& visitor);
00053
00055 void setDynamic(long dyn);
00057 void setEndDynamic(long dyn);
00059 void setAttack(long attack);
00061 void setRelease(long rel);
00063 void setPizzicato(YesNo::type pizz);
00064
00065 long getDynamic() const { return fDynamic; }
00066 long getEndDynamic() const { return fEndDynamic; }
00067 long getAttack() const { return fAttack; }
00068 long getRelease() const { return fRelease; }
00069 YesNo::type getPizzicato() const { return fPizzicato; }
00070
00071 protected:
00072 TExpression()
00073 : fDynamic(undefined), fEndDynamic(undefined), fAttack(undefined),
00074 fRelease(undefined), fPizzicato(YesNo::undefined) {}
00075 virtual ~TExpression() {}
00076 private:
00077 long fDynamic;
00078 long fEndDynamic;
00079 long fAttack;
00080 long fRelease;
00081 YesNo::type fPizzicato;
00082 };
00083 typedef SMARTP<TExpression> SExpression;
00084
00097 class EXP TAccidental : public visitable, public smartable {
00098
00099 public:
00100 enum accident { undefined = -1,
00101 sharp=1, natural, flat, double_sharp, sharp_sharp, flat_flat,
00102 natural_sharp, natural_flat, quarter_flat, quarter_sharp,
00103 three_quarters_flat, three_quarters_sharp, last=three_quarters_sharp };
00104
00105 EXP friend SMARTP<TAccidental> newAccidental();
00106
00107 virtual void accept(TScoreVisitor& visitor);
00108
00109 accident getAccident() const { return fAccident; }
00110 YesNo::type getCautionary() const { return fCautionary; }
00111 YesNo::type getEditorial() const { return fEditorial; }
00112 FullCue::type getSize() const { return fSize; }
00113
00114 void setAccident(accident acc);
00115 void setCautionary(YesNo::type yn);
00116 void setEditorial(YesNo::type yn);
00117 void setSize(FullCue::type size);
00118
00120 static const string xmlaccidental (accident d);
00122 static accident xmlaccidental (const string str);
00123
00124 protected:
00125 TAccidental() :
00126 fAccident(undefined), fCautionary(YesNo::undefined),
00127 fEditorial(YesNo::undefined), fSize(FullCue::undefined) {}
00128 virtual ~TAccidental() {}
00129 private:
00130 accident fAccident;
00131 YesNo::type fCautionary;
00132 YesNo::type fEditorial;
00133 FullCue::type fSize;
00134
00135 static bimap<string, accident> fAccident2String;
00136 static accident fAccidentTbl[];
00137 static string fAccidentStrings[];
00138 };
00139 typedef SMARTP<TAccidental> SAccidental;
00140
00156 class EXP TNoteHead : public visitable, public smartable {
00157
00158 public:
00159 enum notehead { undefined = -1,
00160 slash=1, triangle, diamond, square, cross, x, circle_x, normal, none, last=none };
00161 EXP friend SMARTP<TNoteHead> newNoteHead();
00162
00163 virtual void accept(TScoreVisitor& visitor);
00164
00165 void setShape(notehead shape);
00166 void setFilled(YesNo::type filled);
00167 void setParentheses(YesNo::type par);
00168
00169 notehead getShape() const { return fShape; }
00170 YesNo::type getFilled() const { return fFilled; }
00171 YesNo::type getParentheses() const { return fParentheses; }
00172
00174 static const string xmlnotehead (notehead d);
00176 static notehead xmlnotehead (const string str);
00177
00178 protected:
00179 TNoteHead() : fShape(undefined), fFilled(YesNo::undefined), fParentheses(YesNo::undefined) {}
00180 virtual ~TNoteHead() {}
00181 private:
00182 notehead fShape;
00183 YesNo::type fFilled;
00184 YesNo::type fParentheses;
00185
00186 static bimap<string, notehead> fNoteHead2String;
00187 static notehead fNoteHeadTbl[];
00188 static string fNoteHeadStrings[];
00189 };
00190 typedef SMARTP<TNoteHead> SNoteHead;
00191
00204 class EXP TBeam : public visitable, public smartable {
00205
00206 public:
00207 enum beamtype { undefined = -1,
00208 beambegin=1, beamcontinue, beamend, beamforward, beambackward, last=beambackward };
00209
00210 EXP friend SMARTP<TBeam> newBeam();
00211
00212 beamtype getType() const { return fType; }
00213 int getNumber() const { return fNumber; }
00214 YesNo::type getRepeater() const { return fRepeater; }
00215
00216 void setType(beamtype type);
00217 void setNumber(int num);
00218 void setRepeater(YesNo::type r);
00219
00220 virtual void accept(TScoreVisitor& visitor);
00221
00223 static const string xmlbeamtype (beamtype d);
00225 static beamtype xmlbeamtype (const string str);
00226
00227 protected:
00228 TBeam() : fType(undefined), fNumber(undefined), fRepeater(YesNo::undefined) {}
00229 virtual ~TBeam() {}
00230 private:
00231 beamtype fType;
00232 int fNumber;
00233 YesNo::type fRepeater;
00234
00235 static bimap<string, beamtype> fBeam2String;
00236 static beamtype fBeamTbl[];
00237 static string fBeamStrings[];
00238 };
00239 typedef SMARTP<TBeam> SBeam;
00240
00252 class EXP TGraphNote : public visitable, public smartable {
00253
00254 public:
00255 enum { undefined = -1, stemdown=1, stemup, stemnone, stemdouble, last=stemdouble };
00256
00257 EXP friend SMARTP<TGraphNote> newGraphNote();
00258
00259 virtual void accept(TScoreVisitor& visitor);
00260
00262 void setVoice(long voice);
00264 void setType(NoteType::type type);
00266 void setSize(FullCue::type size);
00268 void setDots(unsigned long dots);
00270 void setStem(long stem);
00272 void setStaff(long staff);
00273
00274 long getVoice() const { return fVoice; }
00275 NoteType::type getType() const { return fType; }
00276 FullCue::type getSize() const { return fSize; }
00277 unsigned int getDots() const { return fDots; }
00278 int getStem() const { return fStem; }
00279 int getStaff() const { return fStaff; }
00280
00281 long add(const SBeam& beam);
00282 long add(const SNotation& notation);
00283
00285 SAccidental& accidental() { return fAccidental; }
00287 STimeModification& timemodification() { return fTimeMod; }
00289 SNoteHead& notehead() { return fNoteHead; }
00291 vvector<SBeam>& beamList() { return fBeamList; }
00293 vvector<SNotation>& notationList() { return fNotationList; }
00294
00296 static const string xmlstem (int d);
00298 static int xmlstem (const string str);
00299
00300 protected:
00301 TGraphNote()
00302 : fVoice(undefined), fType(NoteType::undefined), fSize(FullCue::undefined), fDots(0),
00303 fStem(undefined), fStaff(undefined) {}
00304 virtual ~TGraphNote() {}
00305 private:
00306 long fVoice;
00307 NoteType::type fType;
00308 FullCue::type fSize;
00309 unsigned long fDots;
00310 SAccidental fAccidental;
00311 STimeModification fTimeMod;
00312 long fStem;
00313 SNoteHead fNoteHead;
00314 long fStaff;
00315 vvector<SBeam> fBeamList;
00316 vvector<SNotation> fNotationList;
00317
00318 static bimap<string, int> fStem2String;
00319 static int fStemTbl[];
00320 static string fStemStrings[];
00321 };
00322 typedef SMARTP<TGraphNote> SGraphNote;
00323
00337 class EXP TGraceNote : public visitable, public smartable {
00338
00339 public:
00340 enum { undefined = -1 };
00341 EXP friend SMARTP<TGraceNote> newGraceNote();
00342
00343 virtual void accept(TScoreVisitor& visitor);
00344
00345 int getStealPrevious() const { return fStealPrevious; }
00346 int getStealFollowing() const { return fStealFollowing; }
00347 int getMakeTime() const { return fMakeTime; }
00348 YesNo::type getSlash() const { return fSlash; }
00349
00350 void setStealPrevious(int v);
00351 void setStealFollowing(int v);
00352 void setMakeTime(int v);
00353 void setSlash(YesNo::type v);
00354
00355 protected:
00356 TGraceNote() :
00357 fStealPrevious(undefined), fStealFollowing(undefined), fMakeTime(undefined),
00358 fSlash(YesNo::undefined) {}
00359 virtual ~TGraceNote() {}
00360 private:
00361 int fStealPrevious;
00362 int fStealFollowing;
00363 int fMakeTime;
00364 YesNo::type fSlash;
00365 };
00366 typedef SMARTP<TGraceNote> SGraceNote;
00367
00368 class TNote;
00369 typedef SMARTP<TNote> SNote;
00384 class EXP TNote : public TMusicData, public Positionable {
00385
00386 public:
00387 enum style { normal, cue, grace };
00388 enum type { pitched, rest, unpitched };
00389 EXP friend SMARTP<TNote> newNote();
00390
00391 virtual void accept(TScoreVisitor& visitor);
00392
00393 void setDuration (unsigned long dur);
00394 unsigned long getDuration () const { return fDuration; }
00395 unsigned long getFullDuration();
00397 void setInstrumentID(string id);
00398 const string getInstrumentID() const { return fInstrumentID; }
00399
00401 void setStyle(style t);
00402 style getStyle() const { return fStyle; }
00403
00405 void setType(type t);
00406 type getType() const { return fType; }
00407
00409 SPitch& pitch() { return fPitch; }
00411 SExpression& expression() { return fExpression; }
00413 SNote& tiePrevious() { return fTiePrev; }
00415 SNote& tieNext() { return fTieNext; }
00417 SGraphNote& graphics() { return fGraphNote; }
00419 SGraceNote& graceNote() { return fGraceNote; }
00420
00422 bool isTie() { return tieNext() && !tiePrevious();}
00423
00425 bool isSingle() { return !tieNext() && !tiePrevious();}
00426
00427 bool isNormal() { return fStyle == normal;}
00428 bool isGrace() { return fStyle == grace;}
00429 bool isCue() { return fStyle == cue;}
00430
00431 bool isPitched() { return fType == pitched;}
00432 bool isRest() { return fType == rest;}
00433 bool isUnpitched() { return fType == unpitched;}
00434
00435 long getVoice() const;
00436
00437 protected:
00438 TNote() : fStyle(normal), fType(pitched), fDuration(1), fTiePrev(NULL), fTieNext(NULL) {}
00439 virtual ~TNote() {}
00440
00441 private:
00442 style fStyle;
00443 type fType;
00444 SPitch fPitch;
00445 unsigned long fDuration;
00446 string fInstrumentID;
00447
00448 SExpression fExpression;
00449 SNote fTiePrev;
00450 SNote fTieNext;
00451 SGraphNote fGraphNote;
00452 SGraceNote fGraceNote;
00453 };
00454
00455 }
00456
00457
00458 #endif