8 #ifndef __VRV_IOMUSXML_H__
9 #define __VRV_IOMUSXML_H__
26 #include "pugixml.hpp"
64 #ifndef NO_MUSICXML_SUPPORT
69 OpenSlur(
const std::string &measureNum,
short int number, curvature_CURVEDIR curvedir)
71 m_measureNum = measureNum;
73 m_curvedir = curvedir;
76 std::string m_measureNum;
78 curvature_CURVEDIR m_curvedir;
82 CloseSlur(
const std::string &measureNum,
short int number, curvature_CURVEDIR curvedir)
84 m_measureNum = measureNum;
86 m_curvedir = curvedir;
89 std::string m_measureNum;
91 curvature_CURVEDIR m_curvedir;
95 OpenSpanner(
const int &dirN,
const int &lastMeasureCount)
98 m_lastMeasureCount = lastMeasureCount;
102 int m_lastMeasureCount;
105 struct OpenArpeggio {
106 OpenArpeggio(
const int &arpegN,
const Fraction &timeStamp)
109 m_timeStamp = timeStamp;
113 Fraction m_timeStamp;
117 EndingInfo(
const std::string &endingNumber,
const std::string &endingType,
const std::string &endingText)
119 m_endingNumber = endingNumber;
120 m_endingType = endingType;
121 m_endingText = endingText;
124 std::string m_endingNumber;
125 std::string m_endingType;
126 std::string m_endingText;
130 ClefChange(
const std::string &measureNum, Staff *staff, Layer *layer, Clef *clef,
const int &scoreOnset,
133 m_measureNum = measureNum;
137 m_scoreOnset = scoreOnset;
138 m_afterBarline = afterBarline;
141 std::string m_measureNum;
146 bool m_afterBarline =
false;
150 OpenDashes(
const int dirN,
int staffNum,
const int measureCount)
153 m_staffNum = staffNum;
154 m_measureCount = measureCount;
163 OpenTie(Tie *tie, Note *note,
int layerNum)
167 m_layerNum = layerNum;
176 CloseTie(Note *note,
int layerNum)
179 m_layerNum = layerNum;
188 #endif // NO_MUSICXML_SUPPORT
204 ListOfObjects m_garbage;
206 #ifndef NO_MUSICXML_SUPPORT
208 bool Import(
const std::string &musicxml)
override;
214 bool ReadMusicXml(pugi::xml_node root);
219 void ReadMusicXmlTitle(pugi::xml_node title);
225 bool ReadMusicXmlPart(pugi::xml_node node,
Section *section,
short int nbStaves,
const short int staffOffset);
226 bool ReadMusicXmlMeasure(pugi::xml_node node,
Section *section,
Measure *measure,
short int nbStaves,
227 const short int staffOffset,
int index);
234 short int ReadMusicXmlPartAttributesAsStaffDef(
235 pugi::xml_node node,
StaffGrp *staffGrp,
const short int staffOffset);
241 void ReadMusicXmlAttributes(pugi::xml_node,
Section *section,
Measure *measure,
const std::string &measureNum);
242 void ReadMusicXmlBackup(pugi::xml_node,
Measure *measure,
const std::string &measureNum);
243 void ReadMusicXmlBarLine(pugi::xml_node,
Measure *measure,
const std::string &measureNum);
244 void ReadMusicXmlDirection(
245 pugi::xml_node,
Measure *measure,
const std::string &measureNum,
const short int staffOffset);
246 void ReadMusicXmlFigures(pugi::xml_node,
Measure *measure,
const std::string &measureNum);
247 void ReadMusicXmlForward(pugi::xml_node,
Measure *measure,
const std::string &measureNum);
248 void ReadMusicXmlHarmony(pugi::xml_node,
Measure *measure,
const std::string &measureNum);
249 void ReadMusicXmlNote(
250 pugi::xml_node,
Measure *measure,
const std::string &measureNum,
const short int staffOffset,
Section *section);
251 void ReadMusicXmlPrint(pugi::xml_node,
Section *section);
252 bool ReadMusicXmlBeamsAndTuplets(
const pugi::xml_node &node,
Layer *layer,
bool isChord);
253 void ReadMusicXmlTupletStart(
const pugi::xml_node &node,
const pugi::xml_node &tupletStart,
Layer *layer);
254 void ReadMusicXmlBeamStart(
const pugi::xml_node &node,
const pugi::xml_node &beamStart,
Layer *layer);
255 void ReadMusicXMLMeterSig(
const pugi::xml_node &node,
Object *parent);
256 void ReadMusicXmlTies(
const pugi::xml_node &node,
Layer *layer,
Note *note,
const std::string &measureNum);
262 void ProcessClefChangeQueue(
Section *section);
267 void AddClefs(
Measure *measure,
const musicxml::ClefChange &clefChange);
272 void InsertClefToLayer(
Staff *staff,
Layer *layer,
Clef *clef,
int scoreOnSet);
279 void InsertClefIntoObject(
Object *layerElement,
Clef *clef,
Layer *layer,
int scoreOnset,
bool insertAfter);
280 void InsertClefIntoObject(
Object *parent,
Clef *clef,
Object *relevantChild,
bool insertAfter);
298 Layer *SelectLayer(pugi::xml_node node,
Measure *measure);
303 Layer *SelectLayer(
short int staffNb,
Measure *measure);
309 Layer *SelectLayer(
short int layerNb,
Staff *staff);
315 Clef *ConvertClef(
const pugi::xml_node &clef);
316 KeySig *ConvertKey(
const pugi::xml_node &key);
324 void RemoveLastFromStack(ClassId classId,
Layer *layer);
329 bool IsInStack(ClassId classId,
Layer *layer);
335 bool HasAttributeWithValue(
const pugi::xml_node node,
const std::string &attribute,
const std::string &value)
const;
336 bool IsElement(
const pugi::xml_node node,
const std::string &name)
const;
337 bool HasContentWithValue(
const pugi::xml_node node,
const std::string &value)
const;
344 bool NotInEndingStack(
const Measure *measure)
const;
351 std::string GetContent(
const pugi::xml_node node)
const;
352 std::string GetContentOfChild(
const pugi::xml_node node,
const std::string &child)
const;
362 void OpenTie(
Note *note,
Tie *tie,
int layerNum);
363 void CloseTie(
Note *note,
int layerNum);
364 void OpenSlur(
Measure *measure,
short int number,
Slur *slur, curvature_CURVEDIR dir);
365 void CloseSlur(
Measure *measure,
short int number,
LayerElement *element, curvature_CURVEDIR dir);
367 void MatchTies(
bool matchLayers);
375 std::string GetWordsOrDynamicsText(
const pugi::xml_node node)
const;
376 void TextRendition(
const pugi::xpath_node_set words,
ControlElement *element)
const;
377 std::string StyleLabel(pugi::xml_node display);
378 void PrintMetronome(pugi::xml_node metronome,
Tempo *tempo);
385 void FillSpace(
Layer *layer,
int dur);
392 void GenerateID(pugi::xml_node node);
399 std::pair<std::vector<int>,
int> GetMeterSigGrpValues(
const pugi::xml_node &node,
MeterSigGrp *parent);
407 int GetMrestMeasuresCountBeforeIndex(
int index)
const;
414 bool IsMultirestMeasure(
int index)
const;
421 void SetFermataExternalSymbols(
Fermata *fermata,
const std::string &shape);
422 void ShapeFermata(
Fermata *fermata, pugi::xml_node node);
429 std::string GetOrnamentGlyphNumber(
int attributes)
const;
436 void SetChordStaff(
Layer *layer);
443 static bool IsSameAccidWrittenGestural(data_ACCIDENTAL_WRITTEN written, data_ACCIDENTAL_GESTURAL gestural);
449 static curvature_CURVEDIR CombineCurvedir(curvature_CURVEDIR startDir, curvature_CURVEDIR stopDir);
455 static data_ACCIDENTAL_WRITTEN ConvertAccidentalToAccid(
const std::string &value);
456 static data_ACCIDENTAL_GESTURAL ConvertAlterToAccid(
const float value);
457 static data_ARTICULATION ConvertArticulations(
const std::string &value);
458 static data_BARRENDITION ConvertStyleToRend(
const std::string &value,
const bool repeat);
459 static data_BOOLEAN ConvertWordToBool(
const std::string &value);
460 static data_DURATION ConvertTypeToDur(
const std::string &value);
461 static data_HEADSHAPE ConvertNotehead(
const std::string &value);
462 static data_LINESTARTENDSYMBOL ConvertLineEndSymbol(
const std::string &value);
463 static data_MIDIVALUE ConvertDynamicsToMidiVal(
const float dynamics);
464 static data_PITCHNAME ConvertStepToPitchName(
const std::string &value);
465 static data_TEXTRENDITION ConvertEnclosure(
const std::string &value);
466 static beamRend_FORM ConvertBeamFanToForm(
const std::string &value);
467 static curvature_CURVEDIR InferCurvedir(
const pugi::xml_node slurOrTie);
468 static fermataVis_SHAPE ConvertFermataShape(
const std::string &value);
469 static pedalLog_DIR ConvertPedalTypeToDir(
const std::string &value);
470 static tupletVis_NUMFORMAT ConvertTupletNumberValue(
const std::string &value);
471 static std::u32string ConvertTypeToVerovioText(
const std::string &value);
472 static std::string ConvertAlterToSymbol(
const std::string &value,
bool plusMinus =
false);
473 static std::string ConvertKindToSymbol(
const std::string &value);
474 static std::string ConvertKindToText(
const std::string &value);
475 static std::string ConvertDegreeToText(
const pugi::xml_node harmony);
476 static std::string ConvertFigureGlyph(
const std::string &value);
483 static int PitchToMidi(
const std::string &step,
int alter,
int octave);
484 static void MidiToPitch(
int midi, std::string &step,
int &alter,
int &octave);
491 std::vector<int> m_octDis;
495 bool m_slash =
false;
503 std::vector<int> m_meterCount = { 4 };
505 MeterCountSign m_meterSign = MeterCountSign::None;
507 Label *m_label = NULL;
513 std::map<Layer *, std::vector<LayerElement *>> m_elementStackMap;
515 std::map<Layer *, int> m_layerEndTimes;
516 std::map<Layer *, std::multimap<int, LayerElement *>> m_layerTimes;
518 Layer *m_prevLayer = NULL;
520 Layer *m_currentLayer = NULL;
521 bool m_isLayerInitialized =
false;
523 std::vector<std::pair<Slur *, musicxml::OpenSlur>> m_slurStack;
525 std::vector<std::pair<LayerElement *, musicxml::CloseSlur>> m_slurStopStack;
527 std::vector<musicxml::OpenTie> m_tieStack;
529 std::vector<musicxml::CloseTie> m_tieStopStack;
531 std::vector<std::pair<Hairpin *, musicxml::OpenSpanner>> m_hairpinStack;
534 std::vector<std::tuple<int, double, musicxml::OpenSpanner>> m_hairpinStopStack;
536 std::vector<std::pair<BeamSpan *, std::pair<int, int>>> m_beamspanStack;
537 std::vector<std::pair<BracketSpan *, musicxml::OpenSpanner>> m_bracketStack;
538 std::vector<std::pair<Trill *, musicxml::OpenSpanner>> m_trillStack;
540 std::optional<musicxml::EndingInfo> m_currentEndingStart;
541 std::optional<musicxml::EndingInfo> m_currentEndingStop;
543 std::vector<std::pair<std::vector<Measure *>, musicxml::EndingInfo>> m_endingStack;
545 std::vector<std::pair<ControlElement *, musicxml::OpenDashes>> m_openDashesStack;
547 std::vector<Dir *> m_dirStack;
548 std::vector<Dynam *> m_dynamStack;
549 std::vector<Gliss *> m_glissStack;
550 std::vector<Harm *> m_harmStack;
551 std::vector<Octave *> m_octaveStack;
552 std::vector<Pedal *> m_pedalStack;
553 std::vector<Tempo *> m_tempoStack;
558 std::vector<std::pair<std::string, ControlElement *>> m_controlElements;
560 std::queue<musicxml::ClefChange> m_clefChangeQueue;
562 std::vector<std::pair<Arpeg *, musicxml::OpenArpeggio>> m_ArpeggioStack;
564 std::map<Measure *, int> m_measureCounts;
566 std::map<int, int> m_multiRests;
568 #endif // NO_MUSICXML_SUPPORT
573 #endif // __VRV_IOMUSXML_H__