00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef __TXML2GuidoVisitor__
00025 #define __TXML2GuidoVisitor__
00026 
00027 #include "exports.h"
00028 #include "TNotation.h"
00029 #include "TScorePartwise.h"
00030 #include "TScoreVisitor.h"
00031 #include "TScanVisitor.h"
00032 #include "TRational.h"
00033 #include "guido.h"
00034 
00035 #include <stack>
00036 
00037 using namespace std;
00038 using namespace MusicXML;
00039 
00049 class VEXP TXML2GuidoVisitor : public TScoreVisitor {
00050 
00051 
00052     public:
00053         TXML2GuidoVisitor(bool comments=true, bool checkStem=true, bool bar=false);
00054         virtual ~TXML2GuidoVisitor() {}
00055 
00056         VEXP friend SMARTP<TXML2GuidoVisitor> newXML2GuidoVisitor(bool comments=true, bool checkStem=true, bool bar=false);
00057 
00058         void visite ( SAccidental& elt );
00059         void visite ( SArticulationElement& elt );
00060         void visite ( SArticulations& elt );
00061         void visite ( SAttributes& elt );
00062         void visite ( SBackup& elt );
00063         void visite ( SBarline& elt );
00064         void visite ( SBeam& elt );
00065         void visite ( SBracket& elt );
00066         void visite ( SChord& elt );
00067         void visite ( SClef& elt );
00068         void visite ( SCoda& elt );
00069         void visite ( SCreator& elt );
00070         void visite ( SDirection& elt );
00071         void visite ( SDirectionType& elt );
00072         void visite ( SDirective& elt );
00073         void visite ( SDynamic& elt );
00074         void visite ( SEncoding& elt );
00075         void visite ( SEnding& elt );
00076         void visite ( SFermata& elt );
00077         void visite ( SForward& elt );
00078         void visite ( SGraceNote& elt );
00079         void visite ( SGraphNote& elt );
00080         void visite ( SIdentification& elt );
00081         void visite ( SKey& elt );
00082         void visite ( SMetronome& elt );
00083         void visite ( SMidiInstrument& elt );
00084         void visite ( SNotation& elt );
00085         void visite ( SNote& elt );
00086         void visite ( SNoteHead& elt );
00087         void visite ( SOctaveShift& elt );
00088         void visite ( SPWMeasure& elt );
00089         void visite ( SPWPart& elt );
00090         void visite ( SPartGroup& elt );
00091         void visite ( SPartList& elt );
00092         void visite ( SPitch& elt );
00093         void visite ( SRepeat& elt );
00094         void visite ( SRest& elt );
00095         void visite ( SScoreInstrument& elt );
00096         void visite ( SScorePart& elt );
00097         void visite ( SScorePartwise& elt );
00098         void visite ( SSegno& elt );
00099         void visite ( SSlur& elt );
00100         void visite ( SSound& elt );
00101         void visite ( SStrongAccent& elt );
00102         void visite ( STie& elt );
00103         void visite ( STimeModification& elt );
00104         void visite ( STimeSign& elt );
00105         void visite ( STranspose& elt );
00106         void visite ( STuplet& elt );
00107         void visite ( STupletDesc& elt );
00108         void visite ( SUnpitched& elt );
00109         void visite ( SWavyLine& elt );
00110         void visite ( SWedge& elt );
00111         void visite ( SWords& elt );
00112 
00113         Sguidoelement& current ()           { return fStack.top(); }
00114 
00115     protected:
00116         void add (Sguidoelement& elt)       { fStack.top()->add(elt); }
00117         void push (Sguidoelement& elt)      { add(elt); fStack.push(elt); }
00118         void pop ()                         { fStack.pop(); }
00119         long    fCurrentVoice;
00120         long    fCurrentDivision;
00121         bool    fMeasureEmpty;
00122 
00123     private:
00124         void startmeasure ();
00125         void measurend (SPWMeasure meas, bool first=false);
00126         bool checkgrace (const SNote& note);
00127         bool checkcue   (const SNote& note);
00128         void checkstem  (const SNote& note);
00129         void checkstaff (long staff);
00130         void guidonote (const SNote& note);
00131 
00132         void partheader ( SScoreHeader& elt );
00133         void guidoheader(SScoreHeader& elt);
00134         void guidotime(STimeSign& elt);
00135         const string guidobarstyle(int style) const;
00136 
00137         void addInstr (string instr);
00138 
00139         
00140         stack<Sguidoelement>    fStack;
00141         
00142         SScorePartwise      fScore;
00143         
00144         bool    fHeaderPending;
00145         
00146         bool    fCrescPending;
00147         
00148         TScanVisitor    fScan;
00149         
00150         class SlursVisitor: public TRoutedVisitor {
00151             public:             
00152                 int flag; int num;
00153                 void visite ( SSlur& elt )  { num++; flag |= elt->getType(); }
00154         } fSlurs;
00155 
00156         enum location { before, after };
00157         location fNotePass;
00158         long    fStaffPass;
00159         long    fStaffNum;
00160         long    fMeasNum;
00161         long    fCurrentStaff;
00162         int     fStemDirection; 
00163         
00164         long    fPendingPops;
00165         TRational fCurTimeSign;
00166         
00167         SPartSummary fCurrentPart;
00168 
00169         bool    fInGrace;
00170         bool    fInChord;
00171         bool    fInCue;
00172         bool    fInRepeat;
00173         bool    fInTieSlur;
00174         bool    fBeamOpened;
00175         
00176         bool    fComments;
00177         bool    fCheckStem;
00178         bool    fGenerateBars;
00179         bool    fInhibitNextBar;
00180 };
00181 typedef SMARTP<TXML2GuidoVisitor> SXML2GuidoVisitor;
00182 
00183 #endif