1 //============================================================================= 2 // MuseScore 3 // Music Composition & Notation 4 // 5 // Copyright (C) 2013 - 2015 Werner Schweer and others 6 // 7 // This program is free software; you can redistribute it and/or modify 8 // it under the terms of the GNU General Public License version 2 9 // as published by the Free Software Foundation and appearing in 10 // the file LICENCE.GPL 11 //============================================================================= 12 13 #ifndef __IMPORTXMLFIRSTPASS_H__ 14 #define __IMPORTXMLFIRSTPASS_H__ 15 16 #include "libmscore/fraction.h" 17 #include "libmscore/interval.h" 18 #include "musicxmlsupport.h" 19 20 namespace Ms { 21 22 typedef QMap<QString, VoiceDesc> VoiceList; 23 //using Intervals = std::map<Fraction, Interval>; 24 25 class MusicXmlIntervalList : public std::map<Fraction, Interval> { 26 public: MusicXmlIntervalList()27 MusicXmlIntervalList() {} 28 Interval interval(const Fraction f) const; 29 }; 30 31 class MusicXmlInstrList : public std::map<Fraction, QString> { 32 public: MusicXmlInstrList()33 MusicXmlInstrList() {} 34 const QString instrument(const Fraction f) const; 35 void setInstrument(const QString instr, const Fraction f); 36 }; 37 38 class MusicXmlOctaveShiftList : public std::map<Fraction, int> { 39 public: MusicXmlOctaveShiftList()40 MusicXmlOctaveShiftList() {} 41 int octaveShift(const Fraction f) const; 42 void addOctaveShift(const int shift, const Fraction f); 43 void calcOctaveShiftShifts(); 44 }; 45 46 class LyricNumberHandler { 47 public: LyricNumberHandler()48 LyricNumberHandler() {} 49 void addNumber(const QString number); 50 QString toString() const; 51 int getLyricNo(const QString& number) const; 52 void determineLyricNos(); 53 private: 54 std::map<QString, int> _numberToNo; 55 }; 56 57 class MusicXmlPart { 58 public: 59 MusicXmlPart(QString id = "", QString name = ""); 60 void addMeasureNumberAndDuration(QString measureNumber, Fraction measureDuration); getId()61 QString getId() const { return id; } 62 QString toString() const; 63 VoiceList voicelist; // the voice map information TODO: make private 64 Fraction measureDuration(int i) const; nMeasures()65 int nMeasures() const { return measureDurations.size(); } 66 MusicXmlInstrList _instrList; // TODO: make private 67 MusicXmlIntervalList _intervals; ///< Transpositions 68 Interval interval(const Fraction f) const; 69 int octaveShift(const int staff, const Fraction f) const; 70 void addOctaveShift(const int staff, const int shift, const Fraction f); 71 void calcOctaveShifts(); setName(QString nm)72 void setName(QString nm) { name = nm; } getName()73 QString getName() const { return name; } setPrintName(bool b)74 void setPrintName(bool b) { printName = b; } getPrintName()75 bool getPrintName() const { return printName; } setAbbr(QString ab)76 void setAbbr(QString ab) { abbr = ab; } getAbbr()77 QString getAbbr() const { return abbr; } setPrintAbbr(bool b)78 void setPrintAbbr(bool b) { printAbbr = b; } getPrintAbbr()79 bool getPrintAbbr() const { return printAbbr; } lyricNumberHandler()80 LyricNumberHandler& lyricNumberHandler() { return _lyricNumberHandler; } lyricNumberHandler()81 const LyricNumberHandler& lyricNumberHandler() const { return _lyricNumberHandler; } 82 void setMaxStaff(const int staff); maxStaff()83 int maxStaff() const { return _maxStaff; } 84 private: 85 QString id; 86 QString name; 87 bool printName = true; 88 QString abbr; 89 bool printAbbr = true; 90 QStringList measureNumbers; // MusicXML measure number attribute 91 QList<Fraction> measureDurations; // duration in fraction for every measure 92 QVector<MusicXmlOctaveShiftList> octaveShifts; // octave shift list for every staff 93 LyricNumberHandler _lyricNumberHandler; 94 int _maxStaff = 0; // maximum staff value found (1 based), 0 = none 95 }; 96 97 } // namespace Ms 98 #endif 99