Skip to content

Commit

Permalink
Merge pull request #3896 from handrok/#274933-fingering
Browse files Browse the repository at this point in the history
fix #274933: add ability to read fingering from score v.1.14
  • Loading branch information
anatoly-os committed Aug 24, 2018
2 parents e5d59a7 + e580e23 commit 55e0a7a
Show file tree
Hide file tree
Showing 4 changed files with 379 additions and 1 deletion.
49 changes: 48 additions & 1 deletion libmscore/read114.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,53 @@ static NoteHead::Group convertHeadGroup(int i)
return val;
}


//---------------------------------------------------------
// readFingering114
//---------------------------------------------------------

static void readFingering114(XmlReader& e, Fingering* fing)
{
bool isStringNumber = false;
while (e.readNextStartElement()) {
const QStringRef& tag(e.name());

if (tag == "html-data") {
auto htmlDdata = QTextDocumentFragment::fromHtml(e.readXml()).toPlainText();
htmlDdata.replace(" ", "");
fing->setPlainText(htmlDdata);
}
else if (tag == "subtype") {
auto subtype = e.readElementText();
if (subtype == "StringNumber") {
isStringNumber = true;
fing->setProperty(Pid::SUB_STYLE, QVariant(10));
fing->setPropertyFlags(Pid::SUB_STYLE, PropertyFlags::UNSTYLED);
}
}
else if (tag == "frame") {
auto frame = e.readInt();
if (frame)
if (isStringNumber) //default value is circle for stringnumber, square is setted in tag circle
fing->setFrameType(FrameType::CIRCLE);
else //default value is square for stringnumber, circle is setted in tag circle
fing->setFrameType(FrameType::SQUARE);
else
fing->setFrameType(FrameType::NO_FRAME);
}
else if (tag == "circle") {
auto circle = e.readInt();
if (circle)
fing->setFrameType(FrameType::CIRCLE);
else
fing->setFrameType(FrameType::SQUARE);
}
else {
e.skipCurrentElement();
}
}
}

