Skip to content

Commit

Permalink
[MusicXML] Add glissando line styles
Browse files Browse the repository at this point in the history
Backport of musescore#26559
  • Loading branch information
rettinghaus authored and Jojo-Schmitz committed Feb 18, 2025
1 parent 5ae3556 commit 84509f2
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 15 deletions.
29 changes: 18 additions & 11 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,18 +881,25 @@ static void glissando(const Glissando* gli, int number, bool start, Notations& n
{
GlissandoType st = gli->glissandoType();
QString tagName;
switch (st) {
case GlissandoType::STRAIGHT:
tagName = "slide line-type=\"solid\"";
break;
case GlissandoType::WAVY:
tagName = "glissando line-type=\"wavy\"";
break;
default:
qDebug("unknown glissando subtype %d", int(st));
return;
break;
if (st == GlissandoType::STRAIGHT) {
switch (gli->lineStyle()) {
case Qt::SolidLine:
tagName = "slide line-type=\"solid\"";
break;
case Qt::DashLine:
tagName = "slide line-type=\"dashed\"";
break;
case Qt::DotLine:
tagName = "slide line-type=\"dotted\"";
break;
default:
qDebug("Unknown glissando subtype %d", int(st));
break;
}
}
else
tagName = "glissando line-type=\"wavy\"";

tagName += QString(" number=\"%1\" type=\"%2\"").arg(number).arg(start ? "start" : "stop");
if (start) {
tagName += color2xml(gli);
Expand Down
15 changes: 11 additions & 4 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8013,10 +8013,11 @@ static void addGlissandoSlide(const Notation& notation, Note* note,
MxmlLogger* logger, const QXmlStreamReader* const xmlreader)
{
int glissandoNumber = notation.attribute("number").toInt();
if (glissandoNumber > 0) glissandoNumber--;
if (glissandoNumber > 0)
glissandoNumber--;
const QString glissandoType = notation.attribute("type");
int glissandoTag = notation.name() == "slide" ? 0 : 1;
// QString lineType = ee.attribute(QString("line-type"), "solid");
const bool glissandoTag = notation.name() != "slide";
const QString lineType = notation.attribute("line-type");
Glissando*& gliss = glissandi[glissandoNumber][glissandoTag];

const Fraction tick = note->tick();
Expand All @@ -8041,8 +8042,14 @@ static void addGlissandoSlide(const Notation& notation, Note* note,
gliss->setParent(note);
if (glissandoColor.isValid()/* && preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTLAYOUT)*/)
gliss->setLineColor(glissandoColor);
if (lineType == "dashed")
gliss->setLineStyle(Qt::DashLine);
else if (lineType == "dotted")
gliss->setLineStyle(Qt::DotLine);
else if (lineType == "solid" || lineType.isEmpty())
gliss->setLineStyle(Qt::SolidLine);
gliss->setText(glissandoText);
gliss->setGlissandoType(glissandoTag == 0 ? GlissandoType::STRAIGHT : GlissandoType::WAVY);
gliss->setGlissandoType(glissandoTag || (lineType == "wavy") ? GlissandoType::WAVY : GlissandoType::STRAIGHT);
spanners[gliss] = QPair<int, int>(tick.ticks(), -1);
// qDebug("glissando/slide=%p inserted at first tick %d", gliss, tick);
}
Expand Down
167 changes: 167 additions & 0 deletions mtest/musicxml/io/testGlissandoLines.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-number>MuseScore testfile</work-number>
<work-title>Glissando line types</work-title>
</work>
<identification>
<creator type="composer">Klaus Rettinghaus</creator>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Piano</instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>1</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<slide line-type="solid" number="1" type="start"/>
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>down</stem>
<notations>
<slide line-type="solid" number="1" type="stop"/>
</notations>
</note>
</measure>
<measure number="2">
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<slide line-type="dashed" number="1" type="start"/>
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>down</stem>
<notations>
<slide line-type="dashed" number="1" type="stop"/>
</notations>
</note>
</measure>
<measure number="3">
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<slide line-type="dotted" number="1" type="start"/>
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>down</stem>
<notations>
<slide line-type="dotted" number="1" type="stop"/>
</notations>
</note>
</measure>
<measure number="4">
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>up</stem>
<notations>
<glissando line-type="wavy" number="1" type="start">gliss.</glissando>
</notations>
</note>
<note>
<pitch>
<step>C</step>
<octave>5</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>half</type>
<stem>down</stem>
<notations>
<glissando line-type="wavy" number="1" type="stop"/>
</notations>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
1 change: 1 addition & 0 deletions mtest/musicxml/io/tst_mxml_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ private slots:
void fractionTicks() { mxmlIoTestRef("testFractionTicks"); }
void fretboardDiagrams() { mxmlImportTestRef("testFretboardDiagrams"); }
void fretDiagramLayoutOrder() { mxmlImportTestRef("testFretDiagramLayoutOrder"); }
void glissandoLines() { mxmlIoTest("testGlissandoLines"); }
void grace1() { mxmlIoTest("testGrace1"); }
void grace2() { mxmlIoTest("testGrace2"); }
void grace3() { mxmlIoTest("testGrace3"); }
Expand Down

0 comments on commit 84509f2

Please sign in to comment.