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 __TPitch__
00026 #define __TPitch__
00027
00028 #include "exports.h"
00029 #include "bimap.h"
00030 #include "smartpointer.h"
00031 #include "TScoreVisitor.h"
00032 #include <string>
00033
00034 namespace MusicXML
00035 {
00036
00053 class EXP TPitch : public visitable, public smartable {
00054
00055 public:
00056 enum { undefined=0, C=1, D, E, F, G, A, B, last=B, diatonicSteps=last };
00057 EXP friend SMARTP<TPitch> newPitch();
00058
00059 virtual void accept(TScoreVisitor& visitor);
00060
00061 int getStep() const { return fStep; }
00062 float getAlter() const { return fAlter; }
00063 int getOctave() const { return fOctave; }
00064
00065 void setStep(int step);
00066 void setAlter(float alter);
00067 void setOctave(int oct);
00068
00070 static const string xmlpitch (int d);
00072 static int xmlpitch (const string str);
00073
00075 TPitch& operator++ (int) { fAlter+=1; return *this; }
00077 TPitch& operator-- (int) { fAlter-=1; return *this; }
00078
00079 TPitch& operator+= (int n);
00081 TPitch& operator+= (unsigned int n);
00082
00083 TPitch& operator-= (int n);
00085 TPitch& operator-= (unsigned int n);
00086
00088 unsigned short MIDIPitch () const;
00089
00090 protected:
00091 TPitch() : fStep(undefined), fAlter(0), fOctave(0) {}
00092 virtual ~TPitch() {}
00093
00094 int fStep;
00095 float fAlter;
00096 int fOctave;
00097
00098 private:
00099 static bimap<string, int> fPitch2String;
00100 static int fPitchTbl[];
00101 static string fPitchStrings[];
00102 };
00103 typedef SMARTP<TPitch> SPitch;
00104
00121 class EXP TUnpitched : public TPitch {
00122 public:
00123 EXP friend SMARTP<TUnpitched> newUnpitched();
00124 virtual void accept(TScoreVisitor& visitor);
00125
00126 protected:
00127 TUnpitched() {}
00128 virtual ~TUnpitched() {}
00129 };
00130 typedef SMARTP<TUnpitched> SUnpitched;
00131
00142 class EXP TRest : public TPitch {
00143 public:
00144 EXP friend SMARTP<TRest> newRest();
00145 virtual void accept(TScoreVisitor& visitor);
00146
00147 protected:
00148 TRest() {}
00149 virtual ~TRest() {}
00150 };
00151 typedef SMARTP<TRest> SRest;
00152
00153 }
00154
00155
00156 #endif