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

TXML2GuidoVisitor.h

00001 /*
00002 
00003   Copyright (C) 2003  Grame
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU Lesser General Public
00016   License along with this library; if not, write to the Free Software
00017   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019   Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
00020   grame@grame.fr
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         // the guido elements stack
00140         stack<Sguidoelement>    fStack;
00141         // the root element: may be used to search for linked elements
00142         SScorePartwise      fScore;
00143         // header is inserted at the beginning of the first sequence and not at its regular place
00144         bool    fHeaderPending;
00145         // this is for wedge element with stop attribute handling
00146         bool    fCrescPending;
00147         // this is used to scan a part as it may contain several staves and / or voices
00148         TScanVisitor    fScan;
00149         // a visitor used to scan the slurs and rewrite guido nested slurs (unnested in MusicXML)
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

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