//---------------------------------------------------------
// readNote
//---------------------------------------------------------
Expand Down Expand Up @@ -679,7 +726,7 @@ static void readNote(Note* note, XmlReader& e)
}
else if (tag == "Text") {
Fingering* f = new Fingering(note->score());
f->read300(e);
readFingering114(e, f);
note->add(f);
}
else if (tag == "onTimeType") {
Expand Down
158 changes: 158 additions & 0 deletions mtest/libmscore/compat114/fingering-ref.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.01">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<lyricsMinBottomDistance>6</lyricsMinBottomDistance>
<minMeasureWidth>4</minMeasureWidth>
<endBarDistance>0.3</endBarDistance>
<bracketWidth>0.35</bracketWidth>
<bracketDistance>0.25</bracketDistance>
<clefLeftMargin>0.5</clefLeftMargin>
<clefKeyRightMargin>1.75</clefKeyRightMargin>
<clefBarlineDistance>0.18</clefBarlineDistance>
<minNoteDistance>0.4</minNoteDistance>
<barNoteDistance>1.2</barNoteDistance>
<measureSpacing>1.14</measureSpacing>
<ledgerLineWidth>0.12</ledgerLineWidth>
<beamWidth>0.48</beamWidth>
<beamMinLen>1.25</beamMinLen>
<propertyDistanceStem>0.5</propertyDistanceStem>
<chordStyle>custom</chordStyle>
<chordsXmlFile>1</chordsXmlFile>
<chordDescriptionFile>stdchords.xml</chordDescriptionFile>
<hideInstrumentNameIfOneInstrument>0</hideInstrumentNameIfOneInstrument>
<voltaY>0</voltaY>
<keySigNaturals>1</keySigNaturals>
<tupletOufOfStaff>0</tupletOufOfStaff>
<Spatium>1.76389</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="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
</StaffType>
<bracket type="-1" span="1" col="0"/>
</Staff>
<trackName>Guitar</trackName>
<Instrument>
<longName><font face="Times New Roman"/>Guitar</longName>
<shortName><font face="Times New Roman"/>Guit.</shortName>
<trackName>Guitar</trackName>
<minPitchP>40</minPitchP>
<maxPitchP>83</maxPitchP>
<minPitchA>40</minPitchA>
<maxPitchA>83</maxPitchA>
<StringData>
<frets>19</frets>
<string>40</string>
<string>45</string>
<string>50</string>
<string>55</string>
<string>59</string>
<string>64</string>
</StringData>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="24"/>
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<Text>
<style>Title</style>
<text><font face="Times New Roman"/>fing</text>
</Text>
</VBox>
<Measure>
<voice>
<Clef>
<concertClefType>G8vb</concertClefType>
<transposingClefType>G8vb</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>quarter</durationType>
<Note>
<Fingering>
<text>1</text>
</Fingering>
<pitch>55</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<Fingering>
<style>String Number</style>
<text>2</text>
</Fingering>
<pitch>55</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>57</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>57</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<BarLine>
<subtype>end</subtype>
</BarLine>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
172 changes: 172 additions & 0 deletions mtest/libmscore/compat114/fingering.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="1.14">
<Spatium>1.76389</Spatium>
<Division>480</Division>
<showInvisible>1</showInvisible>
<showFrames>1</showFrames>
<page-layout>
<pageFormat>A4</pageFormat>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-offset>0</page-offset>
</page-layout>
<siglist>
<sig tick="0">
<nom>4</nom>
<denom>4</denom>
</sig>
</siglist>
<tempolist fix="2">
</tempolist>
<Part>
<Staff>
<cleflist>
<clef tick="0" idx="3"/>
</cleflist>
<keylist>
<key tick="0" idx="0"/>
</keylist>
<bracket type="-1" span="1"/>
</Staff>
<name>
<style>9</style>
<subtype>InstrumentLong</subtype>
<frame>0</frame>
<html-data>
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Times New Roman'; font-size:12pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">Guitar</span></p></body></html>
</html-data>
</name>
<shortName>
<style>10</style>
<subtype>InstrumentShort</subtype>
<frame>0</frame>
<html-data>
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Times New Roman'; font-size:12pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt;">Guit.</span></p></body></html>
</html-data>
</shortName>
<Instrument>
<minPitchP>40</minPitchP>
<maxPitchP>83</maxPitchP>
<minPitchA>40</minPitchA>
<maxPitchA>83</maxPitchA>
<trackName>Guitar</trackName>
<Channel>
<controller ctrl="0" value="0"/>
<controller ctrl="32" value="0"/>
<program value="24"/>
<controller ctrl="7" value="100"/>
<controller ctrl="10" value="64"/>
<controller ctrl="93" value="30"/>
<controller ctrl="91" value="30"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<leftMargin>5</leftMargin>
<rightMargin>5</rightMargin>
<topMargin>5</topMargin>
<bottomMargin>5</bottomMargin>
<Text>
<style>2</style>
<subtype>Title</subtype>
<frame>0</frame>
<html-data>
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Times New Roman'; font-size:24pt; font-weight:400; font-style:normal;">
<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">fing</p></body></html>
</html-data>
</Text>
</VBox>
<Measure number="1">
<TimeSig>
<subtype>260</subtype>
<den>4</den>
<nom1>4</nom1>
</TimeSig>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>55</pitch>
<tpc>15</tpc>
<Text>
<style>8</style>
<subtype>Fingering</subtype>
<offset x="0.3" y="-5.25"/>
<pos x="-0.324609" y="-6.45"/>
<frame>0</frame>
<html-data>
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Times New Roman'; font-size:8.00001pt; font-weight:400; font-style:normal;">
<table style="-qt-table-type: root; margin-top:1px; margin-bottom:1px; margin-left:1px; margin-right:1px;">
<tr>
<td style="border: none;">
<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">1</span></p></td></tr></table></body></html>
</html-data>
</Text>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>55</pitch>
<tpc>15</tpc>
<Text>
<style>31</style>
<subtype>StringNumber</subtype>
<offset x="-0.45" y="-0.15"/>
<pos x="-0.240514" y="-6.25669"/>
<selected>1</selected>
<frame>1</frame>
<html-data>
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Times New Roman'; font-size:8.00001pt; font-weight:400; font-style:normal;">
<table style="-qt-table-type: root; margin-top:1px; margin-bottom:1px; margin-left:1px; margin-right:1px;">
<tr>
<td style="border: none;">
<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">2</span></p></td></tr></table></body></html>
</html-data>
</Text>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>57</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<pitch>57</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<BarLine>
<subtype>5</subtype>
</BarLine>
</Measure>
</Staff>
<cursorTrack>0</cursorTrack>
</museScore>
Loading

0 comments on commit 55e0a7a

Please sign in to comment.