Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU4] fix MU3 issue #323402, accidentals not shown as expected for altered unisons #8772

Merged
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
14 changes: 14 additions & 0 deletions src/engraving/libmscore/note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,16 @@ bool Note::dotIsUp() const
}
}

static bool hasAlteredUnison(Note* note)
{
const auto& chordNotes = note->chord()->notes();
AccidentalVal accVal = tpc2alter(note->tpc());
int relLine = absStep(note->tpc(), note->epitch());
return std::find_if(chordNotes.begin(), chordNotes.end(), [note, accVal, relLine](Note* n) {
return n != note && !n->hidden() && absStep(n->tpc(), n->epitch()) == relLine && tpc2alter(n->tpc()) != accVal;
}) != chordNotes.end();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i.e. look for a note on the same A-G step (including octave), but that would require a different accidental.

}

//---------------------------------------------------------
// updateAccidental
// set _accidental and _line depending on tpc
Expand Down Expand Up @@ -2354,6 +2364,10 @@ void Note::updateAccidental(AccidentalState* as)
} else if (acci == AccidentalType::NONE) {
acci = AccidentalType::NATURAL;
}
} else if (hasAlteredUnison(this)) {
if ((acci = Accidental::value2subtype(accVal)) == AccidentalType::NONE) {
acci = AccidentalType::NATURAL;
}
}
if (acci != AccidentalType::NONE && !_hidden) {
if (_accidental == 0) {
Expand Down
187 changes: 187 additions & 0 deletions src/engraving/tests/note_data/altered-unison.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.02">
<programVersion>3.6.2</programVersion>
<programRevision>3224f34</programRevision>
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<pageWidth>8.27</pageWidth>
<pageHeight>11.69</pageHeight>
<enableVerticalSpread>1</enableVerticalSpread>
<useStandardNoteNames>0</useStandardNoteNames>
<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="creationDate">2021-07-31</metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">Microsoft Windows</metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle">x</metaTag>
<Order id="orchestral" customized="1">
<name>Orchestral</name>
<instrument id="piano">
<family id="keyboards">Keyboards</family>
</instrument>
<section id="woodwind" brackets="true" showSystemMarkings="true" barLineSpan="true" thinBrackets="true">
<family>flutes</family>
<family>oboes</family>
<family>clarinets</family>
<family>saxophones</family>
<family>bassoons</family>
<unsorted group="woodwinds"/>
</section>
<section id="brass" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>horns</family>
<family>trumpets</family>
<family>cornets</family>
<family>flugelhorns</family>
<family>trombones</family>
<family>tubas</family>
</section>
<section id="timpani" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>timpani</family>
</section>
<section id="percussion" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>keyboard-percussion</family>
<family>drums</family>
<family>unpitched-metal-percussion</family>
<family>unpitched-wooden-percussion</family>
<family>other-percussion</family>
</section>
<family>keyboards</family>
<family>harps</family>
<family>organs</family>
<family>synths</family>
<section id="plucked-strings" brackets="true" showSystemMarkings="false" barLineSpan="true" thinBrackets="true">
<family>plucked-strings</family>
</section>
<soloists/>
<section id="voices" brackets="true" showSystemMarkings="false" barLineSpan="false" thinBrackets="true">
<family>voices</family>
</section>
<section id="strings" brackets="true" showSystemMarkings="true" barLineSpan="true" thinBrackets="true">
<family>orchestral-strings</family>
</section>
<unsorted/>
</Order>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="1" span="2" col="2"/>
<barLineSpan>1</barLineSpan>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano</instrumentId>
<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"/>
<synti>Fluid</synti>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<Text>
<style>Title</style>
<text>x</text>
</Text>
</VBox>
<Measure>
<voice>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Chord>
<durationType>quarter</durationType>
<Note>
<Accidental><subtype>accidentalFlat</subtype></Accidental>
<pitch>70</pitch><tpc>12</tpc>
</Note>
<Note>
<Accidental><subtype>accidentalNatural</subtype></Accidental>
<pitch>71</pitch><tpc>19</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<Note>
<Accidental><subtype>accidentalSharp</subtype></Accidental>
<pitch>73</pitch><tpc>21</tpc>
</Note>
<Note>
<Accidental><subtype>accidentalNatural</subtype></Accidental>
<pitch>72</pitch><tpc>14</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
13 changes: 13 additions & 0 deletions src/engraving/tests/tst_note.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ private slots:
void tpcTranspose2();
void noteLimits();
void tpcDegrees();
void alteredUnison();
void LongNoteAfterShort_183746();
};

Expand Down Expand Up @@ -513,6 +514,18 @@ void TestNote::tpcDegrees()
//QCOMPARE(tpc2degree(Tpc::TPC_B_S, Key::C_S), 7);
}

void TestNote::alteredUnison()
{
MasterScore* score = readScore(NOTE_DATA_DIR + "altered-unison.mscx");
Measure* m = score->firstMeasure();
Chord* c = m->findChord(Fraction(0, 1), 0);
QVERIFY(c->downNote()->accidental() && c->downNote()->accidental()->accidentalType() == Ms::AccidentalType::FLAT);
QVERIFY(c->upNote()->accidental() && c->upNote()->accidental()->accidentalType() == Ms::AccidentalType::NATURAL);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would have preferred to use QCOMPARE however this is crashing for me using MSVC debug C runtime, when it tries to delete the strings returned by QTest::toString( ). No idea why, it all looks fine stepping through it.

c = m->findChord(Fraction(1, 4), 0);
QVERIFY(c->downNote()->accidental() && c->downNote()->accidental()->accidentalType() == Ms::AccidentalType::NATURAL);
QVERIFY(c->upNote()->accidental() && c->upNote()->accidental()->accidentalType() == Ms::AccidentalType::SHARP);
}

//---------------------------------------------------------
/// LongNoteAfterShort_183746
/// Put a small 128th rest
Expand Down