Main Page | Modules | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | Related Pages

TPitch.h

00001 /*
00002 
00003   MusicXML Library
00004   Copyright (C) 2003  Grame
00005 
00006   This library is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Lesser General Public
00008   License as published by the Free Software Foundation; either
00009   version 2.1 of the License, or (at your option) any later version.
00010 
00011   This library is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Lesser General Public License for more details.
00015 
00016   You should have received a copy of the GNU Lesser General Public
00017   License along with this library; if not, write to the Free Software
00018   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020   Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
00021   grame@grame.fr
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 } // namespace MusicXML
00154 
00155 
00156 #endif

Generated on Tue Mar 23 09:49:43 2004 for LibMusicXML by doxygen 1.3.3