MuseScore  3.4
Music composition and notation
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Ms::MusicXMLParserPass1 Class Reference

#include <importmxmlpass1.h>

Collaboration diagram for Ms::MusicXMLParserPass1:
Collaboration graph
[legend]

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...
 
PartgetPart (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...
 

Constructor & Destructor Documentation

◆ MusicXMLParserPass1()

Ms::MusicXMLParserPass1::MusicXMLParserPass1 ( Score score,
MxmlLogger logger 
)

Member Function Documentation

◆ attributes()

void Ms::MusicXMLParserPass1::attributes ( const QString &  partId,
const Fraction  cTime 
)

Parse the /score-partwise/part/measure/attributes node.

◆ backup()

void Ms::MusicXMLParserPass1::backup ( Fraction dura)

Parse the /score-partwise/part/measure/note/backup node.

◆ clef()

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.

◆ credit()

void Ms::MusicXMLParserPass1::credit ( CreditWordsList credits)

Parse the /score-partwise/credit node: read the credits for later handling by doCredits().

◆ defaults()

void Ms::MusicXMLParserPass1::defaults ( int &  pageWidth,
int &  pageHeight 
)

Parse the /score-partwise/defaults node: read the general score layout settings.

◆ determineMeasureLength()

bool Ms::MusicXMLParserPass1::determineMeasureLength ( QVector< Fraction > &  ml) const

Determine the length in ticks of each measure in all parts.

Return false on error.

◆ determineStaffMoveVoice()

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

◆ direction()

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.

◆ directionType()

void Ms::MusicXMLParserPass1::directionType ( const Fraction  cTime,
QList< MxmlOctaveShiftDesc > &  starts,
QList< MxmlOctaveShiftDesc > &  stops 
)

Parse the /score-partwise/part/measure/direction/direction-type node.

◆ divisions()

void Ms::MusicXMLParserPass1::divisions ( )

Parse the /score-partwise/part/measure/attributes/divisions node.

◆ duration()

void Ms::MusicXMLParserPass1::duration ( Fraction dura)

Parse the /score-partwise/part/measure/note/duration node.

◆ forward()

void Ms::MusicXMLParserPass1::forward ( Fraction dura)

Parse the /score-partwise/part/measure/note/forward node.

◆ getDrumset()

MusicXMLDrumset Ms::MusicXMLParserPass1::getDrumset ( const QString &  id) const
inline

◆ getInstrList()

MusicXmlInstrList Ms::MusicXMLParserPass1::getInstrList ( const QString  id) const

Get the MusicXmlInstrList for part id.

Return an empty MusicXmlInstrList on error.

◆ getMeasureStart()

Fraction Ms::MusicXMLParserPass1::getMeasureStart ( const int  i) const

Return the measure start time for measure i.

◆ getMusicXmlPart()

MusicXmlPart Ms::MusicXMLParserPass1::getMusicXmlPart ( const QString &  id) const
inline

◆ getPart()

Part* Ms::MusicXMLParserPass1::getPart ( const QString &  id) const
inline

◆ getVoiceList()

VoiceList Ms::MusicXMLParserPass1::getVoiceList ( const QString  id) const

Get the VoiceList for part id.

Return an empty VoiceList on error.

◆ handleOctaveShift()

void Ms::MusicXMLParserPass1::handleOctaveShift ( const Fraction  cTime,
const QString &  type,
short  size,
MxmlOctaveShiftDesc desc 
)

◆ hasPart()

bool Ms::MusicXMLParserPass1::hasPart ( const QString &  id) const

Check if part id is found.

◆ identification()

void Ms::MusicXMLParserPass1::identification ( )

Parse the /score-partwise/identification node: read the metadata.

◆ initPartState()

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).

◆ measure()

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.

◆ midiInstrument()

void Ms::MusicXMLParserPass1::midiInstrument ( const QString &  partId)

Parse the /score-partwise/part-list/score-part/midi-instrument node.

◆ notations()

void Ms::MusicXMLParserPass1::notations ( MxmlStartStop tupletStartStop)

Parse the /score-partwise/part/measure/note/notations node.

◆ note()

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.

