Skip to content

Commit

Permalink
Merge pull request #22908 from miiizen/xml-drum-stem
Browse files Browse the repository at this point in the history
Fix stem direction on drumset XML import
  • Loading branch information
mike-spa authored May 21, 2024
2 parents 55945e8 + c1cd38c commit 9f8076b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5980,8 +5980,8 @@ static void setDrumset(Chord* c, MusicXMLParserPass1& pass1, const String& partI
pass1.setDrumsetDefault(partId, instrumentId, headGroup, line, overruledStemDir);
}

static void xmlSetDrumsetPitch(Note* note, const Chord* const chord, const Staff* const staff, int step, int octave,
NoteHeadGroup headGroup, const Instrument* const instrument)
static void xmlSetDrumsetPitch(Note* note, const Chord* chord, const Staff* staff, int step, int octave,
NoteHeadGroup headGroup, DirectionV& stemDir, const Instrument* instrument)
{
const Drumset* ds = instrument->drumset();
// get line
Expand Down Expand Up @@ -6019,6 +6019,10 @@ static void xmlSetDrumsetPitch(Note* note, const Chord* const chord, const Staff
newPitch = lineMatch;
}

if (stemDir == DirectionV::AUTO) {
stemDir = ds->stemDirection(newPitch);
}

note->setPitch(newPitch);
note->setTpcFromPitch();
}
Expand Down Expand Up @@ -6280,13 +6284,11 @@ Note* MusicXMLParserPass2::note(const String& partId,
const int octaveShift = m_pass1.octaveShift(partId, ottavaStaff, noteStartTime);
const Staff* st = c->staff();
if (isSingleDrumset && mnp.unpitched() && instrumentId.empty()) {
xmlSetDrumsetPitch(note, c, st, mnp.displayStep(), mnp.displayOctave(), headGroup, instrument);
xmlSetDrumsetPitch(note, c, st, mnp.displayStep(), mnp.displayOctave(), headGroup, stemDir, instrument);
} else {
setPitch(note, instruments, instrumentId, mnp, octaveShift, instrument);
}
c->add(note);
//c->setStemDirection(stemDir); // already done in handleBeamAndStemDir()
//c->setNoStem(noStem);
cr = c;
}
// end allocation
Expand Down
8 changes: 8 additions & 0 deletions src/importexport/musicxml/tests/data/testImportDrums_ref.mscx
Original file line number Diff line number Diff line change
Expand Up @@ -295,20 +295,23 @@
</Tempo>
<Chord>
<durationType>quarter</durationType>
<StemDirection>down</StemDirection>
<Note>
<pitch>36</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>38</pitch>
<tpc>16</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>51</pitch>
<tpc>11</tpc>
Expand All @@ -317,6 +320,7 @@
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>42</pitch>
<tpc>20</tpc>
Expand All @@ -329,27 +333,31 @@
<voice>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>47</pitch>
<tpc>19</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>45</pitch>
<tpc>17</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>41</pitch>
<tpc>13</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<pitch>49</pitch>
<tpc>21</tpc>
Expand Down

0 comments on commit 9f8076b

Please sign in to comment.