Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ void MusicXMLParserPass1::identification()
// TODO
while (m_e.readNextStartElement()) {
if (m_e.name() == "software") {
m_exporterString += m_e.readText();
m_exporterString += m_e.readText().toLower();
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz Feb 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't mix and match with

if (m_pass1.exporterString().contains(u"Dolet")) {

} else if (m_e.name() == "supports" && m_e.asciiAttribute("element") == "beam" && m_e.asciiAttribute("type") == "yes") {
m_hasBeamingInfo = true;
m_e.skipCurrentElement();
Expand Down
30 changes: 24 additions & 6 deletions src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,7 @@ void MusicXMLParserPass2::initPartState(const String& partId)
m_harmony = 0;
m_tremStart = 0;
m_figBass = 0;
m_delayedOttava = 0;
m_multiMeasureRestCount = -1;
m_measureStyleSlash = MusicXmlSlash::NONE;
m_extendedLyrics.init();
Expand Down Expand Up @@ -1918,7 +1919,7 @@ void MusicXMLParserPass2::part()
}
}

// stop all remaining extends for this part
// stop all remaining extends for this part and add remaining ottava if present
Measure* lm = part->score()->lastMeasure();
if (lm) {
track_idx_t strack = m_pass1.trackForPart(id);
Expand All @@ -1927,6 +1928,10 @@ void MusicXMLParserPass2::part()
for (track_idx_t trk = strack; trk < etrack; trk++) {
m_extendedLyrics.setExtend(-1, trk, lastTick);
}
if (m_delayedOttava && m_delayedOttava->tick2() < lastTick) {
handleSpannerStop(m_delayedOttava, m_delayedOttava->track2(), lastTick, m_spanners);
m_delayedOttava = nullptr;
}
}

const auto incompleteSpanners = findIncompleteSpannersAtPartEnd();
Expand Down Expand Up @@ -2331,6 +2336,11 @@ void MusicXMLParserPass2::measure(const String& partId, const Fraction time)
} else if (m_e.name() == "harmony") {
harmony(partId, measure, time + mTime);
} else if (m_e.name() == "note") {
// Correct delayed ottava tick
if (m_delayedOttava && m_delayedOttava->tick2() < time + mTime) {
handleSpannerStop(m_delayedOttava, m_delayedOttava->track2(), time + mTime, m_spanners);
m_delayedOttava = nullptr;
}
Fraction missingPrev;
Fraction dura;
Fraction missingCurr;
Expand Down Expand Up @@ -2831,6 +2841,7 @@ void MusicXMLParserDirection::direction(const String& partId,
track_idx_t track = m_pass1.trackForPart(partId);
bool isVocalStaff = m_pass1.isVocalStaff(partId);
bool isExpressionText = false;
bool delayOttava = m_pass1.exporterString().contains(u"sibelius");
//LOGD("direction track %d", track);
std::vector<MusicXmlSpannerDesc> starts;
std::vector<MusicXmlSpannerDesc> stops;
Expand Down Expand Up @@ -3020,8 +3031,16 @@ void MusicXMLParserDirection::direction(const String& partId,
delete desc.sp;
} else {
if (spdesc.isStarted) {
handleSpannerStop(spdesc.sp, track, tick + m_offset, spanners);
m_pass2.clearSpanner(desc);
if (spdesc.sp && spdesc.sp->isOttava() && delayOttava) {
// Sibelius writes ottava ends 1 note too early
m_pass2.setDelayedOttava(spdesc.sp);
m_pass2.delayedOttava()->setTrack2(track);
m_pass2.delayedOttava()->setTick2(tick + m_offset);
m_pass2.clearSpanner(desc);
} else {
handleSpannerStop(spdesc.sp, track, tick + m_offset, spanners);
m_pass2.clearSpanner(desc);
}
} else {
spdesc.sp = desc.sp;
spdesc.tick2 = tick + m_offset;
Expand Down Expand Up @@ -3222,15 +3241,14 @@ void MusicXMLParserDirection::otherDirection()
// TODO: Multiple sets of maps for exporters other than Dolet 6/Sibelius
// TODO: Add more symbols from Sibelius
std::map<String, String> otherDirectionStrings;
if (m_pass1.exporterString().contains(u"Dolet")) {
if (m_pass1.exporterString().contains(u"dolet")) {
otherDirectionStrings = {
{ String(u"To Coda"), String(u"To Coda") },
{ String(u"Segno"), String(u"<sym>segno</sym>") },
{ String(u"CODA"), String(u"<sym>coda</sym>") },
};
}
std::map<String, SymId> otherDirectionSyms;
otherDirectionSyms = { { String(u"Rhythm dot"), SymId::augmentationDot },
static const std::map<String, SymId> otherDirectionSyms = { { String(u"Rhythm dot"), SymId::augmentationDot },
{ String(u"Whole rest"), SymId::restWhole },
{ String(u"l.v. down"), SymId::articLaissezVibrerBelow },
{ String(u"8vb"), SymId::ottavaBassaVb },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ class MusicXMLParserPass2
void deleteHandledSpanner(SLine* const& spanner);
int divs() { return m_divs; }

SLine* delayedOttava() { return m_delayedOttava; }
void setDelayedOttava(SLine* ottava) { m_delayedOttava = ottava; }

private:
void addError(const String& error); // Add an error to be shown in the GUI
void initPartState(const String& partId);
Expand Down Expand Up @@ -359,6 +362,7 @@ class MusicXMLParserPass2
Harmony* m_harmony = nullptr; // Current harmony
Chord* m_tremStart = nullptr; // Starting chord for current tremolo
FiguredBass* m_figBass = nullptr; // Current figured bass element (to attach to next note)
SLine* m_delayedOttava = nullptr; // Current delayed ottava
int m_multiMeasureRestCount = 0;
int m_measureNumber = 0; // Current measure number as written in the score
MusicXmlLyricsExtend m_extendedLyrics; // Lyrics with "extend" requiring fixup
Expand Down Expand Up @@ -424,7 +428,6 @@ class MusicXMLParserDirection
String m_sndFine;
String m_sndSegno;
String m_sndToCoda;
bool visible = true;
bool m_hasDefaultY = false;
double m_defaultY = 0.0;
bool m_hasRelativeY = false;
Expand Down
Binary file not shown.
271 changes: 271 additions & 0 deletions src/importexport/musicxml/tests/data/testSibOttavas_ref.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.20">
<Score>
<Division>480</Division>
<Style>
<pageWidth>8.50197</pageWidth>
<pageHeight>11.003</pageHeight>
<pagePrintableWidth>7.50197</pagePrintableWidth>
<pageEvenLeftMargin>0.5</pageEvenLeftMargin>
<pageOddLeftMargin>0.5</pageOddLeftMargin>
<pageEvenTopMargin>0.5</pageEvenTopMargin>
<pageEvenBottomMargin>0.5</pageEvenBottomMargin>
<pageOddTopMargin>0.5</pageOddTopMargin>
<pageOddBottomMargin>0.5</pageOddBottomMargin>
<pageTwosided>0</pageTwosided>
<minSystemDistance>12</minSystemDistance>
<barWidth>0.15625</barWidth>
<endBarWidth>0.5</endBarWidth>
<stemWidth>0.125</stemWidth>
<staffLineWidth>0.09375</staffLineWidth>
<ledgerLineWidth>0.15625</ledgerLineWidth>
<chordSymbolAFontFace>Times New Roman</chordSymbolAFontFace>
<chordSymbolBFontFace>Times New Roman</chordSymbolBFontFace>
<nashvilleNumberFontFace>Times New Roman</nashvilleNumberFontFace>
<smallNoteMag>0.75</smallNoteMag>
<graceNoteMag>0.6</graceNoteMag>
<slurEndWidth>0.0625</slurEndWidth>
<slurMidWidth>0.21875</slurMidWidth>
<tieEndWidth>0.0625</tieEndWidth>
<tieMidWidth>0.21875</tieMidWidth>
<tupletFontFace>Times New Roman</tupletFontFace>
<fingeringFontFace>Times New Roman</fingeringFontFace>
<lhGuitarFingeringFontFace>Times New Roman</lhGuitarFingeringFontFace>
<rhGuitarFingeringFontFace>Times New Roman</rhGuitarFingeringFontFace>
<stringNumberFontFace>Times New Roman</stringNumberFontFace>
<longInstrumentFontFace>Times New Roman</longInstrumentFontFace>
<shortInstrumentFontFace>Times New Roman</shortInstrumentFontFace>
<partInstrumentFontFace>Times New Roman</partInstrumentFontFace>
<expressionFontFace>Times New Roman</expressionFontFace>
<tempoFontFace>Times New Roman</tempoFontFace>
<tempoChangeFontFace>Times New Roman</tempoChangeFontFace>
<metronomeFontFace>Times New Roman</metronomeFontFace>
<measureNumberFontFace>Times New Roman</measureNumberFontFace>
<mmRestRangeFontFace>Times New Roman</mmRestRangeFontFace>
<translatorFontFace>Times New Roman</translatorFontFace>
<systemFontFace>Times New Roman</systemFontFace>
<staffFontFace>Times New Roman</staffFontFace>
<rehearsalMarkFontFace>Times New Roman</rehearsalMarkFontFace>
<repeatLeftFontFace>Times New Roman</repeatLeftFontFace>
<repeatRightFontFace>Times New Roman</repeatRightFontFace>
<frameFontFace>Times New Roman</frameFontFace>
<glissandoFontFace>Times New Roman</glissandoFontFace>
<bendFontFace>Times New Roman</bendFontFace>
<headerFontFace>Times New Roman</headerFontFace>
<footerFontFace>Times New Roman</footerFontFace>
<instrumentChangeFontFace>Times New Roman</instrumentChangeFontFace>
<stickingFontFace>Times New Roman</stickingFontFace>
<user1FontFace>Times New Roman</user1FontFace>
<user2FontFace>Times New Roman</user2FontFace>
<user3FontFace>Times New Roman</user3FontFace>
<user4FontFace>Times New Roman</user4FontFace>
<user5FontFace>Times New Roman</user5FontFace>
<user6FontFace>Times New Roman</user6FontFace>
<user7FontFace>Times New Roman</user7FontFace>
<user8FontFace>Times New Roman</user8FontFace>
<user9FontFace>Times New Roman</user9FontFace>
<user10FontFace>Times New Roman</user10FontFace>
<user11FontFace>Times New Roman</user11FontFace>
<user12FontFace>Times New Roman</user12FontFace>
<Spatium>1.75</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<Part id="1">
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>[Unnamed (treble staff)]</trackName>
<Instrument id="grand-piano">
<trackName></trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano.grand</instrumentId>
<clef staff="2">F</clef>
<singleNoteDynamics>0</singleNoteDynamics>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="0"/>
<controller ctrl="10" value="63"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
</VBox>
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
<isHeader>1</isHeader>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Spanner type="Ottava">
<Ottava>
<subtype>8va</subtype>
</Ottava>
<next>
<location>
<fractions>1/2</fractions>
</location>
</next>
</Spanner>
<Chord>
<durationType>eighth</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Chord>
<dots>1</dots>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Spanner type="Ottava">
<prev>
<location>
<fractions>-1/2</fractions>
</location>
</prev>
</Spanner>
<Spanner type="Ottava">
<Ottava>
<subtype>8vb</subtype>
</Ottava>
<next>
<location>
<measures>1</measures>
</location>
</next>
</Spanner>
<Chord>
<durationType>half</durationType>
<StemDirection>up</StemDirection>
<Note>
<Spanner type="Tie">
<Tie>
</Tie>
<next>
<location>
<measures>1</measures>
<fractions>-1/2</fractions>
</location>
</next>
</Spanner>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<Spanner type="Tie">
<prev>
<location>
<measures>-1</measures>
<fractions>1/2</fractions>
</location>
</prev>
</Spanner>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>65</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Spanner type="Ottava">
<prev>
<location>
<measures>-1</measures>
</location>
</prev>
</Spanner>
<Rest>
<durationType>half</durationType>
</Rest>
<BarLine>
<subtype>end</subtype>
</BarLine>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
Loading