Skip to content

Commit

Permalink
Merge pull request #26990 from rettinghaus/xml/feathered
Browse files Browse the repository at this point in the history
[MusicXML] import feathered beams
  • Loading branch information
miiizen authored Mar 11, 2025
2 parents e0607d9 + 139b3bf commit 9f0151f
Show file tree
Hide file tree
Showing 3 changed files with 1,102 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,7 @@ static void setChordRestDuration(ChordRest* cr, TDuration duration, const Fracti

/**
* Add a rest to the score
* TODO: beam handling
* TODO: display step handling
* TODO: visible handling
* TODO: whole measure rest handling
*/

static Rest* addRest(Score*, Measure* m,
Expand Down Expand Up @@ -2404,7 +2401,8 @@ static void removeBeam(Beam*& beam)
// handleBeamAndStemDir
//---------------------------------------------------------

static void handleBeamAndStemDir(ChordRest* cr, const BeamMode bm, const DirectionV sd, Beam*& beam, bool hasBeamingInfo, Color beamColor)
static void handleBeamAndStemDir(ChordRest* cr, const BeamMode bm, const DirectionV sd, Beam*& beam,
bool hasBeamingInfo, Color beamColor, const String fan)
{
if (!cr) {
return;
Expand All @@ -2423,6 +2421,9 @@ static void handleBeamAndStemDir(ChordRest* cr, const BeamMode bm, const Directi
if (beamColor.isValid()) {
beam->setColor(beamColor);
}
if (!fan.empty() && fan != u"none") {
beam->setAsFeathered(fan == u"rit");
}
}
// add ChordRest to beam
if (beam) {
Expand Down Expand Up @@ -3066,8 +3067,8 @@ void MusicXmlParserPass2::staffDetails(const String& partId, Measure* measure)
staff_idx_t staffIdx = m_score->staffIdx(part) + n;

StringData stringData;
String visible = m_e.attribute("print-object");
String spacing = m_e.attribute("print-spacing");
AsciiStringView visible = m_e.asciiAttribute("print-object");
AsciiStringView spacing = m_e.asciiAttribute("print-spacing");
if (visible == "no") {
// EITHER:
// 1) this indicates an empty staff that is hidden
Expand All @@ -3084,7 +3085,7 @@ void MusicXmlParserPass2::staffDetails(const String& partId, Measure* measure)
// this doesn't apply to a measure, so we'll assume the entire staff has to be hidden.
m_score->staff(staffIdx)->setVisible(false);
}
} else if (visible == u"yes" || visible.empty()) {
} else if (visible == "yes" || visible.empty()) {
if (measure) {
m_score->staff(staffIdx)->setVisible(true);
measure->setStaffVisible(staffIdx, true);
Expand Down Expand Up @@ -6699,6 +6700,7 @@ Note* MusicXmlParserPass2::note(const String& partId,
bool isSingleDrumset = false;
BeamMode bm;
std::map<int, String> beamTypes;
String beamFan;
String instrumentId;
String tieType;
MusicXmlParserLyric lyric { m_pass1.getMusicXmlPart(partId).lyricNumberHandler(), m_e, m_score, m_logger,
Expand All @@ -6715,6 +6717,7 @@ Note* MusicXmlParserPass2::note(const String& partId,
// element handled
} else if (m_e.name() == "beam") {
beamColor = Color::fromString(m_e.asciiAttribute("color").ascii());
beamFan = m_e.attribute("fan");
beam(beamTypes);
} else if (m_e.name() == "chord") {
chord = true;
Expand Down Expand Up @@ -6986,7 +6989,7 @@ Note* MusicXmlParserPass2::note(const String& partId,
// regular note
// handle beam
if (!chord) {
handleBeamAndStemDir(c, bm, stemDir, currBeam, m_pass1.hasBeamingInfo(), beamColor);
handleBeamAndStemDir(c, bm, stemDir, currBeam, m_pass1.hasBeamingInfo(), beamColor, beamFan);
}

// append any grace chord after chord to the previous chord
Expand Down
Loading

0 comments on commit 9f0151f

Please sign in to comment.