MuseScore
3.4
Music composition and notation
|
#include <importmxmlpass1.h>
Public Member Functions | |
MusicXMLParserPass1 (Score *score, MxmlLogger *logger) | |
void | initPartState (const QString &partId) |
Initialize members as required for reading the MusicXML part element. More... | |
Score::FileError | parse (QIODevice *device) |
Parse MusicXML in device and extract pass 1 data. More... | |
Score::FileError | parse () |
Start the parsing process, after verifying the top-level node is score-partwise. More... | |
void | scorePartwise () |
Parse the MusicXML top-level (XPath /score-partwise) node. More... | |
void | identification () |
Parse the /score-partwise/identification node: read the metadata. More... | |
void | credit (CreditWordsList &credits) |
Parse the /score-partwise/credit node: read the credits for later handling by doCredits(). More... | |
void | defaults (int &pageWidth, int &pageHeight) |
Parse the /score-partwise/defaults node: read the general score layout settings. More... | |
void | pageLayout (PageFormat &pf, const qreal conversion, int &pageWidth, int &pageHeight) |
Parse the /score-partwise/defaults/page-layout node: read the page layout. More... | |
void | partList (MusicXmlPartGroupList &partGroupList) |
Parse the /score-partwise/part-list: create the parts and for each part set id and name. More... | |
void | partGroup (const int scoreParts, MusicXmlPartGroupList &partGroupList, MusicXmlPartGroupMap &partGroups) |
Parse the /score-partwise/part-list/part-group node. More... | |
void | scorePart () |
Find the first InstrumentTemplate with musicXMLid instrSound and a non-empty set of channels. More... | |
void | scoreInstrument (const QString &partId) |
Parse the /score-partwise/part-list/score-part/score-instrument node. More... | |
void | midiInstrument (const QString &partId) |
Parse the /score-partwise/part-list/score-part/midi-instrument node. More... | |
void | part () |
Parse the /score-partwise/part node: read the parts data to determine measure timing and octave shifts. More... | |
void | measure (const QString &partId, const Fraction cTime, Fraction &mdur, VoiceOverlapDetector &vod) |
Parse the /score-partwise/part/measure node: read the measures data as required to determine measure timing, octave shifts and assign voices and staves. More... | |
void | attributes (const QString &partId, const Fraction cTime) |
Parse the /score-partwise/part/measure/attributes node. More... | |
void | clef (const QString &partId) |
Parse the /score-partwise/part/measure/attributes/clef node. More... | |
void | time (const Fraction cTime) |
Parse the /score-partwise/part/measure/attributes/time node. More... | |
void | divisions () |
Parse the /score-partwise/part/measure/attributes/divisions node. More... | |
void | staves (const QString &partId) |
Parse the /score-partwise/part/measure/attributes/staves node. More... | |
void | direction (const QString &partId, const Fraction cTime) |
Parse the /score-partwise/part/measure/direction node to be able to handle octave-shifts, as these must be interpreted in musical order instead of in MusicXML file order. More... | |
void | directionType (const Fraction cTime, QList< MxmlOctaveShiftDesc > &starts, QList< MxmlOctaveShiftDesc > &stops) |
Parse the /score-partwise/part/measure/direction/direction-type node. More... | |
void | handleOctaveShift (const Fraction cTime, const QString &type, short size, MxmlOctaveShiftDesc &desc) |
void | notations (MxmlStartStop &tupletStartStop) |
Parse the /score-partwise/part/measure/note/notations node. More... | |
void | note (const QString &partId, const Fraction cTime, Fraction &missingPrev, Fraction &dura, Fraction &missingCurr, VoiceOverlapDetector &vod, MxmlTupletStates &tupletStates) |
Parse the /score-partwise/part/measure/note node. More... | |
void | notePrintSpacingNo (Fraction &dura) |
Parse the /score-partwise/part/measure/note node for a note with print-spacing="no". More... | |
void | duration (Fraction &dura) |
Parse the /score-partwise/part/measure/note/duration node. More... | |
void | forward (Fraction &dura) |
Parse the /score-partwise/part/measure/note/forward node. More... | |
void | backup (Fraction &dura) |
Parse the /score-partwise/part/measure/note/backup node. More... | |
void | timeModification (Fraction &timeMod) |
Parse the /score-partwise/part/measure/note/time-modification node. More... | |
void | pitch (int &step, float &alter, int &oct) |
void | rest () |
Parse the /score-partwise/part/measure/note/rest node. More... | |
void | skipLogCurrElem () |
Skip the current element, log debug as info. More... | |
bool | determineMeasureLength (QVector< Fraction > &ml) const |
Determine the length in ticks of each measure in all parts. More... | |
VoiceList | getVoiceList (const QString id) const |
Get the VoiceList for part id. More... | |
bool | determineStaffMoveVoice (const QString &id, const int mxStaff, const QString &mxVoice, int &msMove, int &msTrack, int &msVoice) const |
For part id, determine MuseScore (ms) staffmove, track and voice from MusicXML (mx) staff and voice MusicXML staff is 0 for the first staff, 1 for the second. More... | |
int | trackForPart (const QString &id) const |
Return the (score relative) track number for the first staff of part id. More... | |
bool | hasPart (const QString &id) const |
Check if part id is found. More... | |
Part * | getPart (const QString &id) const |
MusicXmlPart | getMusicXmlPart (const QString &id) const |
MusicXMLDrumset | getDrumset (const QString &id) const |
void | setDrumsetDefault (const QString &id, const QString &instrId, const NoteHead::Group hg, const int line, const Direction sd) |
Set default notehead, line and stem direction for instrument instrId in part id. More... | |
MusicXmlInstrList | getInstrList (const QString id) const |
Get the MusicXmlInstrList for part id. More... | |
Fraction | getMeasureStart (const int i) const |
Return the measure start time for measure i. More... | |
int | octaveShift (const QString &id, const int staff, const Fraction f) const |
Return the octave shift for part id in staff at f. More... | |
Private Member Functions | |
void | setFirstInstr (const QString &id, const Fraction stime) |
Private Attributes | |
QXmlStreamReader | _e |
int | _divs |
Current MusicXML divisions value. More... | |
QMap< QString, MusicXmlPart > | _parts |
Parts data, mapped on part id. More... | |
QVector< Fraction > | _measureLength |
Length of each measure. More... | |
QVector< Fraction > | _measureStart |
Start time of each measure. More... | |
PartMap | _partMap |
TODO merge into MusicXmlPart ?? More... | |
QMap< QString, MusicXMLDrumset > | _drumsets |
Drumset for each part, mapped on part id. More... | |
Score * | _score |
MuseScore score. More... | |
MxmlLogger * | _logger |
Error logger. More... | |
Fraction | _timeSigDura |
Measure duration according to last timesig read. More... | |
QMap< int, MxmlOctaveShiftDesc > | _octaveShifts |
Pending octave-shifts. More... | |
Fraction | _firstInstrSTime |
First instrument start time. More... | |
QString | _firstInstrId |
First instrument id. More... | |
Ms::MusicXMLParserPass1::MusicXMLParserPass1 | ( | Score * | score, |
MxmlLogger * | logger | ||
) |
void Ms::MusicXMLParserPass1::attributes | ( | const QString & | partId, |
const Fraction | cTime | ||
) |
Parse the /score-partwise/part/measure/attributes node.
void Ms::MusicXMLParserPass1::backup | ( | Fraction & | dura | ) |
Parse the /score-partwise/part/measure/note/backup node.
void Ms::MusicXMLParserPass1::clef | ( | const QString & | partId | ) |
Parse the /score-partwise/part/measure/attributes/clef node.
TODO: Store the clef type, to simplify staff type setting in pass 2.
void Ms::MusicXMLParserPass1::credit | ( | CreditWordsList & | credits | ) |
Parse the /score-partwise/credit node: read the credits for later handling by doCredits().
void Ms::MusicXMLParserPass1::defaults | ( | int & | pageWidth, |
int & | pageHeight | ||
) |
Parse the /score-partwise/defaults node: read the general score layout settings.
bool Ms::MusicXMLParserPass1::determineMeasureLength | ( | QVector< Fraction > & | ml | ) | const |
Determine the length in ticks of each measure in all parts.
Return false on error.
bool Ms::MusicXMLParserPass1::determineStaffMoveVoice | ( | const QString & | id, |
const int | mxStaff, | ||
const QString & | mxVoice, | ||
int & | msMove, | ||
int & | msTrack, | ||
int & | msVoice | ||
) | const |
For part id, determine MuseScore (ms) staffmove, track and voice from MusicXML (mx) staff and voice MusicXML staff is 0 for the first staff, 1 for the second.
Note: track is the first track of the ms staff in the score, add ms voice for elements in a voice Return true if OK, false on error TODO: finalize
void Ms::MusicXMLParserPass1::direction | ( | const QString & | partId, |
const Fraction | cTime | ||
) |
Parse the /score-partwise/part/measure/direction node to be able to handle octave-shifts, as these must be interpreted in musical order instead of in MusicXML file order.
void Ms::MusicXMLParserPass1::directionType | ( | const Fraction | cTime, |
QList< MxmlOctaveShiftDesc > & | starts, | ||
QList< MxmlOctaveShiftDesc > & | stops | ||
) |
Parse the /score-partwise/part/measure/direction/direction-type node.
void Ms::MusicXMLParserPass1::divisions | ( | ) |
Parse the /score-partwise/part/measure/attributes/divisions node.
void Ms::MusicXMLParserPass1::duration | ( | Fraction & | dura | ) |
Parse the /score-partwise/part/measure/note/duration node.
void Ms::MusicXMLParserPass1::forward | ( | Fraction & | dura | ) |
Parse the /score-partwise/part/measure/note/forward node.
|
inline |
MusicXmlInstrList Ms::MusicXMLParserPass1::getInstrList | ( | const QString | id | ) | const |
Get the MusicXmlInstrList for part id.
Return an empty MusicXmlInstrList on error.
Fraction Ms::MusicXMLParserPass1::getMeasureStart | ( | const int | i | ) | const |
Return the measure start time for measure i.
|
inline |
|
inline |
VoiceList Ms::MusicXMLParserPass1::getVoiceList | ( | const QString | id | ) | const |
Get the VoiceList for part id.
Return an empty VoiceList on error.
void Ms::MusicXMLParserPass1::handleOctaveShift | ( | const Fraction | cTime, |
const QString & | type, | ||
short | size, | ||
MxmlOctaveShiftDesc & | desc | ||
) |
bool Ms::MusicXMLParserPass1::hasPart | ( | const QString & | id | ) | const |
Check if part id is found.
void Ms::MusicXMLParserPass1::identification | ( | ) |
Parse the /score-partwise/identification node: read the metadata.
void Ms::MusicXMLParserPass1::initPartState | ( | const QString & | partId | ) |
Initialize members as required for reading the MusicXML part element.
TODO: factor out part reading into a separate class TODO: preferably use automatically initialized variables Note that Qt automatically initializes new elements in QVector (tuplets).
void Ms::MusicXMLParserPass1::measure | ( | const QString & | partId, |
const Fraction | cTime, | ||
Fraction & | mdur, | ||
VoiceOverlapDetector & | vod | ||
) |
Parse the /score-partwise/part/measure node: read the measures data as required to determine measure timing, octave shifts and assign voices and staves.
void Ms::MusicXMLParserPass1::midiInstrument | ( | const QString & | partId | ) |
Parse the /score-partwise/part-list/score-part/midi-instrument node.
void Ms::MusicXMLParserPass1::notations | ( | MxmlStartStop & | tupletStartStop | ) |
Parse the /score-partwise/part/measure/note/notations node.
void Ms::MusicXMLParserPass1::note | ( | const QString & | partId, |
const Fraction | cTime, | ||
Fraction & | missingPrev, | ||
Fraction & | dura, | ||
Fraction & | missingCurr, | ||
VoiceOverlapDetector & | vod, | ||
MxmlTupletStates & | tupletStates | ||
) |
Parse the /score-partwise/part/measure/note node.
void Ms::MusicXMLParserPass1::notePrintSpacingNo | ( | Fraction & | dura | ) |
Parse the /score-partwise/part/measure/note node for a note with print-spacing="no".
These are handled like a forward: only moving the time forward.
int Ms::MusicXMLParserPass1::octaveShift | ( | const QString & | id, |
const int | staff, | ||
const Fraction | f | ||
) | const |
Return the octave shift for part id in staff at f.
void Ms::MusicXMLParserPass1::pageLayout | ( | PageFormat & | pf, |
const qreal | conversion, | ||
int & | pageWidth, | ||
int & | pageHeight | ||
) |
Parse the /score-partwise/defaults/page-layout node: read the page layout.
Score::FileError Ms::MusicXMLParserPass1::parse | ( | QIODevice * | device | ) |
Parse MusicXML in device and extract pass 1 data.
Score::FileError Ms::MusicXMLParserPass1::parse | ( | ) |
Start the parsing process, after verifying the top-level node is score-partwise.
void Ms::MusicXMLParserPass1::part | ( | ) |
Parse the /score-partwise/part node: read the parts data to determine measure timing and octave shifts.
Assign voices and staves.
void Ms::MusicXMLParserPass1::partGroup | ( | const int | scoreParts, |
MusicXmlPartGroupList & | partGroupList, | ||
MusicXmlPartGroupMap & | partGroups | ||
) |
Parse the /score-partwise/part-list/part-group node.
void Ms::MusicXMLParserPass1::partList | ( | MusicXmlPartGroupList & | partGroupList | ) |
Parse the /score-partwise/part-list: create the parts and for each part set id and name.
Also handle the part-groups.
void Ms::MusicXMLParserPass1::pitch | ( | int & | step, |
float & | alter, | ||
int & | oct | ||
) |
void Ms::MusicXMLParserPass1::rest | ( | ) |
Parse the /score-partwise/part/measure/note/rest node.
void Ms::MusicXMLParserPass1::scoreInstrument | ( | const QString & | partId | ) |
Parse the /score-partwise/part-list/score-part/score-instrument node.
void Ms::MusicXMLParserPass1::scorePart | ( | ) |
Find the first InstrumentTemplate with musicXMLid instrSound and a non-empty set of channels.
Parse the /score-partwise/part-list/score-part node: create the part and sets id and name. Note that a part is created even if no part-name is present which is invalid MusicXML but is (sometimes ?) generated by NWC2MusicXML.
void Ms::MusicXMLParserPass1::scorePartwise | ( | ) |
void Ms::MusicXMLParserPass1::setDrumsetDefault | ( | const QString & | id, |
const QString & | instrId, | ||
const NoteHead::Group | hg, | ||
const int | line, | ||
const Direction | sd | ||
) |
Set default notehead, line and stem direction for instrument instrId in part id.
|
private |
void Ms::MusicXMLParserPass1::skipLogCurrElem | ( | ) |
Skip the current element, log debug as info.
void Ms::MusicXMLParserPass1::staves | ( | const QString & | partId | ) |
Parse the /score-partwise/part/measure/attributes/staves node.
void Ms::MusicXMLParserPass1::time | ( | const Fraction | cTime | ) |
Parse the /score-partwise/part/measure/attributes/time node.
void Ms::MusicXMLParserPass1::timeModification | ( | Fraction & | timeMod | ) |
Parse the /score-partwise/part/measure/note/time-modification node.
int Ms::MusicXMLParserPass1::trackForPart | ( | const QString & | id | ) | const |
Return the (score relative) track number for the first staff of part id.
|
private |
Current MusicXML divisions value.
|
private |
Drumset for each part, mapped on part id.
|
private |
|
private |
First instrument id.
|
private |
First instrument start time.
|
private |
Error logger.
|
private |
Length of each measure.
|
private |
Start time of each measure.
|
private |
Pending octave-shifts.
|
private |
TODO merge into MusicXmlPart ??
|
private |
Parts data, mapped on part id.
|
private |
Measure duration according to last timesig read.