◆ notePrintSpacingNo()

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.

◆ octaveShift()

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.

◆ pageLayout()

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.

◆ parse() [1/2]

Score::FileError Ms::MusicXMLParserPass1::parse ( QIODevice *  device)

Parse MusicXML in device and extract pass 1 data.

◆ parse() [2/2]

Score::FileError Ms::MusicXMLParserPass1::parse ( )

Start the parsing process, after verifying the top-level node is score-partwise.

◆ part()

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.

◆ partGroup()

void Ms::MusicXMLParserPass1::partGroup ( const int  scoreParts,
MusicXmlPartGroupList partGroupList,
MusicXmlPartGroupMap partGroups 
)

Parse the /score-partwise/part-list/part-group node.

◆ partList()

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.

◆ pitch()

void Ms::MusicXMLParserPass1::pitch ( int &  step,
float &  alter,
int &  oct 
)

◆ rest()

void Ms::MusicXMLParserPass1::rest ( )

Parse the /score-partwise/part/measure/note/rest node.

◆ scoreInstrument()

void Ms::MusicXMLParserPass1::scoreInstrument ( const QString &  partId)

Parse the /score-partwise/part-list/score-part/score-instrument node.

◆ scorePart()

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.

◆ scorePartwise()

void Ms::MusicXMLParserPass1::scorePartwise ( )

Parse the MusicXML top-level (XPath /score-partwise) node.

< Page width read from defaults

< Page height read from defaults

◆ setDrumsetDefault()

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.

◆ setFirstInstr()

void Ms::MusicXMLParserPass1::setFirstInstr ( const QString &  id,
const Fraction  stime 
)
private

◆ skipLogCurrElem()

void Ms::MusicXMLParserPass1::skipLogCurrElem ( )

Skip the current element, log debug as info.

◆ staves()

void Ms::MusicXMLParserPass1::staves ( const QString &  partId)

Parse the /score-partwise/part/measure/attributes/staves node.

◆ time()

void Ms::MusicXMLParserPass1::time ( const Fraction  cTime)

Parse the /score-partwise/part/measure/attributes/time node.

◆ timeModification()

void Ms::MusicXMLParserPass1::timeModification ( Fraction timeMod)

Parse the /score-partwise/part/measure/note/time-modification node.

◆ trackForPart()

int Ms::MusicXMLParserPass1::trackForPart ( const QString &  id) const

Return the (score relative) track number for the first staff of part id.

Member Data Documentation

◆ _divs

int Ms::MusicXMLParserPass1::_divs
private

Current MusicXML divisions value.

◆ _drumsets

QMap<QString, MusicXMLDrumset> Ms::MusicXMLParserPass1::_drumsets
private

Drumset for each part, mapped on part id.

◆ _e

QXmlStreamReader Ms::MusicXMLParserPass1::_e
private

◆ _firstInstrId

QString Ms::MusicXMLParserPass1::_firstInstrId
private

First instrument id.

◆ _firstInstrSTime

Fraction Ms::MusicXMLParserPass1::_firstInstrSTime
private

First instrument start time.

◆ _logger

MxmlLogger* Ms::MusicXMLParserPass1::_logger
private

Error logger.

◆ _measureLength

QVector<Fraction> Ms::MusicXMLParserPass1::_measureLength
private

Length of each measure.

◆ _measureStart

QVector<Fraction> Ms::MusicXMLParserPass1::_measureStart
private

Start time of each measure.

◆ _octaveShifts

QMap<int, MxmlOctaveShiftDesc> Ms::MusicXMLParserPass1::_octaveShifts
private

Pending octave-shifts.

◆ _partMap

PartMap Ms::MusicXMLParserPass1::_partMap
private

TODO merge into MusicXmlPart ??

◆ _parts

QMap<QString, MusicXmlPart> Ms::MusicXMLParserPass1::_parts
private

Parts data, mapped on part id.

◆ _score

Score* Ms::MusicXMLParserPass1::_score
private

MuseScore score.

◆ _timeSigDura

Fraction Ms::MusicXMLParserPass1::_timeSigDura
private

Measure duration according to last timesig read.


The documentation for this class was generated from the following files: