1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
|
//=============================================================================
// MuseScore
// Linux Music Score Editor
//
// Copyright (C) 2015 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef __IMPORTMXMLPASS2_H__
#define __IMPORTMXMLPASS2_H__
#include <array>
#include "libmscore/score.h"
#include "libmscore/tuplet.h"
#include "importxmlfirstpass.h"
#include "importmxmlpass1.h"
#include "musicxml.h" // a.o. for Slur
#include "musicxmlsupport.h"
namespace Ms {
//---------------------------------------------------------
// support enums / structs / classes
//---------------------------------------------------------
typedef QList<Chord*> GraceChordList;
typedef QVector<FiguredBass*> FiguredBassList;
//---------------------------------------------------------
// MxmlStartStop
//---------------------------------------------------------
enum class MxmlStartStop : char {
START, STOP, NONE
};
//---------------------------------------------------------
// MusicXmlTupletDesc
//---------------------------------------------------------
/**
Describe the information extracted from
a single note/notations/tuplet element.
*/
struct MusicXmlTupletDesc {
MusicXmlTupletDesc();
MxmlStartStop type;
Element::Placement placement;
Tuplet::BracketType bracket;
Tuplet::NumberType shownumber;
};
//---------------------------------------------------------
// MusicXmlSpannerDesc
//---------------------------------------------------------
struct MusicXmlSpannerDesc {
SLine* sp;
Element::Type tp;
int nr;
MusicXmlSpannerDesc(SLine* _sp, Element::Type _tp, int _nr) : sp(_sp), tp(_tp), nr(_nr) {}
MusicXmlSpannerDesc(Element::Type _tp, int _nr) : sp(0), tp(_tp), nr(_nr) {}
};
//---------------------------------------------------------
// MusicXmlLyricsExtend
//---------------------------------------------------------
class MusicXmlLyricsExtend {
public:
MusicXmlLyricsExtend() {}
void init();
void addLyric(Lyrics* const lyric);
void setExtend(const int no, const int track, const int tick);
private:
QSet<Lyrics*> _lyrics;
};
//---------------------------------------------------------
// MusicXMLParserPass2
//---------------------------------------------------------
class FretDiagram;
class FiguredBassItem;
class Glissando;
class Pedal;
class Trill;
class MxmlLogger;
using SlurStack = std::array<SlurDesc, MAX_NUMBER_LEVEL>;
using TrillStack = std::array<Trill*, MAX_NUMBER_LEVEL>;
using BracketsStack = std::array<SLine*, MAX_BRACKETS>;
using DashesStack = std::array<SLine*, MAX_DASHES>;
using OttavasStack = std::array<SLine*, MAX_NUMBER_LEVEL>;
using HairpinsStack = std::array<SLine*, MAX_NUMBER_LEVEL>;
class MusicXMLParserPass2 {
public:
MusicXMLParserPass2(Score* score, MusicXMLParserPass1& pass1, MxmlLogger* logger);
void initPartState(const QString& partId);
Score::FileError parse(QIODevice* device);
Score::FileError parse();
void scorePartwise();
void partList();
void scorePart();
void part();
void measChordNote( /*, const MxmlPhase2Note note, ChordRest& currChord */);
void measChordFlush( /*, ChordRest& currChord */);
void measure(const QString& partId, const Fraction time);
void attributes(const QString& partId, Measure* measure, const int tick);
void measureStyle(Measure* measure);
void print(Measure* measure);
void barline(const QString& partId, Measure* measure);
void key(const QString& partId, Measure* measure, const int tick);
void clef(const QString& partId, Measure* measure, const int tick);
void time(const QString& partId, Measure* measure, const int tick);
void divisions();
void transpose(const QString& partId);
Note* note(const QString& partId, Measure* measure, const Fraction sTime, const Fraction prevTime,
Fraction& dura, QString& currentVoice, GraceChordList& gcl, int& gac,
Beam*& beam, FiguredBassList& fbl, int& alt);
void notePrintSpacingNo(Fraction& dura);
FiguredBassItem* figure(const int idx, const bool paren);
FiguredBass* figuredBass();
FretDiagram* frame();
void harmony(const QString& partId, Measure* measure, const Fraction sTime);
Accidental* accidental();
void beam(Beam::Mode& beamMode);
void duration(Fraction& dura);
void forward(Fraction& dura);
void backup(Fraction& dura);
void timeModification(Fraction& timeMod, TDuration& normalType);
//void pitch(int& step, int& alter, int& oct, AccidentalType& accid);
void lyric(const QString& partId, QMap<int, Lyrics*>& numbrdLyrics, QSet<Lyrics*>& extLyrics);
void slur(ChordRest* cr, const int tick, const int track, bool& lastGraceAFter);
void tied(Note* note, const int track);
void articulations(ChordRest* cr, int& breath, QString& chordLineType);
void dynamics(QString& placement, QStringList& dynamics);
void ornaments(ChordRest* cr, QString& wavyLineType, int& wavyLineNo, QString& tremoloType, int& tremoloNr, bool& lastGraceAFter);
void technical(Note* note, ChordRest* cr);
void glissando(Note* note, const int tick, const int ticks, const int track);
void notations(Note* note, ChordRest* cr, const int tick, MusicXmlTupletDesc& tupletDesc, bool& lastGraceAFter);
void stem(MScore::Direction& sd, bool& nost);
void fermata(ChordRest* cr);
void tuplet(MusicXmlTupletDesc& tupletDesc);
void doEnding(const QString& partId, Measure* measure, const QString& number, const QString& type, const QString& text);
void staffDetails(const QString& partId);
void staffTuning(StringData* t);
void skipLogCurrElem();
// part specific data interface functions
void addSpanner(const MusicXmlSpannerDesc& desc);
SLine* getSpanner(const MusicXmlSpannerDesc& desc);
void clearSpanner(const MusicXmlSpannerDesc& desc);
// multi-measure rest state handling
void setMultiMeasureRestCount(int count);
int getAndDecMultiMeasureRestCount();
private:
// generic pass 2 data
QXmlStreamReader _e;
int _divs; // the current divisions value
Score* const _score; // the score
MusicXMLParserPass1& _pass1; // the pass1 results
MxmlLogger* _logger; ///< Error logger
// part specific data (TODO: move to part-specific class)
// Measure duration according to last timesig read
// TODO: store timesigs read in pass 1, use those instead
// or use score->sigmap() ?
Fraction _timeSigDura;
QVector<Tuplet*> _tuplets; ///< Current tuplet for each track in the current part
QVector<bool> _tuplImpls; ///< Current tuplet implicit flag for each track in the current part
SlurStack _slurs { {} };
TrillStack _trills { {} }; ///< Current trills
BracketsStack _brackets { {} };
DashesStack _dashes { {} };
OttavasStack _ottavas { {} }; ///< Current ottavas
HairpinsStack _hairpins { {} }; ///< Current hairpins
Glissando* _glissandi[MAX_NUMBER_LEVEL][2]; ///< Current slides ([0]) / glissandi ([1])
Tie* _tie;
Volta* _lastVolta;
bool _hasDrumset; ///< drumset defined TODO: move to pass 1
MusicXmlSpannerMap _spanners;
SLine* _pedal; ///< Current pedal
Pedal* _pedalContinue; ///< Current pedal type="change" requiring fixup
Harmony* _harmony; ///< Current harmony
Chord* _tremStart; ///< Starting chord for current tremolo
FiguredBass* _figBass; ///< Current figured bass element (to attach to next note)
int _multiMeasureRestCount;
MusicXmlLyricsExtend _extendedLyrics; ///< Lyrics with "extend" requiring fixup
};
//---------------------------------------------------------
// MusicXMLParserDirection
//---------------------------------------------------------
class MusicXMLParserDirection {
public:
MusicXMLParserDirection(QXmlStreamReader& e, Score* score, const MusicXMLParserPass1& pass1, MusicXMLParserPass2& pass2, MxmlLogger* logger);
void direction(const QString& partId, Measure* measure, const int tick, MusicXmlSpannerMap& spanners);
private:
QXmlStreamReader& _e;
Score* const _score; // the score
const MusicXMLParserPass1& _pass1; // the pass1 results
MusicXMLParserPass2& _pass2; // the pass2 results
MxmlLogger* _logger; ///< Error logger
QStringList _dynamicsList;
QString _enclosure;
QString _wordsText;
QString _metroText;
QString _rehearsalText;
QString _dynaVelocity;
QString _tempo;
QString _sndCapo;
QString _sndCoda;
QString _sndDacapo;
QString _sndDalsegno;
QString _sndSegno;
QString _sndFine;
bool _hasDefaultY;
qreal _defaultY;
bool _coda;
bool _segno;
double _tpoMetro; // tempo according to metronome
double _tpoSound; // tempo according to sound
QList<Element*> _elems;
void directionType(QList<MusicXmlSpannerDesc>& starts, QList<MusicXmlSpannerDesc>& stops);
void bracket(const QString& type, const int number, QList<MusicXmlSpannerDesc>& starts, QList<MusicXmlSpannerDesc>& stops);
void octaveShift(const QString& type, const int number, QList<MusicXmlSpannerDesc>& starts, QList<MusicXmlSpannerDesc>& stops);
void pedal(const QString& type, const int number, QList<MusicXmlSpannerDesc>& starts, QList<MusicXmlSpannerDesc>& stops);
void dashes(const QString& type, const int number, QList<MusicXmlSpannerDesc>& starts, QList<MusicXmlSpannerDesc>& stops);
void wedge(const QString& type, const int number, QList<MusicXmlSpannerDesc>& starts, QList<MusicXmlSpannerDesc>& stops);
QString metronome(double& r);
void sound();
void dynamics();
void handleRepeats(Measure* measure, const int track);
void skipLogCurrElem();
};
} // namespace Ms
#endif
|