Skip to content

Commit

Permalink
ENG-5: Change inferred credits to composer
Browse files Browse the repository at this point in the history
Rather than inferring credit text as a subtitle, it is now converted
to a composer. Additional, some space is added to the in the case of
long credits.

Duplicate of musescore#8413, part 2
  • Loading branch information
iveshenry18 authored and Jojo-Schmitz committed Sep 1, 2021
1 parent 758762d commit 9bb4f85
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 22 deletions.
10 changes: 6 additions & 4 deletions importexport/musicxml/importmxmlpass2.cpp
Expand Up @@ -2530,11 +2530,13 @@ void MusicXMLParserDirection::direction(const QString& partId,

// create text if any text was found
if (isLikelyCredit(tick)) {
Text* t = new Text(_score, Tid::SUBTITLE);
t->setLayoutToParentWidth(true);
t->setXmlText(_wordsText);
Text* t = new Text(_score, Tid::COMPOSER);
t->setXmlText(_wordsText.trimmed());
auto firstMeasure = _score->measures()->first();
VBox* vbox = firstMeasure->isVBox() ? toVBox(firstMeasure) : MusicXMLParserPass1::createAndAddVBoxForCreditWords(_score);
t->layout();
vbox->layout();
vbox->setBoxHeight(vbox->boxHeight() + Spatium(t->height()/_score->spatium())/2); // add some height
vbox->add(t);
}
else if (_wordsText != "" || _rehearsalText != "" || _metroText != "") {
Expand Down Expand Up @@ -2939,7 +2941,7 @@ bool MusicXMLParserDirection::isLikelyCredit(const Fraction& tick) const
&& _rehearsalText == ""
&& _metroText == ""
&& _tpoSound < 0.1
&& _wordsText.contains(QRegularExpression("((Words|Music|Lyrics).*)+by\\s+([A-Z][a-zA-Z'’-]+\\s[A-Z][a-zA-Z'’-]+.*)+"));
&& _wordsText.contains(QRegularExpression("^\\s*((Words|Music|Lyrics).*)*by\\s+([A-Z][a-zA-'’-]+\\s[A-Z][a-zA-Zös'’-]+.*)+"));
}

//---------------------------------------------------------
Expand Down
Binary file added mtest/musicxml/io/testInferredCredits.pdf
Binary file not shown.
Expand Up @@ -2,7 +2,7 @@
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<work>
<work-title>Inferred Subtitle</work-title>
<work-title>Inferred Credits</work-title>
</work>
<identification>
<creator type="composer">Henry Ives</creator>
Expand Down Expand Up @@ -42,12 +42,13 @@
</defaults>
<credit page="1">
<credit-type>title</credit-type>
<credit-words default-x="600" default-y="1611.43" justify="center" valign="top" font-size="22">Inferred Subtitle</credit-words>
<credit-words default-x="600" default-y="1611.86" justify="center" valign="top" font-size="22">Inferred Credits</credit-words>
</credit>
<credit page="1">
<credit-type>subtitle</credit-type>
<credit-words default-x="600" default-y="1554.28" justify="center" valign="top" font-size="16">MuseScore Testcase</credit-words>
</credit>
<part-list>
<part-group type="start" number="1">
<group-symbol>brace</group-symbol>
</part-group>
<score-part id="P1">
<part-name>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
Expand All @@ -64,7 +65,7 @@
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="293.97">
<measure number="1" width="288.37">
<print>
<system-layout>
<system-margins>
Expand All @@ -90,10 +91,14 @@
</attributes>
<direction placement="above">
<direction-type>
<words relative-y="10.00">Words and Music by Henry Ives</words>
<words default-y="34.66" relative-y="10.00">Words and Music by Henry Ives
</words>
<words>
</words>
<words></words>
</direction-type>
</direction>
<note default-x="80.72" default-y="-15.00">
<note default-x="73.72" default-y="-15.00">
<pitch>
<step>C</step>
<octave>5</octave>
Expand All @@ -108,7 +113,7 @@
<text>ha</text>
</lyric>
</note>
<note default-x="117.18" default-y="-15.00">
<note default-x="110.42" default-y="-15.00">
<pitch>
<step>C</step>
<octave>5</octave>
Expand Down Expand Up @@ -136,7 +141,7 @@
<type>half</type>
</note>
</measure>
<measure number="2" width="202.30">
<measure number="2" width="203.70">
<note default-x="26.30" default-y="-45.00">
<pitch>
<step>D</step>
Expand Down Expand Up @@ -164,21 +169,21 @@
<type>half</type>
</note>
</measure>
<measure number="3" width="160.22">
<measure number="3" width="161.62">
<note>
<rest measure="yes"/>
<duration>8</duration>
<voice>1</voice>
</note>
</measure>
<measure number="4" width="160.22">
<measure number="4" width="161.62">
<note>
<rest measure="yes"/>
<duration>8</duration>
<voice>1</voice>
</note>
</measure>
<measure number="5" width="161.86">
<measure number="5" width="163.26">
<note>
<rest measure="yes"/>
<duration>8</duration>
Expand Down
Expand Up @@ -50,7 +50,7 @@
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle">Inferred Subtitle</metaTag>
<metaTag name="workTitle">Inferred Credits</metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
Expand Down Expand Up @@ -116,14 +116,19 @@
</Part>
<Staff id="1">
<VBox>
<height>3.5</height>
<height>9.14746</height>
<Text>
<style>Title</style>
<offset x="0" y="-0.07525"/>
<text><font size="22"/>Inferred Subtitle</text>
<offset x="0" y="-0.1505"/>
<text><font size="22"/>Inferred Credits</text>
</Text>
<Text>
<style>Subtitle</style>
<offset x="0" y="9.926"/>
<text><font size="16"/>MuseScore Testcase</text>
</Text>
<Text>
<style>Composer</style>
<text>Words and Music by Henry Ives</text>
</Text>
</VBox>
Expand Down
2 changes: 1 addition & 1 deletion mtest/musicxml/io/tst_mxml_io.cpp
Expand Up @@ -130,8 +130,8 @@ private slots:
void incompleteTuplet() { mxmlIoTestRef("testIncompleteTuplet"); }
void incorrectStaffNumber1() { mxmlIoTestRef("testIncorrectStaffNumber1"); }
void incorrectStaffNumber2() { mxmlIoTestRef("testIncorrectStaffNumber2"); }
void inferredCredits() { mxmlImportTestRef("testInferredCredits"); }
void inferredFingerings() { mxmlImportTestRef("testInferredFingerings"); }
void inferredSubtitle() { mxmlImportTestRef("testInferredSubtitle"); }
void instrumentChangeMIDIportExport() { mxmlMscxExportTestRef("testInstrumentChangeMIDIportExport"); }
void instrumentSound() { mxmlIoTestRef("testInstrumentSound"); }
void invalidTimesig() { mxmlIoTestRef("testInvalidTimesig"); }
Expand Down

0 comments on commit 9bb4f85

Please sign in to comment.