elNote.appendChild(elDuration);
// tie start/stop
boolean bDoNotation = false;
if (note.isStartOfTie())
{ Element elTie = new Element("tie");
Attribute atType = new Attribute("type", "start");
elTie.addAttribute(atType);
elNote.appendChild(elTie);
bDoNotation = true;
}
else if (note.isEndOfTie())
{ Element elTie = new Element("tie");
Attribute atType = new Attribute("type", "stop");
elTie.addAttribute(atType);
elNote.appendChild(elTie);
bDoNotation = true;
}
// duration type
String sDuration;
boolean bDotted = false;
if (dDuration == 1.0)
sDuration = "whole";
else if (dDuration == 0.75)
{ sDuration = "half";
bDotted = true;
}
else if (dDuration == 0.5)
sDuration = "half";
else if (dDuration == 0.375)
{ sDuration = "quarter";
bDotted = true;
}
else if (dDuration == 0.25)
sDuration = "quarter";
else if (dDuration == 0.1875)
{ sDuration = "eighth";
bDotted = true;
}
else if (dDuration == 0.125)
sDuration = "eighth";
else if (dDuration == 0.09375)
{ sDuration = "16th";
bDotted = true;
}
else if (dDuration == 0.0625)
sDuration = "16th";
else if (dDuration == 0.046875)
{ sDuration = "32nd";
bDotted = true;
}
else if (dDuration == 0.03125)
sDuration = "32nd";
else if (dDuration == 0.0234375)
{ sDuration = "64th";
bDotted = true;
}
else if (dDuration == 0.015625)
sDuration = "64th";
else if (dDuration == 0.01171875)
{ sDuration = "128th";
bDotted = true;
}
else if (dDuration == 0.0078125)
sDuration = "128th";
else sDuration = "/" + Double.toString(dDuration);
Element elType = new Element("type");
elType.appendChild(sDuration);
elNote.appendChild(elType);
// dotted
if (bDotted)
{ Element elDot = new Element("dot");
elNote.appendChild(elDot);
}
// notations
if (bDoNotation)
{ Element elNotations = new Element("notations");
if (note.isStartOfTie())
{ Element elTied = new Element("tied");
Attribute atStart = new Attribute("type", "start");
elTied.addAttribute(atStart);
elNotations.appendChild(elTied);
}
else if (note.isEndOfTie())
{ Element elTied = new Element("tied");
Attribute atStart = new Attribute("type", "stop");
elTied.addAttribute(atStart);
elNotations.appendChild(elTied);
}
elNote.appendChild(elNotations);
}