Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricelacharme committed Jan 6, 2025
1 parent 8580ad3 commit 505ce39
Showing 1 changed file with 36 additions and 16 deletions.
52 changes: 36 additions & 16 deletions KMusicXml/MusicXml/Domain/Part.cs
Original file line number Diff line number Diff line change
Expand Up @@ -894,10 +894,12 @@ private static Note GetNote(XElement node, int mult, int chromatictranspose, int
// Velocity
note.Velocity = SoundDynamics;

// Warning: alter maybe -1.5
string accidental = "";
if (alter != null)
{
switch (int.Parse(alter.Value))
//switch (int.Parse(alter.Value))
switch (ConvertStringValue(alter.Value))
{
case 1:
accidental = "S";
Expand All @@ -908,7 +910,7 @@ private static Note GetNote(XElement node, int mult, int chromatictranspose, int
default:
break;
}
note.Pitch.Alter = int.Parse(alter.Value);
note.Pitch.Alter = ConvertStringValue(alter.Value);
}

note.Accidental = accidental;
Expand Down Expand Up @@ -970,21 +972,39 @@ private static Note GetNote(XElement node, int mult, int chromatictranspose, int

if (tiesnext != null && tiesnext.Count() > 0)
{
var stepnext = e.Descendants("step").FirstOrDefault();

if (bStart && stepnext.Value == step.Value)
{
var ddur = e.Descendants("duration").FirstOrDefault();
if (ddur != null)
{
int ddd = int.Parse(ddur.Value) * mult;
note.Duration += ddd;
if (!note.IsDrums)
{
var stepnext = e.Descendants("step").FirstOrDefault();
if (bStart && stepnext.Value == step.Value)
{
var ddur = e.Descendants("duration").FirstOrDefault();
if (ddur != null)
{
int ddd = int.Parse(ddur.Value) * mult;
note.Duration += ddd;

// Only one linked note => break
if (tiesnext.Count() == 1 && ttie.Attribute("type").Value == "stop")
break;
//else if (tiesnext.Count() == 2)
// Console.WriteLine("");
// Only one linked note => break
if (tiesnext.Count() == 1 && ttie.Attribute("type").Value == "stop")
break;
}
}
}
else
{
// Drums
var displaystepnext = e.Descendants("display-step").FirstOrDefault();
if (bStart && displaystepnext.Value == displaystep.Value)
{
var ddur = e.Descendants("duration").FirstOrDefault();
if (ddur != null)
{
int ddd = int.Parse(ddur.Value) * mult;
note.Duration += ddd;

// Only one linked note => break
if (tiesnext.Count() == 1 && ttie.Attribute("type").Value == "stop")
break;
}
}
}
}
Expand Down

0 comments on commit 505ce39

Please sign in to comment.